Install the latest release:

$ pip install neurom


It is recommended that you install NeuroM into a virtualenv. See virtualenv setup for details on how to set that up.

Analyze, visualize, and check

The neurom module has various helper functions and command line applications to simplify loading neuron morphologies from files into neurom data structures and obtaining morphometrics, either from single or multiple neurons. The functionality described here is limited, but it is hoped that it will suffice for most analyses.

Extract morphometrics with neurom.features.get()

These are some of the properties can be obtained for a single neurite type or for all neurites regardless of type via neurom.features.get():

  • Segment lengths

  • Section lengths

  • Segment radii

  • Number of sections

  • Number of sections per neurite

  • Number of neurites

  • Number of segments

  • Local and remote bifurcation angles

  • Section path distances

  • Section radial distances

  • Section branch orders

  • Total neurite length

The usage is simple:

import neurom as nm
nrn = nm.load_neuron('some/data/path/morph_file0.swc')
nrn_ap_seg_len = nm.features.get('segment_lengths', nrn, neurite_type=nm.APICAL_DENDRITE)
pop = nm.load_neurons('some/data/path')
pop_ap_seg_len = nm.features.get('segment_lengths', pop, neurite_type=nm.APICAL_DENDRITE)

This function also allows obtaining the soma radius and surface area.

Iterate over neurites with neurom.core.neuron.iter_neurites()

neurom.core.neuron.iter_neurites() function allows to iterate over the neurites of a single neuron or a neuron population. It can also be applied to a single neurite or a list of neurites. It allows to optionally pass a function to be mapped onto each neurite, as well as a neurite filter function. In this example, we apply a simple user defined function to the apical dendrites in a population:

import neurom as nm

def user_func(neurite):
    print('Analysing neurite', neurite)
    return len(neurite.points)

stuff = [x for x in nm.iter_neurites(pop, user_func, lambda n : n.type == nm.APICAL_DENDRITE)]

View neurons with neurom.viewer

There are also helper functions to plot a neuron in 2 and 3 dimensions.

neurom.viewer.draw() function allows the user to make two and three-dimensional plots of neurites, somata and neurons. It also has a dendrogram neuron plotting mode.

Extract morphometrics into JSON files

The neurom stats application lets you obtain various morphometrics quantities from a set of morphology files. It is highly configurable, and gives access to all the features available via the neurom.features.get() function.

For example,

$ neurom stats some/path/morph.swc # single file

$ neurom stats some/path # all files in directory

Check data validity

The neurom check application applies some semantic checks to morphology data files in order to determine whether it is suitable to construct a neuron structure and whether certain defects within the structure are detected. It can be invoked from the command line, and takes as main argument the path to either a single file or a directory of morphology files.

For example,

$ neurom check some/path/morph.swc # single file
INFO: ========================================
INFO: File: test_data/swc/Neuron.swc
INFO:                      Is single tree PASS
INFO:                     Has soma points PASS
INFO:                  No missing parents PASS
INFO:                  Has sequential ids PASS
INFO:                  Has increasing ids PASS
INFO:                      Has valid soma PASS
INFO:                  Has valid neurites PASS
INFO:                  Has basal dendrite PASS
INFO:                            Has axon PASS
INFO:                 Has apical dendrite PASS
INFO:     Has all nonzero segment lengths PASS
INFO:     Has all nonzero section lengths PASS
INFO:       Has all nonzero neurite radii PASS
INFO:             Has nonzero soma radius PASS
INFO:                                 ALL PASS
INFO: ========================================

$ neurom check test_data/swc # all files in directory
# loops over all morphology files found in test_data/swc