morph_tool¶
Implementation of the morphology file converter.
- exception morph_tool.MorphToolException¶
MorphTool exception.
- morph_tool.apical_point_position(neuron, tuft_percent=20)¶
Attempt to find the apical point in ‘tufted’ neurons.
Consider a neuron:
| / | Tuft = 20% |--/ | | / |--/ | ----.-----
All endpoints in the top ‘tuft_percent’ are found, then their common branch segment, furthest from the soma, is identified.
Using the release from 2012 as the base, apical points were compared from the annotated versions, and using this algorithm. Of 239 morphologies that were annotated, 48 differed in the apical point choice by more than 1um in the y component. Many of the differences were morphologies that shoulnd’t have had apical points in the first place (ie: weren’t pyramidal cells, ex: C050398B-I4).
- Parameters:
neuron (morphio.Morphology) – a neuron morphology
tuft_percent – percentage of the ‘height’ of the apical dendrite that would enclose the tuft, only leaves in this volume are considered as endpoints
- Returns:
a point if it is found, or None otherwise
- Return type:
- morph_tool.apical_point_section_segment(neuron, tuft_percent=20)¶
Find the apical point’s section and segment.
- Parameters:
neuron (morphio.Morphology) – a morphology
tuft_percent – percentage of the ‘height’ of the apical dendrite that would enclose the tuft, only leaves in this volume are considered as endpoints See apical_point_position for more details
- Returns:
(NeuroM/MorphIO section ID, point ID) of the apical point. Since NeuroM v2, section ids of NeuroM and MorphIO are the same excluding soma.
- Return type:
Tuple
- morph_tool.axon_point_section(morph, direction=None, bbox=None, ignore_axis=2)¶
Estimate axon point as the terminal point of the main axon.
This point is defined as the point for which the sum of the angles with the direction vector is minimal. This corresponds to a main axon being a branch that follows best a straight line in the given direction. More constraints can be added with bbox argument, if incorrect axon is detected.
- Parameters:
- Returns:
MorphIO section ID for which the last point is the axon point
- morph_tool.convert(input_file, outputfile, recenter=False, nrn_order=False, single_point_soma=False, sanitize=False)¶
Run the appropriate converter.
- Parameters:
input_file (str) – path to input file
outputfile (str) – path to output file
recenter (bool) – whether to recenter the morphology based on the
soma (center of gravity of the) –
nrn_order (bool) – whether to traverse the neuron in the NEURON fashion
single_point_soma (bool) – For SWC only
sanitize (bool) – whether to sanitize the morphology
- morph_tool.diff(morph1, morph2, rtol=1e-05, atol=1e-08)¶
Returns a DiffResult object that is equivalent to True when morphologies differ.
Additional information about why they differ is stored in DiffResult.info Morphologies with different formats can be compared. Morphologies are considered different if one of the following property differ: - number of root sections - sections type - sections point array - sections diameter array - sections perimeter array - sections number of children The soma are NOT taken into consideration
- Parameters:
morph1 (str|morphio.Morphology|morphio.mut.Morphology) – a morphology
morph2 (str|morphio.Morphology|morphio.mut.Morphology) – a morphology
rtol (float) – the relative tolerance used for comparing points (see numpy.isclose help)
atol (float) – the absolute tolerance used for comparing points (see numpy.isclose help)
- morph_tool.point_to_section_segment(neuron, point, rtol=1e-05, atol=1e-08)¶
Find section and segment that matches the point.
Only the first point found with the exact same coordinates as the point argument is considered
- Parameters:
neuron (morphio.Morphology) – neuron object
point (point) – value of the point to find in the h5 file
rtol (floats) – precision of np.isclose
atol (floats) – precision of np.isclose
- Returns:
(NeuroM/MorphIO section ID, point ID) of the point the matches the input coordinates. Since NeuroM v2, section ids of NeuroM and MorphIO are the same excluding soma.
- Return type:
Tuple