# SpikeGeneratorGroup class¶

(Shortest import: from brian2 import SpikeGeneratorGroup)

class brian2.input.spikegeneratorgroup.SpikeGeneratorGroup(N, indices, times, dt=None, clock=None, period=1e100*second, when='thresholds', order=0, sorted=False, name='spikegeneratorgroup*', codeobj_class=None)[source]

A group emitting spikes at given times.

Parameters: N : int The number of “neurons” in this group indices : array of integers The indices of the spiking cells times : Quantity The spike times for the cells given in indices. Has to have the same length as indices. period : Quantity, optional If this is specified, it will repeat spikes with this period. dt : Quantity, optional The time step to be used for the simulation. Cannot be combined with the clock argument. clock : Clock, optional The update clock to be used. If neither a clock, nor the dt argument is specified, the defaultclock will be used. when : str, optional When to run within a time step, defaults to the 'thresholds' slot. order : int, optional The priority of of this group for operations occurring at the same time step and in the same scheduling slot. Defaults to 0. sorted : bool, optional Whether the given indices and times are already sorted. Set to True if your events are already sorted (first by spike time, then by index), this can save significant time at construction if your arrays contain large numbers of spikes. Defaults to False.

Notes

• In a time step, SpikeGeneratorGroup emits all spikes that happened at $$t-dt < t_{spike} \leq t$$. This might lead to unexpected or missing spikes if you change the time step dt between runs.
• SpikeGeneratorGroup does not currently raise any warning if a neuron spikes more that once during a time step, but other code (e.g. for synaptic propagation) might assume that neurons only spike once per time step and will therefore not work properly.
• If sorted is set to True, the given arrays will not be copied (only affects runtime mode)..

Attributes

 _previous_dt Remember the dt we used the last time when we checked the spike bins _spikes_changed “Dirty flag” that will be set when spikes are changed after the spikes The spikes returned by the most recent thresholding operation.

Methods

 before_run(run_namespace) set_spikes(indices, times[, period, sorted]) Change the spikes that this group will generate.

Details

_previous_dt

Remember the dt we used the last time when we checked the spike bins to not repeat the work for multiple runs with the same dt

_spikes_changed

“Dirty flag” that will be set when spikes are changed after the before_run check

spikes

The spikes returned by the most recent thresholding operation.

before_run(run_namespace)[source]
set_spikes(indices, times, period=1e100*second, sorted=False)

Change the spikes that this group will generate.

This can be used to set the input for a second run of a model based on the output of a first run (if the input for the second run is already known before the first run, then all the information should simply be included in the initial SpikeGeneratorGroup initializer call, instead).

Parameters: indices : array of integers The indices of the spiking cells times : Quantity The spike times for the cells given in indices. Has to have the same length as indices. period : Quantity, optional If this is specified, it will repeat spikes with this period. sorted : bool, optional Whether the given indices and times are already sorted. Set to True if your events are already sorted (first by spike time, then by index), this can save significant time at construction if your arrays contain large numbers of spikes. Defaults to False.