There is a newer version of the record available.

Published May 12, 2021 | Version v0.6.0
Software Open

schlegelp/navis: Version 0.6.0

  • 1. Dept. of Physiology, Development and Neuroscience, U.Cam
  • 2. Dept of Zoology, Cambridge
  • 3. @neurodata

Description

This new version comes with tons of goodies:

Multi-core processing as (almost) first-class citizen

Many functions now accept a parallel=True. If the input is a NeuronList, navis will then use multiple cores to run that function. You can use n_cores=some number (defaults to half the available cores) to set the number of cores used.

A toy example:

>>> nl = navis.example_neurons(4)
>>> pr = navis.prune_by_strahler(nl, to_prune=1, parallel=True)

To run generic (i.e. non-navis functions) in parallel you can use NeuronList.apply:

>>> nl = navis.example_neurons(4)
>>> nl.apply(lambda x: x.id, parallel=True)
[1734350788, 1734350908, 722817260, 754534424]

Note that this requires that you install pathos:

$ pip3 install pathos -U
Read and write SWC files directly from/to zip files
>>> nl = navis.example_neurons(4)
>>> # Write to zip
>>> navis.write_swc(nl, '~/Downloads/SWCs.zip')
>>> # Read from zip
>>> unzipped = navis.read_swc('~/Downloads/SWCs.zip')
Unit awareness

For a while now, navis neurons had an (optional) units property, and some downstream libraries (e.g. fafbseg and pymaid) make use of that:

>>> # Example neurons are in raw (i.e. voxel) hemibrain space
>>> n = navis.example_neurons(1)
>>> n.units
8 <Unit('nanometer')>

Under the hood, this is using a neat library called pint which also lets you convert between units. So you can do stuff like this:

>>> # Example neuron is in 8nm voxels (see above)
>>> n_vxl = navis.example_neurons(1)
>>> # Convert to microns
>>> n_um = n_vxl.convert_units('um')
>>> n_um.units
1.0 <Unit('micrometer')>

Likewise, many navis functions that work with spatial units now alternatively accept a "unit str" that can be parsed by pint. For example:

>>> n = navis.example_neurons(1)
>>> # Prune twigs smaller than 5 microns
>>> # (which would be 5 * 1000 / 8 = 625 in this neuron's space)
>>> n_pr = navis.prune_twigs(n, '5 microns')
New functions
  • navis.prune_at_depth: to prune at given distance from root
  • navis.read_rda: read nat neuron-data R data (.rda) - also works for basic stuff like dataframes
  • navis.cell_body_fiber: prune neuron down to its cell body fiber

For a complete list of changes, see the change log and the commit history.

Files

schlegelp/navis-v0.6.0.zip

Files (37.9 MB)

Name Size Download all
md5:9fbd05cee5452b45c764fe9e59209ca0
37.9 MB Preview Download

Additional details

Related works