jaxley.morphology.distance_pathwise#
- distance_pathwise(startpoint, endpoints)[source]#
Returns the pathwise distance between a root and other compartments.
We use Dijkstra’s algorithm to get the path with the lowest number of compartments between start and endpoint. It then computes the length of that path in micrometers. Note that, for an uncyclic graph, the path with the lowest number of compartments between start and endpoint is also the path with the lowest length.
- Parameters:
- Returns:
A list of distances.
- Return type:
Example usage#
Example 1: The following computes the pathwise distance between the zero-eth soma compartment and all other compartments. It then saves this distance in cell.nodes[“path_dist_from_soma”].
from jaxley.morphology import distance_pathwise path_dists = distance_pathwise(cell.soma.branch(0).comp(0), cell) cell.nodes["path_dist_from_soma"] = path_dists
Example 2: The following computes the pathwise distance between two compartments.
dist = distance_pathwise(cell.branch(8).comp(2), cell.branch(2).comp(0))