SpikeTime

Contents

SpikeTime#

class brainpy.state.SpikeTime(in_size, indices, times, weights=1.0, time_as_step='round', name=None)#

The input neuron group characterized by spikes emitting at given times.

Internally builds a brainevent.CSR matrix of shape [n_max_time_step, n_neuron] so that update() reduces to a single CSR row slice.

>>> # Get 2 neurons, firing spikes at 10 ms and 20 ms.
>>> SpikeTime(2, times=[10, 20])
>>> # or
>>> # Get 2 neurons, the neuron 0 fires spikes at 10 ms and 20 ms.
>>> SpikeTime(2, times=[10, 20], indices=[0, 0])
>>> # or
>>> # Get 2 neurons, neuron 0 fires at 10 ms and 30 ms, neuron 1 fires at 20 ms.
>>> SpikeTime(2, times=[10, 20, 30], indices=[0, 1, 0])
>>> # or
>>> # Get 2 neurons; at 10 ms, neuron 0 fires; at 20 ms, neuron 0 and 1 fire;
>>> # at 30 ms, neuron 1 fires.
>>> SpikeTime(2, times=[10, 20, 20, 30], indices=[0, 0, 1, 1])
>>> # or
>>> # Get 2 neurons with a uniform float weight for all spikes.
>>> SpikeTime(2, times=[10, 20], indices=[0, 1], weights=2.5)
>>> # or
>>> # Get 2 neurons with per-event weights.
>>> SpikeTime(2, times=[10, 20], indices=[0, 1], weights=[0.5, 0.8])
Parameters:
  • in_size (int, tuple, list) – The neuron group geometry.

  • indices (list, tuple, ArrayType) – The neuron indices at each time point to emit spikes.

  • times (list, tuple, ArrayType) – The time points which generate the spikes.

  • weights (bool, float, Sequence, or ArrayLike, default True) – Spike weights. True produces boolean output (backward-compatible). A float scalar applies the same weight to every spike. A sequence of the same length as indices/times assigns per-event weights. The output dtype is inferred from this parameter.

  • time_as_step (callable, str, default 'round') – Rounding method for converting spike times to integer step indices. Options: 'floor', 'round', 'ceil'.

  • name (str, optional) – The name of the dynamic system.

See also

PoissonSpike

Stochastic Poisson spike generator.

PoissonEncoder

Poisson encoder with dynamic rates.

Notes

  • Internally, a brainevent.CSR sparse matrix of shape (n_max_time_step, n_neuron) is pre-built at construction, so update() reduces to a single CSR row slice.

  • Only 1-D neuron groups are supported.

  • Spike times are converted to integer step indices using the rounding method specified by time_as_step.