def dist_between(x, a, b):
""" Returns the geodesic distance between nodes in nanometers.
Parameters
----------
x : {CatmaidNeuron, CatmaidNeuronList}
Neuron containing the nodes
a, b : treenode IDs
Treenodes to check.
Returns
-------
int
distance in nm
See Also
--------
:func:`~pymaid.distal_to`
Check if a node A is distal to node B.
:func:`~pymaid.geodesic_matrix`
Get all-by-all geodesic distance matrix.
"""
if isinstance( x, core.CatmaidNeuronList ):
if len(x) == 1:
x = x[0]
else:
raise ValueError('Need a single CatmaidNeuron')
elif isinstance( x, core.CatmaidNeuron ):
pass
else:
raise ValueError('Unable to process data of type {0}'.format(type(x)))
try:
_ = int(a)
_ = int(b)
except:
raise ValueError('a, b need to be treenode IDs')
return int( nx.algorithms.shortest_path_length( g.to_undirected(as_view=True),
a, b,
weight='weight') )
评论列表
文章目录