The Synapses class was introduced in Brian version 1.4 and can be used to define everything around synaptic interactions. It can replace the Connection class but is much more flexible, in particular it allows to directly incorporate descriptions of synaptic plasticity. See section Synapses in the user manual for instructions how to use the class.
Set of synapses between two neuron groups
Initialised with arguments:
Methods
Returns the vector of values for state variable var, with length the number of synapses. The vector is an instance of class SynapticVariable.
Returns the synapse indexes correspond to i, which can be a tuple or a slice. If i is a tuple (m,n), m and n can be an integer, an array, a slice or a subgroup.
The following usages are also possible for a Synapses object S:
Attributes:
Internal attributes:
Equations for the Synapses class. The only difference with Equations is that differential equations can be marked for an event-driven implementation, e.g.:
dx/dt=-x/tau : 1 (event-driven)
A vector of synaptic variables that is returned by Synapses.__getattr__(), and that can be subscripted with 2 or 3 arguments.
Example usages, where S is Synapses object:
Indexes can be integers, slices, arrays or groups.
Synaptic variables can be assigned values as follows:
Initialised with arguments:
Returns the wanted state as a matrix of shape (# presynaptic neurons, # postsynaptic neurons) for visualization purposes. The returned array value at [i,j] is the value of the wanted synaptic variable for the synapse between (i, j). If not synapse exists between those two neurons, then the value is np.nan.
Outputting a 2D matrix is not generally possible, because multiple synapses can exist for a given pair or pre- and post-synaptic neurons. In this case, the state values for all the synapses between neurons i and j are aggregated in the (i, j) position of the matrix. This is done according to the multiple_synapses keyword argument which can be changed:
mutiple_synapses = 'last' (default) takes the last value
mutiple_synapses = 'first' takes the first value
mutiple_synapses = 'min' takes the min of the values
mutiple_synapses = 'max' takes the max of the values
mutiple_synapses = 'sum' takes the sum of the values
Please note that this function should be used for visualization, and should not be used to store or reload synaptic variable values. If you want to do so, refer to the documentation at Synapses.save_connectivity().
A synaptic variable that is a delay. The main difference with SynapticVariable is that delays are stored as integers (timebins) but accessed as absolute times (in seconds).
TODO: pass the clock as argument.
Spike queue
Initialised with arguments:
Data structure
A spike queue is implemented as a 2D array X that is circular in the time direction (rows) and dynamic in the events direction (columns). The row index corresponding to the current timestep is currentime. Each element contains the target synapse index.
The class is implemented as a SpikeMonitor, so that the propagate() method is called at each timestep (of the monitored group).
Methods
Advances by one timestep.
Returns the all the synaptic events corresponding to the current time, as an array of synapse indexes.
Precompute all offsets corresponding to delays. This assumes that delays will not change during the simulation. If they do (between two runs for example), then this method can be called.
Offsets
Offsets are used to solve the problem of inserting multiple synaptic events with the same delay. This is difficult to vectorise. If there are n synaptic events with the same delay, these events are given an offset between 0 and n-1, corresponding to their relative position in the data structure. They can be either precalculated (faster), or determined at run time (saves memory). Note that if they are determined at run time, then it is possible to also vectorise over presynaptic spikes.