pymaid.get_paths¶
- pymaid.get_paths(sources, targets, n_hops=2, min_synapses=1, return_graph=False, remove_isolated=False, remote_instance=None)[source]¶
Fetch paths between two sets of neurons.
- Parameters:
sources – Source neurons.
targets –
Target neurons.
sources
andtargets
can be:list of skeleton ID(s) (int or str)
list of neuron name(s) (str, exact match)
an annotation as e.g. ‘annotation:PN right’
CatmaidNeuron or CatmaidNeuronList object
n_hops (int | list | range, optional) –
Number of hops allowed between sources and targets. Direct connection would be 1 hop.
1. int, e.g.
n_hops=3
will return paths with EXACTLY 3 hops 2. list, e.g.n_hops=[2,4]
will return all paths with 2 and 4 hops 3. range, e.g.n_hops=range(2,4)
will be converted to a list and return paths with 2 and 3 hops.min_synapses (int, optional) – Minimum number of synpases between source and target.
return_graph (bool, optional) – If True, will return NetworkX Graph (see below).
remove_isolated (bool, optional) – Remove isolated nodes from NetworkX Graph. Only relevant if
return_graph=True
.remote_instance (CatmaidInstance, optional) – If not passed directly, will try using global.
- Returns:
paths (list) – List of skeleton IDs that constitute paths from sources to targets:
[[source1, ..., target1], [source2, ..., target2], ...]
networkx.DiGraph – Only if
return_graph=True
. Graph contains all neurons that connect sources and targets. Important: Does only contain edges that connect sources and targets via maxn_hops
! Other edges have been removed.
Examples
>>> # This assumes that you have already set up a CatmaidInstance >>> import networkx as nx >>> import matplotlib.pyplot as plt >>> g, paths = pymaid.get_paths(['annotation:glomerulus DA1'], ... ['2333007']) >>> g <networkx.classes.digraph.DiGraph at 0x127d12390> >>> paths [['57381', '4376732', '2333007'], ['57323', '630823', '2333007'], ... >>> nx.draw(g) >>> plt.show()