navis.conversion.voxels2mesh¶
- navis.conversion.voxels2mesh(vox, spacing='auto', step_size=1, chunk_size='auto', pad_chunks=True, merge_fragments=True, progress=True)[source]¶
Generate mesh from voxels using marching cubes.
- Parameters:
voxels (VoxelNeuron | (N, 3) np.array) – Object to voxelize. Can be a VoxelNeuron or an (N, 3) array of x, y, z voxel coordinates.
spacing (np.array) – (3, ) array with x, y, z voxel size. If auto and input is a VoxelNeuron we will use the neuron’s .units property, else spacing will be (1, 1, 1).
step_size (int, optional) – Step size for marching cube algorithm. Higher values = faster but coarser.
chunk_size ("auto" | int, optional) –
Whether to process voxels in chunks to keep memory footprint low:
”auto” will set chunk size automatically based on size of input
use
int
to set chunk size - smaller chunk mean lower memory consumption but longer run time - 200 (i.e. chunks of 200x200x200 voxels) appears to be a good valueset to
0
to force processing in one go
0 (For chunk_size !=) –
pad_chunks (bool) – If True, will pad each chunk. This helps making meshes watertight but may introduce internal faces when merging mesh fragments.
merge_fragments (bool) – If True, will attempt to merge fragments at the chunk boundaries.
progress (bool) – Whether to show a progress bar.
- Returns:
mesh – Returns a trimesh or MeshNeuron depending on the input. Data tables (e.g. connectors) are not carried over from input neuron.
- Return type:
trimesh.Trimesh | MeshNeuron