Voxel / Image Data

navis lets you import neurons from a variety of local and remote sources. In this tutorial you will learn how to load voxel data from local data and - failing that - construct them from scratch. For loading remote data (e.g. the MICrONS, neuromorpho, Virtual Fly Brain or Janelia hemibrain datasets), navis has dedicated interfaces. See the example gallery for tutorials on these.

Voxel data (e.g. from confocal scans) is represented by the navis.VoxelNeuron class. At this point, navis supports reading just a single file format directly: .nrrd files via navis.read_nrrd() and navis.write_nrrd().

import navis

For this example I downloaded one of Janelia’s Fly Light confocal stacks (link) and converted it to nrrd using ImageJ.

# Open one of the Janelia confocals (I converted this to nrrd using ImageJ)
vxl = navis.read_nrrd('~/Downloads/JRC_SS86025_JRC_SS86025-20211112_49_B6.nrrd')
vxl
type navis.VoxelNeuron
name JRC_SS86025_JRC_SS86025-20211112_49_B6
units [0.5189161 micrometer, 0.5189161 micrometer, 1...
shape (1210, 563, 364)
dtype >u2

If push comes to shove you can construct navis.VoxelNeuron either from a dense 3-dimensional matrix or from sparse 2-dimensional voxel data:

import numpy as np

# Create an empty 7x7x7 matrix
dense = np.zeros((7, 7, 7))
# Fill the center voxel
dense[4, 4, 4] = 1

# Create the neuron
vxl = navis.VoxelNeuron(dense)
vxl
type navis.VoxelNeuron
name None
units 1 dimensionless
shape (7, 7, 7)
dtype float64
# Create an array with sparse x/y/z voxel coordinates
sparse = np.array([[4, 4, 4],
                   [4, 4, 5]])

# Construct neuron
vxl = navis.VoxelNeuron(sparse)
vxl
type navis.VoxelNeuron
name None
units 1 dimensionless
shape (5, 5, 6)
dtype int64

Hopefully the above has given you some entry points on how to load your data. Please see the docstring of navis.VoxelNeuron for details.

Also note that all navis neurons can be stored to disk using pickle - see the pickling tutorial. See also the I/O API reference api_io>.

Keep in mind that you can convert one neuron type into another - for example by meshing VoxelNeurons (see Converting neuron types).