neurom.core.morphology¶
Morphology classes and functions.
Functions
|
Returns a morphology starting at section. |
|
Iterator to a neurite, morphology or morphology population. |
|
Return an iterator to the points in a population, morphology, neurites, or section. |
|
Iterator to the sections in a neurite, morphology or morphology population. |
|
Return an iterator to the segments in a collection of neurites. |
Classes
|
Class representing a simple morphology. |
|
Class representing a neurite tree. |
|
Simple recursive tree class. |
- class neurom.core.morphology.Morphology(morphio_morph, name=None, *, process_subtrees=False)¶
Class representing a simple morphology.
Morphology constructor.
- Parameters:
morphio_morph (morphio.Morphology|morphio.mut.Morphology) – a morphio object
name (str) – an optional morphology name
process_subtrees (bool) – enable mixed tree processing if set to True
- copy()¶
Returns a shallow copy of the morphio morphology object.
- property neurites¶
The list of neurites.
- property points¶
Returns the list of points.
- section(section_id)¶
Returns the section with the given id.
- property sections¶
The array of all sections, excluding the soma.
- property segments¶
The array of all segments of the sections.
- to_morphio()¶
Returns the morphio morphology object.
- transform(trans)¶
Return a copy of this morphology with a 3D transformation applied.
- class neurom.core.morphology.Neurite(root_node, *, process_subtrees=False)¶
Class representing a neurite tree.
Constructor.
- Parameters:
root_node (morphio.Section) – root section
process_subtrees (bool) – enable mixed tree processing if set to True
- property area¶
Return the surface area of this neurite.
The area is defined as the sum of area of the sections.
- is_heterogeneous() bool ¶
Returns true if the neurite consists of more that one section types.
- property length¶
Returns the total length of this neurite.
The length is defined as the sum of lengths of the sections.
- property morphio_root_node¶
Returns the morphio root section.
- property points¶
Array with all the points in this neurite.
Note: Duplicate points at section bifurcations are removed
- property process_subtrees¶
Enable mixed tree processing if set to True.
- property root_node¶
The first section of the neurite.
- property sections¶
The array of all sections.
- property segments¶
The array of all segments of the neurite.
- subtree_types¶
The types of the subtrees.
- type¶
The type of the Neurite (which can be composite).
- property volume¶
Return the volume of this neurite.
The volume is defined as the sum of volumes of the sections.
- class neurom.core.morphology.Section(morphio_section)¶
Simple recursive tree class.
The section constructor.
- property area¶
Return the surface area of this section.
The area is calculated from the segments, as defined by this section’s points
- property children¶
Returns a list of child section.
- ibifurcation_point(iter_mode=<function Section.ipreorder>)¶
Iterator to bifurcation points.
- Parameters:
iter_mode – iteration mode. Default: ipreorder.
- property id¶
Returns the section ID.
- iforking_point(iter_mode=<function Section.ipreorder>)¶
Iterator to forking points.
- Parameters:
iter_mode – iteration mode. Default: ipreorder.
- ileaf()¶
Iterator to all leaves of a tree.
- ipostorder()¶
Depth-first post-order iteration of tree nodes.
- ipreorder()¶
Depth-first pre-order iteration of tree nodes.
- is_bifurcation_point()¶
Is tree a bifurcation point?
- is_forking_point()¶
Is this section a forking point?
- is_homogeneous_point()¶
A section is homogeneous if it has the same type with its children.
- is_leaf()¶
Is tree a leaf?
- is_root()¶
Is tree the root node?
- iupstream(stop_node=None)¶
Iterate from a tree node to the root nodes.
- Parameters:
stop_node – Node to stop the upstream traversal. If None, it stops when parent is None.
- property length¶
Return the path length of this section.
- property parent¶
Returns the parent section if non root section else None.
- property points¶
Returns the section list of points the NeuroM way (points + radius).
- property segments¶
The array of all segments of the neurite.
- to_morphio()¶
Returns the morphio section.
- property type¶
Returns the section type.
- property volume¶
Return the volume of this section.
The volume is calculated from the segments, as defined by this section’s points
- neurom.core.morphology.graft_morphology(section)¶
Returns a morphology starting at section.
- neurom.core.morphology.iter_neurites(obj, mapfun=None, filt=None, neurite_order=NeuriteIter.FileOrder)¶
Iterator to a neurite, morphology or morphology population.
Applies optional neurite filter and mapping functions.
- Parameters:
obj – a neurite, morphology or morphology 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 morphology population
>>> from neurom.core.morphology import iter_neurites >>> from neurom import load_morphologies >>> pop = load_morphologies("tests/data/valid_set") >>> n_points = [n for n in iter_neurites(pop, lambda x, section_type: len(x.points))]
Get the number of points in each axon in a morphology population
>>> import neurom as nm >>> from neurom.core.morphology import iter_neurites >>> from neurom import load_morphologies >>> pop = load_morphologies("tests/data/valid_set") >>> filter = lambda n : n.type == nm.AXON >>> mapping = lambda n, section_type: len(n.points) >>> n_points = [n for n in iter_neurites(pop, mapping, filter)]
- neurom.core.morphology.iter_points(obj, neurite_filter=None, neurite_order=NeuriteIter.FileOrder, section_filter=None)¶
Return an iterator to the points in a population, morphology, neurites, or section.
- Parameters:
obj – population, morphology, neurite, section or iterable containing
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
section_filter – optional section level filter
- neurom.core.morphology.iter_sections(neurites, iterator_type=<function Section.ipreorder>, neurite_filter=None, neurite_order=NeuriteIter.FileOrder, section_filter=None)¶
Iterator to the sections in a neurite, morphology or morphology population.
- Parameters:
neurites – morphology, 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
section_filter – optional section level filter. Please note that neurite_filter takes precedence over the section_filter.
Examples
Get the number of points in each section of all the axons in a morphology population
>>> import neurom as nm >>> from neurom.core.morphology 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.core.morphology.iter_segments(obj, neurite_filter=None, neurite_order=NeuriteIter.FileOrder, section_filter=None, section_iterator=<function Section.ipreorder>)¶
Return an iterator to the segments in a collection of neurites.
- Parameters:
obj – morphology, 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
section_filter – optional section level filter
section_iterator – 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
Note
This is a convenience function provided for generic access to morphology segments. It may have a performance overhead WRT custom-made segment analysis functions that leverage numpy and section-wise iteration.