Connection Management
From NEST
Connections in NEST
Different connection patterns can be constructed with the basic connection functions in NEST.
One-to-one connections
Connect(pre, post, params=None, delay=None, model='static_synapse'): Make one-to-one connections of type model between the nodes in pre and the nodes in post. pre and post have to be lists of the same length. If params is given (as dictionary or list of dictionaries), they are used as parameters for the connections. If params is given as a single float or as list of floats, it is used as weight(s), in which case delay also has to be given as float or as list of floats.
A = Create("iaf_neuron", 2)
B = Create("spike_detector", 2)
Connect(A, B)
Convergent connections
ConvergentConnect(pre, post, weight=None, delay=None, model='static_synapse'): Connect all neurons in pre to each neuron in post. pre and post have to be lists. If weight is given (as a single float or as list of floats), delay also has to be given as float or as list of floats.
A = Create("iaf_neuron", 2)
B = Create("spike_detector")
ConvergentConnect(A, B)
RandomConvergentConnect(pre, post, n, weight=None, delay=None, model='static_synapse'): Connect n randomly selected neurons from pre to each neuron in post. pre and post have to be lists. If weight is given (as a single float or as list of floats), delay also has to be given as float or as list of floats.
Divergent connections
DivergentConnect(pre, post, weight=None, delay=None, model='static_synapse'): Connect each neuron in pre to all neurons in post. pre and post have to be lists. If weight is given (as a single float or as list of floats), delay also has to be given as float or as list of floats.
A = Create("iaf_neuron")
B = Create("spike_detector", 2)
DivergentConnect(A, B)
RandomDivergentConnect(pre, post, n, weight=None, delay=None, model='static_synapse'): Connect each neuron in pre to n randomly selected neurons from post. pre and post have to be lists. If weight is given (as a single float or as list of floats), delay also has to be given as float or as list of floats.
Topological connections
If the connect functions above are not sufficient, the topology module provides more sophisticated functions. For example, it is possible to create receptive field structures and much more! See Topological Connections for more information.
Receptor types
Each connection in NEST targets a specific receptor type on the post-synaptic node. Receptor types are identified by integer numbers, the default receptor type is 0. The meaning of the receptor type depends on the model and is documented in the model documentation. To connect to a non-standard receptor type, the parameter receptor_type of the additional argument params is used in the call to the Connect command. To illustrate the concept of receptor types, we give an example using standard integrate-and-fire neurons as presynaptic nodes and a multi-compartment integrate-and-fire neuron (iaf_cond_alpha_mc) as post-synaptic node.
A1, A2, A3, A4 = Create("iaf_neuron", 4)
B = Create("iaf_cond_alpha_mc")
receptors = GetDefaults("iaf_cond_alpha_mc")["receptor_types"]
print receptors
{'soma_exc': 1,
'soma_inh': 2,
'soma_curr': 7,
'proximal_exc': 3
'proximal_inh': 4,
'proximal_curr': 8,
'distal_exc': 5,
'distal_inh': 6,
'distal_curr': 9,}
Connect([A1], B, params={"receptor_type": receptors["distal_inh"]})
Connect([A2], B, params={"receptor_type": receptors["proximal_inh"]})
Connect([A3], B, params={"receptor_type": receptors["proximal_exc"]})
Connect([A4], B, params={"receptor_type": receptors["soma_inh"]})
The code block above connects a standard integrate-and-fire neuron to a somatic excitatory receptor of a multi-compartment integrate-and-fire neuron model. The result is illustrated in the figure.
Synapse types
NEST supports multiple synapse types that are specified during connection setup. The default synapse type in NEST is static_synapse. Its weight does not change over time. To allow learning and plasticity, it is possible to use other synapse types that implement long-term or short-term plasticity. A list of available types is accessible via the command Models("synapses"). The output of this command (as of revision 8441) is shown below:
['cont_delay_synapse', 'static_synapse', 'static_synapse_hom_wd', 'stdp_pl_synapse_hom', 'stdp_synapse', 'stdp_synapse_hom', 'tsodyks_synapse']
All synapses store their parameters on a per-connection basis. An exception to this scheme are the homogeneous synapse types (identified by the suffix _hom), which only store weight and delay once for all synapses of a type. This means that these are the same for all connections. They can be used to save memory.
The default values of a synapse type can be inspected using the command GetDefaults(), which takes the name of the synapse as an argument, and modified with SetDefaults(), which takes the name of the synapse type and a parameter dictionary as arguments.
print GetDefaults("static_synapse")
{'delay': 1.0,
'max_delay': -inf,
'min_delay': inf,
'num_connections': 0,
'num_connectors': 0,
'receptor_type': 0,
'synapsemodel': 'static_synapse',
'weight': 1.0}
SetDefaults("static_synapse", {"weight": 2.5})
For the creation of custom synapse types from already existing synapse types, the command CopyModel is used. It has an optional argument params to directly customize it during the copy operation. Otherwise the defaults of the copied model are taken.
CopyModel("static_synapse", "inhibitory", {"weight": -2.5})
Connect(A, B, model="inhibitory")
Note: Not all nodes can be connected via all available synapse types. The events a synapse type is able to transmit is documented in the Transmits section of the model documentation.
Inspecting connections
FindConnections(source, target=None, synapse_type=None): Return an array of identifiers for connections that match the given parameters. Only source is mandatory and must be a list of one ore more nodes. If target and/or synapse_type is/are given, they must be single values, lists of length one or the same length as source.
The result of FindConnections can be given as an argument to the GetStatus function, which will then return a list with the parameters of the connections:
n1, n2 = Create("iaf_neuron", 2)
Connect([n1], [n2])
conn = FindConnections([n1])
print GetStatus(conn)
[{'synapse_type': 'static_synapse',
'target': 2,
'weight': 1.0,
'delay': 1.0,
'source': 1,
'receptor': 0}]
Modifying existing connections
To modify the connections of an existing connection, one also has to obtain handles to the connections with FindConnections() first. These can then be given as arguments to the SetStatus() functions:
n1, n2 = Create("iaf_neuron", 2)
Connect([n1], [n2])
conn = FindConnections([n1])
SetStatus(conn, ["weight": 2.0])
print GetStatus(conn)
[{'synapse_type': 'static_synapse',
'target': 2,
'weight': 2.0,
'delay': 1.0,
'source': 1,
'receptor': 0}]




