jaxley.connect.connect

Navigation

jaxley.connect.connect#

connect(pre, post, synapse_type)[source]#

Connect specific compartments of a network with a synapse.

The pre- and postsynaptic compartments must be compartments of the same network. If pre and post are both just a single compartment, then this function instantiates a single synapse. If pre and post are both N compartments, then this function instatiates N synapses (first-to-first, second-to-second,…).

Parameters:
  • pre (View) – View of the presynaptic compartment.

  • post (View) – View of the postsynaptic compartment.

  • synapse_type (Synapse) – The type of synapse to use.

Example usage#

Example 1: Connect one compartment to another compartment with a single synapse:

from jaxley.connect import connect
from jaxley.synapses import IonotropicSynapse

net = jx.Network([cell for _ in range(10)])
connect(
    net.cell(0).branch(0).comp(0),
    net.cell(1).branch(0).comp(0),
    IonotropicSynapse(),
)
print(net.edges)

Example 2: Connect N compartments to N other compartments with N synapses:

from jaxley.connect import connect
from jaxley.synapses import IonotropicSynapse

net = jx.Network([cell for _ in range(10)])
connect(
    net.cell(0).branch([0, 1]).comp(0),
    net.cell(1).branch([2, 3]).comp(0),
    IonotropicSynapse(),
)
print(net.edges)

Troubleshooting#

For large networks, using connect() might take a long time when selecting a large amount of cells at once. When encountering this problem, one can connect the network using functions not in the public Jaxley API.

Below, we connect the first half of all compartments in a network to the second half. Notice two things: First, we used the pandas function .loc on .nodes directly, which is faster than the Jaxley method select (because select builds a View of the net). We then use _append_multiple_synapses instead of connect to connect the synapses, since connect only accepts View as input.

cell = jx.Cell()
net = jx.Network([cell for _ in range(N)])

pre_nodes = net.nodes.loc[range(N // 2)]
post_nodes = net.nodes.loc[range(N//2, N)]

net._append_multiple_synapses(pre_nodes, post_nodes, IonotropicSynapse())