jaxley.morphology.distance_pathwise

Navigation

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:
  • startpoint (View) – A single compartment from which to compute the distance.

  • endpoints (Branch | Cell | View) – One or multiple compartments to which to compute the distance to.

Returns:

A list of distances.

Return type:

List[float]

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))