pymaid.prune_by_length

pymaid.prune_by_length(x, min_length=0, max_length=inf, inplace=False)[source]

Remove segments of given length.

This uses pymaid.graph_utils._generate_segments() to generate segments that maximize segment lengths.

Parameters:
  • x (CatmaidNeuron/List) –

  • min_length (int | float) – Twigs shorter than this length [um] will be pruned.

  • max_length (int | float) – Segments longer than this length [um] will be pruned.

  • inplace (bool, optional) – If False, pruning is performed on copy of original neuron which is then returned.

Returns:

Pruned neuron(s).

Return type:

CatmaidNeuron/List

See also

pymaid.longest_neurite()

If you want to keep/remove just the N longest neurites instead of using a length cut-off.

pymaid.prune_twigs()

Use if you are looking to remove only terminal branches of a given size.

Examples

>>> import pymaid
>>> n = pymaid.get_neurons(16)
>>> # Remove neurites longer than 100mirons
>>> n_pr = pymaid._prune_by_length(n,
...                                min_length=0,
...                                max_length=100,
...                                inplace=False)
>>> n.n_nodes > n_pr.n_nodes
True