neurom.io.utils

Utility functions and for loading neurons.

Functions

get_files_by_path

Get a file or set of files from a file path.

get_morph_files

Get a list of all morphology files in a directory.

load_data

Unpack data into a raw data wrapper.

load_neuron

Build section trees from an h5 or swc file.

load_neurons

Create a population object.

Classes

DataWrapper

Class holding a raw data block and section information.

FstNeuron

Class representing a neuron.

NeuronLoader

Caching morphology loader.

Population

Neuron Population Class.

Exceptions

NeuroMError

Base class for all NeuroM exceptions.

RawDataError

Exception class for raw data errors.

class neurom.io.utils.DataWrapper(data_block, fmt, sections=None)[source]

Bases: object

Class holding a raw data block and section information.

neurite_root_section_ids()[source]

Get the section IDs of the intitial neurite sections.

soma_points()[source]

Get the soma points.

class neurom.io.utils.FstNeuron(data_wrapper, name='Neuron')[source]

Bases: neurom.core._neuron.Neuron

Class representing a neuron.

transform(trans)[source]

Return a copy of this neuron with a 3D transformation applied.

exception neurom.io.utils.NeuroMError[source]

Bases: Exception

Base class for all NeuroM exceptions.

class neurom.io.utils.NeuronLoader(directory, file_ext=None, cache_size=None)[source]

Bases: object

Caching morphology loader.

Parameters
  • directory – path to directory with morphology files

  • file_ext – file extension to look for (if not set, will pick any of .swc|.h5|.asc)

  • cache_size – size of LRU cache (if not set, no caching done)

get(name)[source]

Get name morphology data.

class neurom.io.utils.Population(neurons, name='Population')[source]

Bases: object

Neuron Population Class.

Features:
  • flattened collection of neurites.

  • collection of somas, neurons.

  • iterable-like iteration over neurons.

exception neurom.io.utils.RawDataError[source]

Bases: neurom.exceptions.NeuroMError

Exception class for raw data errors.

neurom.io.utils.get_files_by_path(path)[source]

Get a file or set of files from a file path.

Return list of files with path

neurom.io.utils.get_morph_files(directory)[source]

Get a list of all morphology files in a directory.

Returns

list with all files with extensions ‘.swc’ , ‘h5’ or ‘.asc’ (case insensitive)

neurom.io.utils.load_data(handle, reader=None)[source]

Unpack data into a raw data wrapper.

neurom.io.utils.load_neuron(handle, reader=None)[source]

Build section trees from an h5 or swc file.

neurom.io.utils.load_neurons(neurons, neuron_loader=<function load_neuron>, name=None, population_class=<class 'neurom.core.population.Population'>, ignored_exceptions=())[source]

Create a population object.

From all morphologies in a directory of from morphologies in a list of file names.

Parameters
  • neurons – directory path or list of neuron file paths

  • neuron_loader – function taking a filename and returning a neuron

  • population_class – class representing populations

  • name (str) – optional name of population. By default ‘Population’ or filepath basename depending on whether neurons is list or directory path respectively.

Returns

neuron population object