Standard Groups

Some standard types of NeuronGroup have already been defined. PoissonGroup and PoissonInput to generate spikes with Poisson statistics, PulsePacket to generate pulse packets with specified parameters, and SpikeGeneratorGroup to generate spikes which fire at prespecified times.

class brian.PoissonGroup(N, rates=0.0 * hertz, clock=None)

A group that generates independent Poisson spike trains.

Initialised as:

PoissonGroup(N,rates[,clock])

with arguments:

N
The number of neurons in the group
rates
A scalar, array or function returning a scalar or array. The array should have the same length as the number of neurons in the group. The function should take one argument t the current simulation time.
clock
The clock which the group will update with, do not specify to use the default clock.
class brian.PoissonInput(target, N=None, rate=None, weight=None, state=None, jitter=None, reliability=None, copies=1, record=False, freeze=False)

Adds a Poisson input to a NeuronGroup. Allows to efficiently simulate a large number of independent Poisson inputs to a NeuronGroup variable, without simulating every synapse individually. The synaptic events are generated randomly during the simulation and are not preloaded and stored in memory (unless record=True is used). All the inputs must target the same variable, have the same frequency and same synaptic weight. You can use as many PoissonInput objects as you want, even targetting a same NeuronGroup. There is the possibility to consider time jitter in the presynaptic spikes, and synaptic unreliability. The inputs can also be recorded if needed. Finally, all neurons from the NeuronGroup receive independent realizations of Poisson spike trains, except if the keyword freeze=True is used, in which case all neurons receive the same Poisson input.

Initialised as:

PoissonInput(target[, N][, rate][, weight][, state][, jitter][, reliability][, copies][, record][, freeze])

with arguments:

target
The target NeuronGroup
N
The number of independent Poisson inputs
rate
The rate of each Poisson process
weight
The synaptic weight
state
The name or the index of the synaptic variable of the NeuronGroup
jitter
is None by default. There is the possibility to consider copies presynaptic spikes at each Poisson event, randomly shifted according to an exponential law with parameter jitter=taujitter (in second).
reliability
is None by default. There is the possibility to consider copies presynaptic spikes at each Poisson event, where each of these spikes is unreliable, i.e. it occurs with probability jitter=alpha (between 0 and 1).
copies
The number of copies of each Poisson event. This is identical to weight=copies*w, except if jitter or reliability are specified.
record
True if the input has to be recorded. In this case, the recorded events are stored in the recorded_events attribute, as a list of pairs (i,t) where i is the neuron index and t is the event time.
freeze
True if the input must be the same for all neurons of the NeuronGroup
class brian.PulsePacket(t, n, sigma, clock=None)

Fires a Gaussian distributed packet of n spikes with given spread

Initialised as:

PulsePacket(t,n,sigma[,clock])

with arguments:

t
The mean firing time
n
The number of spikes in the packet
sigma
The standard deviation of the firing times.
clock
The clock to use (omit to use default or local clock)

Methods

This class is derived from SpikeGeneratorGroup and has all its methods as well as one additional method:

generate(t, n, sigma)

Change the parameters and/or generate a new pulse packet.

class brian.SpikeGeneratorGroup(N, spiketimes, clock=None, period=None, sort=True, gather=None)

Emits spikes at given times

Initialised as:

SpikeGeneratorGroup(N,spiketimes[,clock[,period]])

with arguments:

N
The number of neurons in the group.
spiketimes
An object specifying which neurons should fire and when. It can be a container such as a list, containing tuples (i,t) meaning neuron i fires at time t, or a callable object which returns such a container (which allows you to use generator objects even though this is slower, see below). i can be an integer or an array (list of neurons that spike at the same time). If spiketimes is not a list or tuple, the pairs (i,t) need to be sorted in time. You can also pass a numpy array spiketimes where the first column of the array is the neuron indices, and the second column is the times in seconds. Alternatively you can pass a tuple with two arrays, the first one being the neuron indices and the second one times. WARNING: units are not checked in this case, the time array should be in seconds.
clock
An optional clock to update with (omit to use the default clock).
period
Optionally makes the spikes recur periodically with the given period. Note that iterator objects cannot be used as the spikelist with a period as they cannot be reinitialised.
gather=False
Set to True if you want to gather spike events that fall in the same timestep. (Deprecated since Brian 1.3.1)
sort=True
Set to False if your spike events are already sorted.

Has an attribute:

spiketimes
This can be used to reset the list of spike times, however the values of N, clock and period cannot be changed.

Sample usages

The simplest usage would be a list of pairs (i,t):

spiketimes = [(0,1*ms), (1,2*ms)]
SpikeGeneratorGroup(N,spiketimes)

A more complicated example would be to pass a generator:

import random
def nextspike():
    nexttime = random.uniform(0*ms,10*ms)
    while True:
        yield (random.randint(0,9),nexttime)
        nexttime = nexttime + random.uniform(0*ms,10*ms)
P = SpikeGeneratorGroup(10,nextspike())

This would give a neuron group P with 10 neurons, where a random one of the neurons fires at an average rate of one every 5ms. Please note that as of 1.3.1, this behavior is preserved but will run slower than initializing with arrays, or lists.

Notes

Note that if a neuron fires more than one spike in a given interval dt, additional spikes will be discarded. A warning will be issued if this is detected.

Also, if you want to use a SpikeGeneratorGroup with many spikes and/or neurons, please use an initialization with arrays.

Also note that if you pass a generator, then reinitialising the group will not have the expected effect because a generator object cannot be reinitialised. Instead, you should pass a callable object which returns a generator. In the example above, that would be done by calling:

P = SpikeGeneratorGroup(10,nextspike)

Whenever P is reinitialised, it will call nextspike() to create the required spike container.

class brian.MultipleSpikeGeneratorGroup(spiketimes, clock=None, period=None)

Emits spikes at given times

Warning

This function has been deprecated after Brian 1.3.1 and will be removed in a future release. Use SpikeGeneratorGroup instead. To convert spiketimes for MultipleSpikeGeneratorGroup into a form suitable for SpikeGeneratorGroup, do:

N = len(spiketimes)
spiketimes = [(i, t) for i in xrange(N) for t in spiketimes[i]]

Initialised as:

MultipleSpikeGeneratorGroup(spiketimes[,clock[,period]])

with arguments:

spiketimes
a list of spike time containers, one for each neuron in the group, although note that elements of spiketimes can also be callable objects which return spike time containers if you want to be able to reinitialise (see below). At it’s simplest, spiketimes could be a list of lists, where spiketimes[0] contains the firing times for neuron 0, spiketimes[1] for neuron 1, etc. But, any iterable object can be passed, so spiketimes[0] could be a generator for example. Each spike time container should be sorted in time. If the containers are numpy arrays units will not be checked (times should be in seconds).
clock
A clock, if omitted the default clock will be used.
period
Optionally makes the spikes recur periodically with the given period. Note that iterator objects cannot be used as the spikelist with a period as they cannot be reinitialised.

Note that if two or more spike times fall within the same dt, spikes will stack up and come out one per dt until the stack is exhausted. A warning will be generated if this happens.

Also note that if you pass a generator, then reinitialising the group will not have the expected effect because a generator object cannot be reinitialised. Instead, you should pass a callable object which returns a generator, this will be called each time the object is reinitialised by calling the reinit() method.

Sample usage:

spiketimes = [[1*msecond, 2*msecond]]
P = MultipleSpikeGeneratorGroup(spiketimes)