ignore_and_fire#

class brainpy.state.ignore_and_fire(in_size, phase=1.0, rate=Quantity(10., 'Hz'), name=None)#

Ignore-and-fire neuron model for generating spikes at fixed intervals.

Description

The ignore_and_fire neuron is a neuron model that generates spikes at a predefined rate with a constant inter-spike interval (“fire”), irrespective of its inputs (“ignore”). In this simplest version of the ignore_and_fire neuron, the inputs from other neurons or devices are not processed at all.

This is a brainpy.state re-implementation of the NEST simulator model of the same name, using NEST-standard parameterization.

1. Model equations and dynamics

The model’s internal state variable, the phase, describes the time to the next spike relative to the firing period (the inverse of the rate).

The firing period (in simulation time steps) is computed as:

\[T_{\text{fire}} = \text{round}\!\left(\frac{1}{\text{rate}} \times 1000\right) / dt\]

where rate is in spikes/s and the result is expressed in simulation time steps (NEST rounds this to the simulation grid via Time::get_steps()).

The initial phase countdown (in simulation time steps) is computed as:

\[N_{\text{phase}} = \text{round}\!\left(\frac{\text{phase}}{\text{rate}} \times 1000\right) / dt\]

In each update step, the model checks whether the countdown has reached zero:

  • If phase_steps == 0: a spike is emitted and the countdown is reset to firing_period_steps - 1.

  • Otherwise: the countdown is decremented by 1.

To create asynchronous activity for a population of ignore_and_fire neurons, the firing phases can be randomly initialized.

2. Assumptions, constraints, and computational implications

  • The model assumes unit-compatible parameters and broadcast-compatible shapes against self.varshape.

  • The phase parameter must satisfy \(0 < \text{phase} \le 1\), representing fractional position within the firing period.

  • The rate parameter must be positive. Extremely low rates (< 1/1000 Hz) may cause integer overflow when converting to time steps.

  • Per-step compute is \(O(\prod \mathrm{varshape})\) with vectorized elementwise operations (phase countdown and spike emission).

  • All inputs to update() are completely ignored; the model fires deterministically based solely on its internal clock.

Note

The ignore_and_fire neuron is primarily used for neuronal-network model verification and validation purposes (“benchmarking”), in particular, to evaluate the correctness and performance of connectivity generation and inter-neuron communication. It permits an easy scaling of the network size and/or connectivity without affecting the output spike statistics. The amount of network traffic is predefined by the user, and therefore fully controllable and predictable, irrespective of the network size and structure.

Note

This model inherits from Dynamics rather than Neuron because it has no membrane potential, no threshold-based spike generation, and no subthreshold dynamics. Surrogate gradients and spike reset mechanisms are therefore not applicable.

Parameters:
  • in_size (Size) – Population shape specification. All neuron parameters are broadcast to self.varshape derived from in_size.

  • phase (ArrayLike, optional) – Initial fractional position within the firing period, where 0 means immediate firing and 1 means firing after a full period. Must satisfy \(0 < \text{phase} \le 1\). Scalar or array broadcast-compatible with varshape. Unitless. Default is 1.0.

  • rate (ArrayLike, optional) – Firing rate in spikes per second. Must be positive. Scalar or array broadcast-compatible with varshape. Default is 10. * u.Hz.

  • name (str or None, optional) – Optional node name passed to brainstate.nn.Dynamics.

Parameter Mapping

Table 22 Parameter mapping to NEST ignore_and_fire#

Parameter

Default

Math symbol

Semantics

phase

1.0

\(\phi \in (0, 1]\)

Fractional position in firing period; 1.0 = full period delay.

rate

10.0 Hz

\(f\) (Hz)

Spike rate; firing period \(T = 1/f\).

phase_steps#

Integer countdown to next spike (in simulation time steps). Decrements each step; fires when reaching zero.

Type:

ShortTermState

firing_period_steps#

Integer duration of firing period (in simulation time steps). Constant after initialization.

Type:

ShortTermState

Examples

Create an ignore_and_fire neuron with 10 Hz firing rate:

>>> import brainpy
>>> import brainstate
>>> import saiunit as u
>>>
>>> # Create an ignore_and_fire neuron with 10 Hz firing rate
>>> neuron = brainpy.state.ignore_and_fire(1, rate=10.0 * u.Hz)
>>>
>>> # Initialize the state
>>> neuron.init_state()
>>>
>>> # Step the neuron and check for spikes
>>> with brainstate.environ.context(dt=0.1 * u.ms, t=0.0 * u.ms):
...     spike = neuron.update()
...     print(f"Spike: {spike}")

Create a population with random phases for asynchronous activity:

>>> import numpy as np
>>> # Create 100 neurons with random initial phases
>>> phases = np.random.uniform(0.01, 1.0, size=100)
>>> neurons = brainpy.state.ignore_and_fire(100, phase=phases, rate=20.0 * u.Hz)

References

__init__(in_size, phase=1.0, rate=Quantity(10., 'Hz'), name=None)[source]#

Initialize the ignore_and_fire neuron model.

Stores parameters, initializes base Dynamics state, and validates parameter constraints. Does not initialize internal state variables (phase_steps, firing_period_steps); call init_state() before simulation.

Parameters:
  • in_size (Size) – Population shape specification passed to brainstate.nn.Dynamics. Determines self.varshape.

  • phase (ArrayLike, optional) – Initial fractional position within the firing period. Must satisfy \(0 < \text{phase} \le 1\). Broadcast to varshape via braintools.init.param(). Default is 1.0.

  • rate (ArrayLike, optional) – Firing rate in spikes per second. Must be positive. Broadcast to varshape via braintools.init.param(). Default is 10. * u.Hz.

  • name (str or None, optional) – Optional node name passed to brainstate.nn.Dynamics.

Raises:

ValueError – If phase violates \(0 < \text{phase} \le 1\) or rate is not strictly positive, raised by _validate_parameters().

See also

init_state

Initialize state variables before simulation.

update

Perform one simulation time step.

init_state(batch_size=None, **kwargs)[source]#

Initialize internal state variables for simulation.

Computes and stores firing_period_steps and phase_steps as brainstate.ShortTermState arrays. Both are derived from the rate and phase parameters via _calc_initial_variables().

Parameters:
  • batch_size (int or None, optional) – If provided, states are created with shape (batch_size, *varshape). None keeps unbatched state. Default is None.

  • **kwargs – Unused compatibility parameters accepted by the base-state API.

Raises:

ValueError – If phase is not in \((0, 1]\) or rate is not positive, raised during _validate_parameters() called in __init__().

Side Effects

Creates or overwrites the following instance attributes:

  • self.firing_period_steps : brainstate.ShortTermState

  • self.phase_steps : brainstate.ShortTermState

Notes

This method must be called before the first update() call, typically via neuron.init_state() or automatically through higher-level APIs like brainstate.nn.Module.init_all_states().

update(x=None)[source]#

Update the ignore_and_fire neuron for one simulation time step.

Decrements the internal phase countdown and emits spikes when the countdown reaches zero. All external inputs are completely ignored.

The update logic follows NEST’s deterministic firing schedule:

  1. Check if phase_steps == 0:

    • If yes: emit spike (output 1.0), reset countdown to firing_period_steps - 1.

    • If no: emit no spike (output 0.0), decrement countdown by 1.

  2. Update self.phase_steps with the new countdown value.

Parameters:

x (ArrayLike or None, optional) – Input signal (ignored). Accepted for API compatibility with other neuron models but has no effect on the dynamics. Any value or shape is permitted; the parameter is never accessed.

Returns:

spike – Float array with shape varshape (or (batch_size, *varshape) if initialized with batching). Contains 1.0 at positions where a spike is emitted this step and 0.0 elsewhere. Dtype is float32 or the default JAX float dtype.

Return type:

jnp.ndarray

Notes

This method must be called after init_state(). Calling update() before initialization will raise an AttributeError due to missing phase_steps state.

The spike output is suitable for direct use as delta-synapse input (units of spikes/step) or as a binary event indicator for recording.