neurom.features.neuritefunc

Neurite features.

Any public function from this namespace can be called via features mechanism on a neurite, a collection of neurites, a neuron, a neuron population:

>>> import neurom
>>> from neurom import features
>>> nrn = neurom.load_neuron('path/to/neuron')
>>> features.get('max_radial_distance', nrn.neurites)
>>> features.get('n_segments', nrn.neurites, neurite_type=neurom.AXON)

Functions

bifurcation_partitions

Partition at bifurcation points of a collection of neurites.

diameter_power_relations

Calculate the diameter power relation at a bifurcation point.

local_bifurcation_angles

Get a list of local bifurcation angles in a collection of neurites.

map_segments

Map func to all the segments in a collection of neurites.

max_radial_distance

Get the maximum radial distances of the termination sections for a collection of neurites.

max_radial_distances

Get the maximum radial distances of the termination sections for a collection of neurites.

n_bifurcation_points

Number of bifurcation points in a collection of neurites.

n_forking_points

Number of forking points in a collection of neurites.

n_leaves

Number of leaves points in a collection of neurites.

n_neurites

Number of neurites in a collection of neurites.

n_sections

Number of sections in a collection of neurites.

n_segments

Number of segments in a collection of neurites.

neurite_lengths

Get the path length per neurite in a collection.

neurite_volume_density

Get the volume density per neurite.

number_of_bifurcations

Number of bifurcation points in a collection of neurites.

number_of_forking_points

Number of forking points in a collection of neurites.

number_of_neurites

Number of neurites in a collection of neurites.

number_of_sections

Number of sections in a collection of neurites.

number_of_sections_per_neurite

Get the number of sections per neurite in a collection of neurites.

number_of_segments

Number of sections in a collection of neurites.

number_of_terminations

Number of leaves points in a collection of neurites.

partition_asymmetries

Partition asymmetry at bifurcation points of a collection of neurites.

partition_pairs

Partition pairs at bifurcation points of a collection of neurites.

principal_direction_extents

Principal direction extent of neurites in neurons.

remote_bifurcation_angles

Get a list of remote bifurcation angles in a collection of neurites.

section_areas

Section areas in a collection of neurites.

section_bif_branch_orders

Bifurcation section branch orders in a collection of neurites.

section_bif_lengths

Bifurcation section lengths in a collection of neurites.

section_bif_radial_distances

Get the radial distances of the bifurcation sections for a collection of neurites.

section_branch_orders

Section branch orders in a collection of neurites.

section_end_distances

Section end to end distances in a collection of neurites.

section_lengths

Section lengths in a collection of neurites.

section_path_lengths

Path lengths of a collection of neurites.

section_radial_distances

Section radial distances in a collection of neurites.

section_strahler_orders

Inter-segment opening angles in a section.

section_taper_rates

Diameter taper rates of the sections in a collection of neurites from root to tip.

section_term_branch_orders

Termination section branch orders in a collection of neurites.

section_term_lengths

Termination section lengths in a collection of neurites.

section_term_radial_distances

Get the radial distances of the termination sections for a collection of neurites.

section_tortuosity

Section tortuosities in a collection of neurites.

section_volumes

Section volumes in a collection of neurites.

segment_areas

Areas of the segments in a collection of neurites.

segment_lengths

Lengths of the segments in a collection of neurites.

segment_meander_angles

Inter-segment opening angles in a section.

segment_midpoints

Return a list of segment mid-points in a collection of neurites.

segment_path_lengths

Returns pathlengths between all non-root points and their root point.

segment_radial_distances

Returns the list of distances between all segment mid points and origin.

segment_radii

Arithmetic mean of the radii of the points in segments in a collection of neurites.

segment_taper_rates

Diameters taper rates of the segments in a collection of neurites.

segment_volumes

Volumes of the segments in a collection of neurites.

sibling_ratios

Sibling ratios at bifurcation points of a collection of neurites.

terminal_path_lengths_per_neurite

Get the path lengths to each terminal point per neurite in a collection.

total_area_per_neurite

Surface area in a collection of neurites.

total_length_per_neurite

Get the path length per neurite in a collection.

total_volume_per_neurite

Get the volume per neurite in a collection.

class neurom.features.neuritefunc.COLS[source]

Bases: object

Column labels for internal data representation.

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

Bases: enum.IntEnum

Type of neurite.

class neurom.features.neuritefunc.Section(morphio_section)[source]

Bases: object

Simple recursive tree class.

The section constructor.

append_section(section)[source]

Appends a section to the current section object.

Parameters

section (morphio.Section|morphio.mut.Section|Section|morphio.PointLevel) – a section

ibifurcation_point(iter_mode=<function Section.ipreorder>)[source]

Iterator to bifurcation points.

Parameters

iter_mode – iteration mode. Default: ipreorder.

iforking_point(iter_mode=<function Section.ipreorder>)[source]

Iterator to forking points.

Parameters

iter_mode – iteration mode. Default: ipreorder.

ileaf()[source]

Iterator to all leaves of a tree.

ipostorder()[source]

Depth-first post-order iteration of tree nodes.

ipreorder()[source]

Depth-first pre-order iteration of tree nodes.

is_bifurcation_point()[source]

Is tree a bifurcation point?

is_forking_point()[source]

Is this section a forking point?

is_leaf()[source]

Is tree a leaf?

is_root()[source]

Is tree the root node?

iupstream()[source]

Iterate from a tree node to the root nodes.

neurom.features.neuritefunc.bifurcation_partitions(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Partition at bifurcation points of a collection of neurites.

neurom.features.neuritefunc.convex_hull(obj)[source]

Get the convex hull of an object containing points.

Returns

scipy.spatial.ConvexHull object built from obj.points

neurom.features.neuritefunc.diameter_power_relations(neurites, neurite_type=<NeuriteType.all: 32>, method='first')[source]

Calculate the diameter power relation at a bifurcation point.

Diameter power relation is defined in https://www.ncbi.nlm.nih.gov/pubmed/18568015

This quantity gives an indication of how far the branching is from the Rall ratio (when =1).

neurom.features.neuritefunc.interval_lengths(points, prepend_zero=False)[source]

Returns the list of distances between consecutive points.

Parameters
  • points – a list of np.array of 3D points

  • prepend_zero (bool) – if True, the returned array will start with a zero

neurom.features.neuritefunc.is_type(*ref)

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)
neurom.features.neuritefunc.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.neuritefunc.iter_sections(neurites, iterator_type=<function Section.ipreorder>, neurite_filter=None, neurite_order=<NeuriteIter.FileOrder: 1>)[source]

Iterator to the sections in a neurite, neuron or neuron population.

Parameters
  • neurites – neuron, population, neurite, or iterable containing neurite objects

  • iterator_type – section iteration order within a given neurite. Must be one of: Section.ipreorder: Depth-first pre-order iteration of tree nodes Section.ipostorder: Depth-first post-order iteration of tree nodes Section.iupstream: Iterate from a tree node to the root nodes Section.ibifurcation_point: Iterator to bifurcation points Section.ileaf: Iterator to all leaves of a tree

  • neurite_filter – optional top level filter on properties of neurite neurite objects.

  • 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 section of all the axons in a neuron population

>>> import neurom as nm
>>> from neurom.core.neuron import iter_sections
>>> filter = lambda n : n.type == nm.AXON
>>> n_points = [len(s.points) for s in iter_sections(pop,  neurite_filter=filter)]
neurom.features.neuritefunc.iter_segments(obj, neurite_filter=None, neurite_order=<NeuriteIter.FileOrder: 1>)[source]

Return an iterator to the segments in a collection of neurites.

Parameters
  • obj – neuron, population, neurite, section, or iterable containing neurite objects

  • neurite_filter – optional top level filter on properties of neurite neurite objects

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

Note

This is a convenience function provided for generic access to neuron segments. It may have a performance overhead WRT custom-made segment analysis functions that leverage numpy and section-wise iteration.

neurom.features.neuritefunc.local_bifurcation_angles(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get a list of local bifurcation angles in a collection of neurites.

neurom.features.neuritefunc.map_segments(func, neurites, neurite_type)[source]

Map func to all the segments in a collection of neurites.

func accepts a section and returns list of values corresponding to each segment.

neurom.features.neuritefunc.max_radial_distance(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get the maximum radial distances of the termination sections for a collection of neurites.

neurom.features.neuritefunc.max_radial_distances(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get the maximum radial distances of the termination sections for a collection of neurites.

neurom.features.neuritefunc.n_bifurcation_points(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of bifurcation points in a collection of neurites.

neurom.features.neuritefunc.n_forking_points(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of forking points in a collection of neurites.

neurom.features.neuritefunc.n_leaves(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of leaves points in a collection of neurites.

neurom.features.neuritefunc.n_neurites(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of neurites in a collection of neurites.

neurom.features.neuritefunc.n_sections(neurites, neurite_type=<NeuriteType.all: 32>, iterator_type=<function Section.ipreorder>)[source]

Number of sections in a collection of neurites.

neurom.features.neuritefunc.n_segments(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of segments in a collection of neurites.

neurom.features.neuritefunc.neurite_lengths(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get the path length per neurite in a collection.

neurom.features.neuritefunc.neurite_volume_density(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get the volume density per neurite.

The volume density is defined as the ratio of the neurite volume and the volume of the neurite’s enclosing convex hull

TODO: the convex hull fails on some morphologies, it may be good to instead use

bounding_box to compute the neurite enclosing volume

Note

Returns np.nan if the convex hull computation fails.

neurom.features.neuritefunc.number_of_bifurcations(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of bifurcation points in a collection of neurites.

neurom.features.neuritefunc.number_of_forking_points(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of forking points in a collection of neurites.

neurom.features.neuritefunc.number_of_neurites(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of neurites in a collection of neurites.

neurom.features.neuritefunc.number_of_sections(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of sections in a collection of neurites.

neurom.features.neuritefunc.number_of_sections_per_neurite(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get the number of sections per neurite in a collection of neurites.

neurom.features.neuritefunc.number_of_segments(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of sections in a collection of neurites.

neurom.features.neuritefunc.number_of_terminations(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Number of leaves points in a collection of neurites.

neurom.features.neuritefunc.partition_asymmetries(neurites, neurite_type=<NeuriteType.all: 32>, variant='branch-order', method='petilla')[source]

Partition asymmetry at bifurcation points of a collection of neurites.

Variant: length is a different definition, as the absolute difference in downstream path lenghts, relative to the total neurite path length Method: ‘petilla’ or ‘uylings’. The former is default. The latter uses -2 shift. See neurom.features.bifurcationfunc.partition_asymmetry()

neurom.features.neuritefunc.partition_pairs(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Partition pairs at bifurcation points of a collection of neurites.

Partition pair is defined as the number of bifurcations at the two daughters of the bifurcating section

neurom.features.neuritefunc.principal_direction_extents(neurites, neurite_type=<NeuriteType.all: 32>, direction=0)[source]

Principal direction extent of neurites in neurons.

neurom.features.neuritefunc.remote_bifurcation_angles(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get a list of remote bifurcation angles in a collection of neurites.

neurom.features.neuritefunc.section_areas(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Section areas in a collection of neurites.

neurom.features.neuritefunc.section_bif_branch_orders(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Bifurcation section branch orders in a collection of neurites.

neurom.features.neuritefunc.section_bif_lengths(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Bifurcation section lengths in a collection of neurites.

neurom.features.neuritefunc.section_bif_radial_distances(neurites, neurite_type=<NeuriteType.all: 32>, origin=None)[source]

Get the radial distances of the bifurcation sections for a collection of neurites.

neurom.features.neuritefunc.section_branch_orders(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Section branch orders in a collection of neurites.

neurom.features.neuritefunc.section_end_distances(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Section end to end distances in a collection of neurites.

neurom.features.neuritefunc.section_lengths(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Section lengths in a collection of neurites.

neurom.features.neuritefunc.section_path_lengths(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Path lengths of a collection of neurites.

neurom.features.neuritefunc.section_radial_distances(neurites, neurite_type=<NeuriteType.all: 32>, origin=None, iterator_type=<function Section.ipreorder>)[source]

Section radial distances in a collection of neurites.

The iterator_type can be used to select only terminal sections (ileaf) or only bifurcations (ibifurcation_point).

neurom.features.neuritefunc.section_strahler_orders(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Inter-segment opening angles in a section.

neurom.features.neuritefunc.section_taper_rates(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Diameter taper rates of the sections in a collection of neurites from root to tip.

Taper rate is defined here as the linear fit along a section. It is expected to be negative for neurons.

neurom.features.neuritefunc.section_term_branch_orders(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Termination section branch orders in a collection of neurites.

neurom.features.neuritefunc.section_term_lengths(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Termination section lengths in a collection of neurites.

neurom.features.neuritefunc.section_term_radial_distances(neurites, neurite_type=<NeuriteType.all: 32>, origin=None)[source]

Get the radial distances of the termination sections for a collection of neurites.

neurom.features.neuritefunc.section_tortuosity(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Section tortuosities in a collection of neurites.

neurom.features.neuritefunc.section_volumes(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Section volumes in a collection of neurites.

neurom.features.neuritefunc.segment_areas(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Areas of the segments in a collection of neurites.

neurom.features.neuritefunc.segment_lengths(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Lengths of the segments in a collection of neurites.

neurom.features.neuritefunc.segment_meander_angles(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Inter-segment opening angles in a section.

neurom.features.neuritefunc.segment_midpoints(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Return a list of segment mid-points in a collection of neurites.

neurom.features.neuritefunc.segment_path_lengths(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Returns pathlengths between all non-root points and their root point.

neurom.features.neuritefunc.segment_radial_distances(neurites, neurite_type=<NeuriteType.all: 32>, origin=None)[source]

Returns the list of distances between all segment mid points and origin.

neurom.features.neuritefunc.segment_radii(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Arithmetic mean of the radii of the points in segments in a collection of neurites.

neurom.features.neuritefunc.segment_taper_rates(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Diameters taper rates of the segments in a collection of neurites.

The taper rate is defined as the absolute radii differences divided by length of the section

neurom.features.neuritefunc.segment_volumes(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Volumes of the segments in a collection of neurites.

neurom.features.neuritefunc.sibling_ratios(neurites, neurite_type=<NeuriteType.all: 32>, method='first')[source]

Sibling ratios at bifurcation points of a collection of neurites.

The sibling ratio is the ratio between the diameters of the smallest and the largest child. It is a real number between 0 and 1. Method argument allows one to consider mean diameters along the child section instead of diameter of the first point.

neurom.features.neuritefunc.terminal_path_lengths_per_neurite(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get the path lengths to each terminal point per neurite in a collection.

neurom.features.neuritefunc.total_area_per_neurite(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Surface area in a collection of neurites.

The area is defined as the sum of the area of the sections.

neurom.features.neuritefunc.total_length_per_neurite(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get the path length per neurite in a collection.

neurom.features.neuritefunc.total_volume_per_neurite(neurites, neurite_type=<NeuriteType.all: 32>)[source]

Get the volume per neurite in a collection.