Standard Groups
Some standard types of NeuronGroup have already been defined.
PoissonGroup to generate spikes with Poisson statistics,
PulsePacket to generate pulse packets with specified parameters,
SpikeGeneratorGroup and MultipleSpikeGeneratorGroup to
generate spikes which fire at prespecified times.
-
class brian.PoissonGroup(N, rates=0.0 Hz, 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.PulsePacket(*args, **kwds)
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, gather=False, sort=True)
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, 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. WARNING: units are not checked in this case, and you need to
ensure that the spikes are sorted.
- 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 (makes the simulation faster if you have many events).
- 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.
Notes
Note that if a neuron fires more than one spike in a given interval dt, additional
spikes will be discarded. If you want them to stack, consider using the less efficient
MultipleSpikeGeneratorGroup object instead. A warning will be issued if this
is detected.
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
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)