navis.prune_by_strahler¶
- navis.prune_by_strahler(x, to_prune, inplace=False, reroot_soma=True, force_strahler_update=False, relocate_connectors=False)[source]¶
Prune neuron based on Strahler order.
- Parameters:
x (TreeNeuron | MeshNeuron | NeuronList) – Neuron(s) to prune.
to_prune (int | list | range | slice) –
- Strahler indices (SI) to prune. For example:
to_prune=1
removes all leaf branchesto_prune=[1, 2]
removes SI 1 and 2to_prune=range(1, 4)
removes SI 1, 2 and 3to_prune=slice(0, -1)
removes everything but the highest SIto_prune=slice(-1, None)
removes only the highest SI
reroot_soma (bool, optional) – If True, neuron will be rerooted to its soma.
inplace (bool, optional) – If False, pruning is performed on copy of original neuron which is then returned.
force_strahler_update (bool, optional) – If True, will force update of Strahler order even if already exists in node table.
relocate_connectors (bool, optional) – If True, connectors on removed nodes will be reconnected to the closest still existing node. Works only in child->parent direction.
parallel (bool) – If True and input is NeuronList, use parallel processing. Requires pathos.
n_cores (int, optional) – Numbers of cores to use if
parallel=True
. Defaults to half the available cores.progress (bool) – Whether to show a progress bar. Overruled by
navis.set_pbars
.omit_failures (bool) – If True will omit failures instead of raising an exception. Ignored if input is single neuron.
- Returns:
Pruned neuron(s).
- Return type:
TreeNeuron/List
Examples
>>> import navis >>> n = navis.example_neurons(1) >>> n_pr = navis.prune_by_strahler(n, to_prune=1, inplace=False) >>> n.n_nodes > n_pr.n_nodes True