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

    navis.subset_neuron¶

    navis.subset_neuron(x, subset, inplace=False, keep_disc_cn=False, prevent_fragments=False)[source]¶

    Subset a neuron to a given set of nodes/vertices.

    Note that for MeshNeurons it is not guaranteed that all vertices in subset survive because we will also drop degenerate vertices that do not participate in any faces.

    Parameters:
    • x (TreeNeuron | MeshNeuron | Dotprops) – Neuron to subset.

    • subset (list-like | set | NetworkX.Graph | pandas.DataFrame) –

      For TreeNeurons:
      • node IDs to subset the neuron to

      • a boolean mask

      • DataFrame with node_id column

      For MeshNeurons:
      • vertex indices

      • a boolean mask

      For Dotprops:
      • point indices

      • a boolean mask

    • keep_disc_cn (bool, optional) – If False, will remove disconnected connectors that have “lost” their parent node/vertex.

    • prevent_fragments (bool, optional) – If True, will add nodes/vertices to subset required to keep neuron from fragmenting. Ignored for Dotprops.

    • inplace (bool, optional) – If False, a copy of the neuron is returned.

    Return type:

    TreeNeuron | MeshNeuron

    Examples

    Subset skeleton to all branches with less than 10 nodes

    >>> import navis
    >>> # Get neuron
    >>> n = navis.example_neurons(1)
    >>> # Get all linear segments
    >>> segs = n.segments
    >>> # Get short segments
    >>> short_segs = [s for s in segs if len(s) <= 10]
    >>> # Flatten segments into list of nodes
    >>> nodes_to_keep = [n for s in short_segs for n in s]
    >>> # Subset neuron
    >>> n_short = navis.subset_neuron(n, nodes_to_keep)
    

    See also

    navis.cut_skeleton()

    Cut neuron at specific points.

    navis.in_volume()

    To intersect a neuron with a volume (mesh).

    Back to top

    Source

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