navis 1.4.0
  • Install
  • Quickstart
  • Tutorials
  • API
  • Changelog
  • Github
  • Ecosystem
  • Site
    • Page
        • navis.geodesic_matrix
          • geodesic_matrix()

    navis.geodesic_matrix¶

    navis.geodesic_matrix(x, from_=None, directed=False, weight='weight', limit=inf)[source]¶

    Generate geodesic (“along-the-arbor”) distance matrix between nodes/vertices.

    Parameters:
    • x (TreeNeuron | MeshNeuron | NeuronList) – If list, must contain a SINGLE neuron.

    • from (list | numpy.ndarray, optional) – Node IDs (for TreeNeurons) or vertex indices (for MeshNeurons). If provided, will compute distances only FROM this subset to all other nodes/vertices.

    • directed (bool, optional) – If True, pairs without a child->parent path will be returned with distance = "inf". Only relevant for TreeNeurons.

    • weight ('weight' | None, optional) – If weight distances are given as physical length. If None distances is number of nodes.

    • limit (int | float, optional) – Use to limit distance calculations. Nodes that are not within limit will have distance np.inf. If neuron has its .units set, you can also pass a string such as “10 microns”.

    Returns:

    Geodesic distance matrix. Distances in nanometres.

    Return type:

    pd.DataFrame

    See also

    navis.distal_to()

    Check if a node A is distal to node B.

    navis.dist_between()

    Get point-to-point geodesic distances.

    navis.dist_to_root()

    Distances from all skeleton node to their root(s).

    Examples

    Find average geodesic distance between all leaf nodes

    >>> import navis
    >>> n = navis.example_neurons(1)
    >>> # Generate distance matrix
    >>> m = navis.geodesic_matrix(n)
    >>> # Subset matrix to leaf nodes
    >>> leafs = n.nodes[n.nodes.type=='end'].node_id.values
    >>> l_dist = m.loc[leafs, leafs]
    >>> # Get mean
    >>> round(l_dist.mean().mean())
    12983
    

    Back to top

    Source

    © Copyright 2018, Philipp Schlegel.
    Created using Sphinx 5.3.0.