navis.heal_skeleton¶
- navis.heal_skeleton(x, method='ALL', max_dist=None, min_size=None, drop_disc=False, mask=None, inplace=False)[source]¶
Heal fragmented skeleton(s).
Tries to heal a fragmented skeleton (i.e. a neuron with multiple roots) using a minimum spanning tree.
- Parameters:
x (TreeNeuron/List) – Fragmented skeleton(s).
method ('LEAFS' | 'ALL', optional) –
- Method used to heal fragments:
’LEAFS’: Only leaf (including root) nodes will be used to heal gaps. This can be much faster depending on the size of the neuron
’ALL’: All nodes can be used to reconnect fragments.
max_dist (float | str, optional) – This effectively sets the max length for newly added edges. Use it to prevent far away fragments to be forcefully connected. If the neurons have .units set, you can also pass a string such as e.g. “2 microns”.
min_size (int, optional) – Minimum size in nodes for fragments to be reattached. Fragments smaller than
min_size
will be ignored during stitching and hence remain disconnected.drop_disc (bool) – If True and the neuron remains fragmented after healing (i.e.
max_dist
ormin_size
prevented a full connect), we will keep only the largest (by number of nodes) connected component and discard all other fragments.mask (list-like, optional) – Either a boolean mask or a list of node IDs. If provided will only heal breaks between these nodes.
inplace (bool, optional) – If False, will perform healing on and return a copy.
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:
None – If
inplace=True
.CatmaidNeuron/List – If
inplace=False
.
See also
navis.stitch_skeletons()
Use to stitch multiple skeletons together.
navis.break_fragments()
Use to produce individual neurons from disconnected fragments.
Examples
>>> import navis >>> n = navis.example_neurons(1, kind='skeleton') >>> # Disconnect parts of the neuron >>> n.nodes.loc[100, 'parent_id'] = -1 >>> len(n.root) 2 >>> # Heal neuron >>> healed = navis.heal_skeleton(n) >>> len(healed.root) 1