navis.cut_skeleton¶
- navis.cut_skeleton(x, where, ret='both')[source]¶
Split skeleton at given point and returns two new neurons.
Split is performed between cut node and its parent node. The cut node itself will still be present in both resulting neurons.
- Parameters:
x (TreeNeuron | NeuronList) – Must be a single skeleton.
where (int | str | list) – Node ID(s) or tag(s) of the node(s) to cut. The edge that is cut is the one between this node and its parent. So cut node must not be a root node! Multiple cuts are performed in the order of
cut_node
. Fragments are ordered distal -> proximal.ret ('proximal' | 'distal' | 'both', optional) – Define which parts of the neuron to return. Use this to speed up processing when you need only parts of the neuron.
- Returns:
split – Fragments of the input neuron after cutting sorted such that distal parts come before proximal parts. For example, with a single cut you can expect to return a NeuronList containing two neurons: the first contains the part distal and the second the part proximal to the cut node.
The distal->proximal order of fragments is tried to be maintained for multiple cuts but this is not guaranteed.
- Return type:
Examples
Cut skeleton at a (somewhat random) branch point
>>> import navis >>> n = navis.example_neurons(1) >>> bp = n.nodes[n.nodes.type=='branch'].node_id.values >>> dist, prox = navis.cut_skeleton(n, bp[0])
Make cuts at multiple branch points
>>> import navis >>> n = navis.example_neurons(1) >>> bp = n.nodes[n.nodes.type=='branch'].node_id.values >>> splits = navis.cut_skeleton(n, bp[:10])
See also
navis.TreeNeuron.prune_distal_to()
navis.TreeNeuron.prune_proximal_to()
TreeNeuron/List
shorthands to this function.navis.subset_neuron()
Returns a neuron consisting of a subset of its nodes.