navis.tortuosity¶
- navis.tortuosity(x, seg_length=10)[source]¶
Calculate tortuosity of a neuron.
See Stepanyants et al., Neuron (2004) for detailed explanation. Briefly, tortuosity index T is defined as the ratio of the branch segment length L (
seg_length
) to the Euclidian distance R between its ends.- The way this is implemented in navis:
Each linear stretch (i.e. between branch points or branch points to a leaf node) is divided into segments of exactly
seg_length
geodesic length. Any remainder is skipped.For each of these segments we divide its geodesic length L (i.e. seg_length) by the Euclidian distance R between its start and its end.
The final tortuosity is the mean of L / R across all segments.
Note
If you want to make sure that segments are as close to length L as possible, consider resampling the neuron using
navis.resample_skeleton()
.- Parameters:
x (TreeNeuron | MeshNeuron | NeuronList) – Neuron to analyze. If MeshNeuron, will generate and use a skeleton representation.
seg_length (int | float | str | list thereof, optional) – Target segment length(s) L. If neuron(s) have their
.units
set, you can also pass a string such as “1 micron”.seg_length
must be larger than the current sampling resolution of the neuron.
- Returns:
tortuosity – If x is NeuronList, will return DataFrame. If x is single TreeNeuron, will return either a single float (if single seg_length is queried) or a DataFrame (if multiple seg_lengths are queried).
- Return type:
float | np.array | pandas.DataFrame
See also
navis.segment_analysis()
This function provides by-segment morphometrics, including tortuosity.
Examples
>>> import navis >>> n = navis.example_neurons(1) >>> # Calculate tortuosity with 1 micron seg lengths >>> T = navis.tortuosity(n, seg_length='1 micron') >>> round(T, 3) 1.054