pymaid.remove_tagged_branches

pymaid.remove_tagged_branches(x, tag, how='segment', preserve_connectors=False, inplace=False)[source]

Removes branches with a given treenode tag (e.g. not a branch).

Parameters:
  • x (CatmaidNeuron | CatmaidNeuronList) – Neuron(s) to be processed.

  • tag (str) – Treeode tag to use.

  • how ('segment' | 'distal' | 'proximal', optional) –

    Method of removal:
    1. segment removes entire segment

    2. distal/proximal removes everything distal/proximal to tagged node(s), including that node.

  • preserve_connectors (bool, optional) – If True, connectors that got disconnected during branch removal will be reattached to the closest surviving downstream node.

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

Returns:

Pruned neuron(s). Only if inplace=False.

Return type:

CatmaidNeuron/List

Examples

  1. Remove not-a-branch terminal branches

>>> x = pymaid.get_neuron(16)
>>> x_prun = pymaid.remove_tagged_branches(x,
...                                        'not a branch',
...                                        how='segment',
...                                        preserve_connectors=True)
  1. Prune neuron to microtubule-containing backbone

>>> x_prun = pymaid.remove_tagged_branches(x,
...                                        'microtubule ends',
...                                        how='distal',
...                                        preserve_connectors=False)