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:
Python
>>> 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`:
Python
>>> 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:
bash
$ pip3 install pathos -U
Read and write SWC files directly from/to zip files
python
>>> 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:
python
>>> 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:
python
>>> 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