Version 0.6.0
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 rootnavis.read_rda
: read nat neuron-data R data (.rda
) - also works for basic stuff like dataframesnavis.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.