neurom.features

NeuroM, lightweight and fast.

Examples

Obtain some morphometrics >>> import neurom >>> from neurom import features >>> nrn = neurom.load_neuron(‘path/to/neuron’) >>> ap_seg_len = features.get(‘segment_lengths’, nrn, neurite_type=neurom.APICAL_DENDRITE) >>> ax_sec_len = features.get(‘section_lengths’, nrn, neurite_type=neurom.AXON)

Functions

feature

Feature decorator to automatically register the feature in the appropriate namespace.

get

Obtain a feature from a set of morphology objects.

register_neurite_feature

Register a feature to be applied to neurites.

class neurom.features.NeuriteType(value)[source]

Bases: enum.IntEnum

Type of neurite.

exception neurom.features.NeuroMError[source]

Bases: Exception

Base class for NeuroM errors.

neurom.features.deprecated(fun_name=None, msg='')[source]

Issue a deprecation warning for a function.

neurom.features.feature(shape, namespace=None, name=None)[source]

Feature decorator to automatically register the feature in the appropriate namespace.

Parameters
  • shape (tuple) – the expected shape of the feature values

  • namespace (string) – a namespace (must be ‘NEURITEFEATURES’ or ‘NEURONFEATURES’)

  • name (string) – name of the feature, used to access the feature via neurom.features.get().

neurom.features.get(feature_name, obj, **kwargs)[source]

Obtain a feature from a set of morphology objects.

Features can be either Neurite features or Neuron features. For the list of Neurite features see neurom.features.neuritefunc. For the list of Neuron features see neurom.features.neuronfunc.

Parameters
  • feature_name (string) – feature to extract

  • obj – a neuron, a neuron population or a neurite tree

  • kwargs – parameters to forward to underlying worker functions

Returns

features as a 1D, 2D or 3D numpy array.

neurom.features.iter_neurites(obj, mapfun=None, filt=None, neurite_order=<NeuriteIter.FileOrder: 1>)[source]

Iterator to a neurite, neuron or neuron population.

Applies optional neurite filter and mapping functions.

Parameters
  • obj – a neurite, neuron or neuron population.

  • mapfun – optional neurite mapping function.

  • filt – optional neurite filter function.

  • neurite_order (NeuriteIter) – order upon which neurites should be iterated - NeuriteIter.FileOrder: order of appearance in the file - NeuriteIter.NRN: NRN simulator order: soma -> axon -> basal -> apical

Examples

Get the number of points in each neurite in a neuron population

>>> from neurom.core.neuron import iter_neurites
>>> n_points = [n for n in iter_neurites(pop, lambda x : len(x.points))]

Get the number of points in each axon in a neuron population

>>> import neurom as nm
>>> from neurom.core.neuron import iter_neurites
>>> filter = lambda n : n.type == nm.AXON
>>> mapping = lambda n : len(n.points)
>>> n_points = [n for n in iter_neurites(pop, mapping, filter)]
neurom.features.register_neurite_feature(name, func)[source]

Register a feature to be applied to neurites.

Warning

This feature has been deprecated in 1.6.0

Parameters
  • name – name of the feature, used for access via get() function.

  • func – single parameter function of a neurite.

neurom.features.tree_type_checker(*ref)[source]

Tree type checker functor.

Parameters
  • *ref (NeuriteType|tuple) – Either a single NeuriteType or a variable list of them or a tuple

  • them. (of) –

Returns

Functor that takes a tree, and returns true if that tree matches any of NeuriteTypes in ref

Ex:
>>> import neurom
>>> from neurom.core.types import NeuriteType, tree_type_checker
>>> from neurom.core.neuron import Section
>>> nrn = neurom.load_neuron('path')
>>>
>>> tree_filter = tree_type_checker(NeuriteType.axon, NeuriteType.basal_dendrite)
>>> nrn.i_neurites(Section.ipreorder, tree_filter=tree_filter)
>>>
>>> tree_filter = tree_type_checker((NeuriteType.axon, NeuriteType.basal_dendrite))
>>> nrn.i_neurites(Section.ipreorder, tree_filter=tree_filter)