navis.average_skeletons¶
- navis.average_skeletons(x, limit=10, base_neuron=None)[source]¶
Compute an average from a list of skeletons.
This is a very simple implementation which may give odd results if used on complex neurons. Works fine on e.g. backbones or tracts.
- Parameters:
x (NeuronList) – Neurons to be averaged.
limit (int | str) – Max distance for nearest neighbour search. If the neurons have .units set, you can also pass a string such as e.g. “2 microns”.
base_neuron (neuron id | TreeNeuron, optional) – Neuron to use as template for averaging. If not provided, the first neuron in the list is used as template!
- Return type:
Examples
>>> # Get a bunch of neurons >>> import navis >>> da2 = navis.example_neurons() >>> # Prune down to longest neurite >>> for n in da2: ... if n.has_soma: ... n.reroot(n.soma, inplace=True) >>> da2_pr = da2.prune_by_longest_neurite(inplace=False) >>> # Make average >>> da2_avg = navis.average_skeletons(da2_pr, limit=10e3) >>> # Plot >>> da2.plot3d() >>> da2_avg.plot3d()