jaxley.connect.connectivity_matrix_connect

jaxley.connect.connectivity_matrix_connect#

connectivity_matrix_connect(pre_cell_view, post_cell_view, synapse_type, connectivity_matrix, random_post_comp=False)[source]#

Connect cells of a network with synapses via a boolean connectivity matrix.

Entries > 0 in the matrix indicate a connection between the corresponding cells. Connections are from branch 0 location 0 of the pre-synaptic cell to branch 0 location 0 of the post-synaptic cell unless random_post_comp=True.

Parameters:
  • pre_cell_view (View) – View of the presynaptic cell.

  • post_cell_view (View) – View of the postsynaptic cell.

  • synapse_type (Synapse) – The synapse to append.

  • connectivity_matrix (ndarray[bool]) – A boolean matrix indicating the connections between cells. If floating point values are passed, they are _not_ interpreted as synaptic weights, but we only check if they are zero (no connection) or not (connection).

  • random_post_comp (bool) – If True, randomly samples the postsynaptic compartments.

Example usage#

The following generates a random 10 x 10 boolean matrix and uses it to connect the neurons in a network.

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

net = jx.Network([cell for _ in range(10)])
connectivity_matrix = np.random.choice([False, True], size=(10, 10))
connectivity_matrix_connect(
    net.cell("all"),
    net.cell("all"),
    IonotropicSynapse(),
    connectivity_matrix,
)
print(net.edges)