navis.read_precomputed¶
- navis.read_precomputed(f, datatype='auto', include_subdirs=False, fmt='{id}', info=True, limit=None, parallel='auto', **kwargs)[source]¶
Read skeletons and meshes from neuroglancer’s precomputed format.
Follows the formats specified here.
- Parameters:
f (filepath | folder | zip file | bytes) – Filename, folder or bytes. If folder, will import all files. If a
.zip
,.tar
or.tar.gz
file will read all files in the archive. See alsolimit
parameter.datatype ("auto" | "skeleton" | "mesh") – Which data type we expect to read from the files. If “auto”, we require a “info” file in the same directory as
f
.include_subdirs (bool, optional) – If True and
f
is a folder, will also search subdirectories for binary files.fmt (str) –
Formatter to specify what files to look for (when f is directory) and how they are parsed into neuron attributes. Some illustrative examples:
{name}
(default) uses the filename (minus the suffix) as the neuron’s name property{id}
(default) uses the filename as the neuron’s ID property{name,id}
uses the filename as the neuron’s name and ID properties{name}.{id}
splits the filename at a “.” and uses the first part as name and the second as ID{name,id:int}
same as above but converts into integer for the ID{name}_{myproperty}
splits the filename at “_” and uses the first part as name and as a generic “myproperty” property{name}_{}_{id}
splits the filename at “_” and uses the first part as name and the last as ID. The middle part is ignored.
Throws a ValueError if pattern can’t be found in filename. Ignored for DataFrames.
info (bool | str | dict) –
- An info file describing the data:
True
= will look for info file in base folderFalse
= do not use/look for info filestr
= filepath to info filedict
= already parsed info file
limit (int, optional) – If reading from a folder you can use this parameter to read only the first
limit
files. Useful if wanting to get a sample from a large library of skeletons/meshes.parallel ("auto" | bool | int) – Defaults to
auto
which means only use parallel processing if more than 200 files are imported. Spawning and joining processes causes overhead and is considerably slower for imports of small numbers of neurons. Integer will be interpreted as the number of cores (otherwise defaults toos.cpu_count() // 2
).**kwargs – Keyword arguments passed to the construction of the neurons. You can use this to e.g. set meta data such as
units
.
- Returns:
navis.MeshNeuron
navis.NeuronList
See also
navis.write_precomputed()
Export neurons/volumes to precomputed format.