neurom.check.neuron_checks¶
NeuroM neuron checking functions.
Contains functions for checking validity of neuron neurites and somata. Tests assumes neurites and/or soma have been succesfully built where applicable, i.e. soma- and neurite-related structural tests pass.
Functions
Check if a neuron has neurites that are flat within a tolerance. |
|
Get neurites that are not monotonic. |
|
Check that a neuron has only neurites that are monotonic. |
|
Check presence of neurite points with radius not above threshold. |
|
Check presence of neuron sections with length not above threshold. |
|
Check presence of neuron segments with length not above threshold. |
|
Check if a neuron has apical dendrites. |
|
Check if a neuron has an axon. |
|
Check if a neuron has basal dendrites. |
|
Check if a section has more than 3 children. |
|
Check if the neuron has dangling neurites. |
|
Check if leaf points are too large. |
|
Check that a neuron has no flat neurites. |
|
Check if there are jumps (large movements in the axis). |
|
Check if the neuron has dendrites with narrow sections. |
|
Check if neurites have a narrow start. |
|
Check that the neurites have no root node jumps. |
|
Check if soma radius not above threshold. |
|
Iterator to a neurite, neuron or neuron population. |
|
Iterator to the sections in a neurite, neuron or neuron population. |
|
Return an iterator to the segments in a collection of neurites. |
|
Compute the path distance from given set of points. |
|
Return the length of a segment. |
Classes
Column labels for internal data representation. |
|
Class representing a check result. |
|
Enum representing valid tree types. |
|
Simple recursive tree class. |
-
class
neurom.check.neuron_checks.
COLS
[source]¶ Bases:
object
Column labels for internal data representation.
-
class
neurom.check.neuron_checks.
CheckResult
(status, info=None, title=None)[source]¶ Bases:
object
Class representing a check result.
-
class
neurom.check.neuron_checks.
NeuriteType
(value)[source]¶ Bases:
neurom.utils.OrderedEnum
Enum representing valid tree types.
-
class
neurom.check.neuron_checks.
Tree
[source]¶ Bases:
object
Simple recursive tree class.
-
add_child
(tree)[source]¶ Add a child to the list of this tree’s children.
This tree becomes the added tree’s parent
-
ibifurcation_point
(iter_mode=<function Tree.ipreorder>)[source]¶ Iterator to bifurcation points. Returns a tree object.
- Parameters
tree – the tree over which to iterate
iter_mode – iteration mode. Default: ipreorder.
-
-
neurom.check.neuron_checks.
get_flat_neurites
(neuron, tol=0.1, method='ratio')[source]¶ Check if a neuron has neurites that are flat within a tolerance.
- Parameters
neurite (Neurite) – neurite to operate on
tol (float) – the tolerance or the ratio
method (string) – ‘tolerance’ or ‘ratio’ described in
is_flat()
- Returns
Bool list corresponding to the flatness check for each neurite in neuron neurites with respect to the given criteria
-
neurom.check.neuron_checks.
get_nonmonotonic_neurites
(neuron, tol=1e-06)[source]¶ Get neurites that are not monotonic.
- Parameters
neurite (Neurite) – neurite to operate on
tol (float) – the tolerance or the ratio
- Returns
list of neurites that do not satisfy monotonicity test
-
neurom.check.neuron_checks.
has_all_monotonic_neurites
(neuron, tol=1e-06)[source]¶ Check that a neuron has only neurites that are monotonic.
- Parameters
neuron (Neuron) – The neuron object to test
tol (float) – tolerance
- Returns
CheckResult with result
-
neurom.check.neuron_checks.
has_all_nonzero_neurite_radii
(neuron, threshold=0.0)[source]¶ Check presence of neurite points with radius not above threshold.
- Parameters
neuron (Neuron) – The neuron object to test
threshold – value above which a radius is considered to be non-zero
- Returns
CheckResult with result including list of (section ID, point ID) pairs of zero-radius points
-
neurom.check.neuron_checks.
has_all_nonzero_section_lengths
(neuron, threshold=0.0)[source]¶ Check presence of neuron sections with length not above threshold.
- Parameters
neuron (Neuron) – The neuron object to test
threshold (float) – value above which a section length is considered
be non-zero (to) –
- Returns
CheckResult with result including list of ids of bad sections
-
neurom.check.neuron_checks.
has_all_nonzero_segment_lengths
(neuron, threshold=0.0)[source]¶ Check presence of neuron segments with length not above threshold.
- Parameters
neuron (Neuron) – The neuron object to test
threshold (float) – value above which a segment length is considered to
non-zero (be) –
- Returns
CheckResult with result including list of (section_id, segment_id) of zero length segments
-
neurom.check.neuron_checks.
has_apical_dendrite
(neuron, min_number=1, treefun=<function _read_neurite_type>)[source]¶ Check if a neuron has apical dendrites.
- Parameters
neuron (Neuron) – The neuron object to test
min_number – minimum number of apical dendrites required
treefun – Optional function to calculate the tree type of neuron’s
neurites –
- Returns
CheckResult with result
-
neurom.check.neuron_checks.
has_axon
(neuron, treefun=<function _read_neurite_type>)[source]¶ Check if a neuron has an axon.
- Parameters
neuron (Neuron) – The neuron object to test
treefun – Optional function to calculate the tree type of
neurites (neuron's) –
- Returns
CheckResult with result
-
neurom.check.neuron_checks.
has_basal_dendrite
(neuron, min_number=1, treefun=<function _read_neurite_type>)[source]¶ Check if a neuron has basal dendrites.
- Parameters
neuron (Neuron) – The neuron object to test
min_number – minimum number of basal dendrites required
treefun – Optional function to calculate the tree type of neuron’s
neurites –
- Returns
CheckResult with result
-
neurom.check.neuron_checks.
has_multifurcation
(neuron)[source]¶ Check if a section has more than 3 children.
-
neurom.check.neuron_checks.
has_no_dangling_branch
(neuron)[source]¶ Check if the neuron has dangling neurites.
Are considered dangling
dendrites whose first point is too far from the soma center
axons whose first point is too far from the soma center AND from any point belonging to a dendrite
- Parameters
neuron (Neuron) – The neuron object to test
- Returns
CheckResult with a list of all first segments of dangling neurites
-
neurom.check.neuron_checks.
has_no_fat_ends
(neuron, multiple_of_mean=2.0, final_point_count=5)[source]¶ Check if leaf points are too large.
- Parameters
neuron (Neuron) – The neuron object to test
multiple_of_mean (float) – how many times larger the final radius
to be compared to the mean of the final points (has) –
final_point_count (int) – how many points to include in the mean
- Returns
CheckResult with result list of ids of bad sections
Note
A fat end is defined as a leaf segment whose last point is larger by a factor of multiple_of_mean than the mean of the points in final_point_count
-
neurom.check.neuron_checks.
has_no_flat_neurites
(neuron, tol=0.1, method='ratio')[source]¶ Check that a neuron has no flat neurites.
- Parameters
neuron (Neuron) – The neuron object to test
tol (float) – tolerance
method (string) – way of determining flatness, ‘tolerance’, ‘ratio’ as described in
neurom.check.morphtree.get_flat_neurites()
- Returns
CheckResult with result
-
neurom.check.neuron_checks.
has_no_jumps
(neuron, max_distance=30.0, axis='z')[source]¶ Check if there are jumps (large movements in the axis).
- Parameters
neuron (Neuron) – The neuron object to test
max_distance (float) – value above which consecutive z-values are
a jump (considered) –
axis (str) – one of x/y/z, which axis to check for jumps
- Returns
CheckResult with result list of ids of bad sections
-
neurom.check.neuron_checks.
has_no_narrow_neurite_section
(neuron, neurite_filter, radius_threshold=0.05, considered_section_min_length=50)[source]¶ Check if the neuron has dendrites with narrow sections.
- Parameters
neuron (Neuron) – The neuron object to test
neurite_filter (callable) – filter the neurites by this callable
radius_threshold (float) – radii below this are considered narro
considered_section_min_length (float) – sections with length below
are not taken into account (this) –
- Returns
CheckResult with result. result.info contains the narrow section ids and their first point
-
neurom.check.neuron_checks.
has_no_narrow_start
(neuron, frac=0.9)[source]¶ Check if neurites have a narrow start.
- Parameters
neuron (Neuron) – The neuron object to test
frac (float) – Ratio that the second point must be smaller than the first
- Returns
CheckResult with a list of all first segments of neurites with a narrow start
-
neurom.check.neuron_checks.
has_no_root_node_jumps
(neuron, radius_multiplier=2)[source]¶ Check that the neurites have no root node jumps.
Their first point not should not be further than radius_multiplier * soma radius from the soma center
-
neurom.check.neuron_checks.
has_nonzero_soma_radius
(neuron, threshold=0.0)[source]¶ Check if soma radius not above threshold.
- Parameters
neuron (Neuron) – The neuron object to test
threshold – value above which the soma radius is considered to be non-zero
- Returns
CheckResult with result
-
neurom.check.neuron_checks.
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 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 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.check.neuron_checks.
iter_sections
(neurites, iterator_type=<function Tree.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: Tree.ipreorder: Depth-first pre-order iteration of tree nodes Tree.ipostorder: Depth-first post-order iteration of tree nodes Tree.iupstream: Iterate from a tree node to the root nodes Tree.ibifurcation_point: Iterator to bifurcation points Tree.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 import ites_sections >>> filter = lambda n : n.type == nm.AXON >>> n_points = [len(s.points) for s in iter_sections(pop, neurite_filter=filter)]
-
neurom.check.neuron_checks.
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.check.neuron_checks.
section_length
(points)¶ Compute the path distance from given set of points.