pymaid.adjacency_from_connectors¶
- pymaid.adjacency_from_connectors(source, target=None, remote_instance=None)[source]¶
Regenerate adjacency matrices from neurons’ connectors.
Notes
This function creates an adjacency matrix from scratch using just the neurons’ connectors. This function is able to deal with non-unique skeleton IDs (most other functions are not). Use it e.g. when you split neurons into multiple fragments.
- Parameters:
source (skeleton IDs | CatmaidNeuron | CatmaidNeuronList) – Neuron(s) for which to generate adjacency matrix. If
target==None
, will usetarget=source
.target (skeleton IDs | CatmaidNeuron | CatmaidNeuronList) – Neuron(s) for which to generate adjacency matrix. If
target==None
, will usetarget=source
.remote_instance (CatmaidInstance, optional) – If not passed, will try using globally defined.
- Returns:
Matrix holding possible synaptic contacts. Sources are rows, targets are columns. Labels are skeleton IDs. Order is preserved:
target1 target2 target3 ... source1 5 1 0 source2 10 20 5 source3 4 3 15 ...
- Return type:
pandas.DataFrame
See also
adjacency_matrix()
If you are working with “intact” neurons. Much faster!
filter_connectivity()
Use this function if you have only a single fragment per neuron (e.g. just the axon). Also way faster.
Examples
>>> # Fetch some neurons >>> x = pymaid.get_neuron('annotation:PD2a1/b1') >>> # Split into axon / dendrites >>> x.reroot(x.soma) >>> split = pymaid.split_axon_dendrite(x) >>> # Regenerate all-by-all adjacency matrix >>> adj = pymaid.adjacency_from_connectors(split) >>> # Skeleton IDs are non-unique but column/row order = input order: >>> # in this example, the first occurrence is axon, the second dendrites >>> adj.head()