navis.skeletonize¶
- navis.skeletonize(x, **kwargs)[source]¶
Turn neuron into skeleton.
Currently, we can only skeletonize meshes, dotprops and point clouds but are looking into ways to also do it for
VoxelNeurons
.For meshes, this function is a thin-wrapper for skeletor. It uses sensible defaults for neurons but if you want to fine-tune your skeletons you should look into using skeletor directly.
- Parameters:
x (MeshNeuron | trimesh.Trimesh | Dotprops) – Mesh(es) to skeletonize. Note that the quality of the results very much depends on the mesh, so it might be worth doing some pre-processing (see below).
**kwargs –
Keyword arguments are passed through to the respective converters:
meshes:
navis.conversion.mesh2skeleton()
dotprops and point clouds:
navis.conversion.points2skeleton()
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:
skeleton – For meshes, this has a .vertex_map attribute that maps each vertex in the input mesh to a skeleton node ID.
- Return type:
See also
navis.drop_fluff()
Use this if your mesh has lots of tiny free floating bits to reduce noise and speed up skeletonization.
Examples
# Skeletonize a mesh >>> import navis >>> # Get a mesh neuron >>> n = navis.example_neurons(1, kind=’mesh’) >>> # Convert to skeleton >>> sk = navis.skeletonize(n) >>> # Mesh vertex indices to node IDs map >>> sk.vertex_map # doctest: +SKIP array([938, 990, 990, …, 39, 234, 234])
# Skeletonize dotprops (i.e. point-clouds) >>> import navis >>> # Get a skeleton and turn into dotprops >>> dp = navis.make_dotprops(navis.example_neurons(1)) >>> # Turn back into a skeleton >>> sk = navis.skeletonize(dp)