neurom.features.morphology¶
Morphology features.
Any public function from this namespace can be called via the features mechanism. If calling
directly the function in this namespace can only accept a morphology as its input. If you want to
apply it to a morphology population then you must use the features mechanism e.g. features.get
.
The features mechanism does not allow you to apply these features to neurites.
>>> import neurom
>>> from neurom import features
>>> m = neurom.load_morphology("tests/data/swc/Neuron.swc")
>>> result = features.get('soma_surface_area', m)
>>> population = neurom.load_morphologies("tests/data/valid_set")
>>> result = features.get('sholl_crossings', population)
For more details see Features.
Functions

Calculates the min/max ratio of the principal direction extents along the plane. 

Calculates the circularity of the morphology points along the plane. 

Returns the length fraction of the segments that have their midpoints higher than the soma. 

Get the maximum radial distances of the termination sections. 

Get volume density per neurite. 

Number of neurites in a morph. 

List of numbers of sections per neurite. 

Get the radial distances of the bifurcation sections. 

Section radial distances. 

Get the radial distances of the termination sections. 

Ger the radial distances of the segments. 

Calculates the shape factor of the morphology points along the plane. 

Calculate crossings of neurites. 

Perform Sholl frequency calculations on a morph. 

Get the radius of a morphology's soma. 

Get the surface area of a morphology's soma. 

Get the volume of a morphology's soma. 

Neurite areas. 

Extent of morphology along axis z. 

Extent of morphology along axis y. 

Neurite lengths. 

Neurite volumes. 

Extent of morphology along axis x. 

Calculate the angles between all the trunks of the morph. 

Calculate the angles between the trunks of the morph of a given type and a given vector. 

Calculate the angles between the trunks of the morph of a source type to target type. 

Get a list of all the trunk origin azimuths of a morph. 

Get a list of all the trunk origin elevations of a morph. 

Radii of the trunk sections of neurites in a morph. 

List of lengths of trunk sections of neurites in a morph. 

Calculate the vectors between all the trunks of the morphology and the soma center. 

Get the volume density. 
 neurom.features.morphology.aspect_ratio(morph, neurite_type=NeuriteType.all, projection_plane='xy')¶
Calculates the min/max ratio of the principal direction extents along the plane.
 Parameters:
morph – Morphology object.
neurite_type – The neurite type to use. By default all neurite types are used.
projection_plane – Projection plane to use for the calculation. One of (‘xy’, ‘xz’, ‘yz’).
 Returns:
The aspect ratio feature of the morphology points.
 neurom.features.morphology.circularity(morph, neurite_type=NeuriteType.all, projection_plane='xy')¶
Calculates the circularity of the morphology points along the plane.
The circularity is defined as the 4 * pi * area of the convex hull over its perimeter.
 Parameters:
morph – Morphology object.
neurite_type – The neurite type to use. By default all neurite types are used.
projection_plane – Projection plane to use for the calculation. One of (‘xy’, ‘xz’, ‘yz’).
 Returns:
The circularity of the morphology points.
 neurom.features.morphology.length_fraction_above_soma(morph, neurite_type=NeuriteType.all, up='Y')¶
Returns the length fraction of the segments that have their midpoints higher than the soma.
 Parameters:
morph – Morphology object.
neurite_type – The neurite type to use. By default all neurite types are used.
up – The axis along which the computation is performed. One of (‘X’, ‘Y’, ‘Z’).
 Returns:
The fraction of neurite length that lies on the right of the soma along the given axis.
 neurom.features.morphology.max_radial_distance(morph, origin=None, neurite_type=NeuriteType.all)¶
Get the maximum radial distances of the termination sections.
 neurom.features.morphology.neurite_volume_density(morph, neurite_type=NeuriteType.all)¶
Get volume density per neurite.
 neurom.features.morphology.number_of_neurites(morph, neurite_type=NeuriteType.all)¶
Number of neurites in a morph.
 neurom.features.morphology.number_of_sections_per_neurite(morph, neurite_type=NeuriteType.all)¶
List of numbers of sections per neurite.
 neurom.features.morphology.section_bif_radial_distances(morph, origin=None, neurite_type=NeuriteType.all)¶
Get the radial distances of the bifurcation sections.
 neurom.features.morphology.section_radial_distances(morph, origin=None, neurite_type=NeuriteType.all)¶
Section radial distances.
 neurom.features.morphology.section_term_radial_distances(morph, origin=None, neurite_type=NeuriteType.all)¶
Get the radial distances of the termination sections.
 neurom.features.morphology.segment_radial_distances(morph, origin=None, neurite_type=NeuriteType.all)¶
Ger the radial distances of the segments.
 neurom.features.morphology.shape_factor(morph, neurite_type=NeuriteType.all, projection_plane='xy')¶
Calculates the shape factor of the morphology points along the plane.
The shape factor is defined as the ratio of the convex hull area over max squared pairwise distance of the morphology points.
 Parameters:
morph – Morphology object.
neurite_type – The neurite type to use. By default all neurite types are used.
projection_plane – Projection plane to use for the calculation. One of (‘xy’, ‘xz’, ‘yz’).
 Returns:
The shape factor of the morphology points.
 neurom.features.morphology.sholl_crossings(morph, neurite_type=NeuriteType.all, center=None, radii=None)¶
Calculate crossings of neurites.
 Parameters:
morph (Morphologylist) – morphology or a list of neurites
neurite_type (NeuriteType) – Type of neurite to use. By default
NeuriteType.all
is used.center (Point) – center point, if None then soma center is taken
radii (iterable of floats) – radii for which crossings will be counted, if None then soma radius is taken
 Returns:
Array of same length as radii, with a count of the number of crossings for the respective radius
This function can also be used with a list of sections, as follow:
secs = (sec for sec in nm.iter_sections(morph) if complex_filter(sec)) sholl = nm.features.neuritefunc.sholl_crossings(secs, center=morph.soma.center, radii=np.arange(0, 1000, 100))
 neurom.features.morphology.sholl_frequency(morph, neurite_type=NeuriteType.all, step_size=10, bins=None)¶
Perform Sholl frequency calculations on a morph.
 Parameters:
morph (Morphology) – a morphology
neurite_type (NeuriteType) – which neurites to operate on
step_size (float) – step size between Sholl radii
bins (iterable of floats) – custom binning to use for the Sholl radii. If None, it uses
morphologies. (intervals of step_size between min and max radii of)
Note
Given a morphology, the soma center is used for the concentric circles, which range from the soma radii, and the maximum radial distance in steps of step_size. Each segment of the morphology is tested, so a neurite that bends back on itself, and crosses the same Sholl radius will get counted as having crossed multiple times.
If a neurite_type is specified and there are no trees corresponding to it, an empty list will be returned.
 neurom.features.morphology.soma_radius(morph)¶
Get the radius of a morphology’s soma.
 neurom.features.morphology.soma_surface_area(morph)¶
Get the surface area of a morphology’s soma.
Note
The surface area is calculated by assuming the soma is spherical.
 neurom.features.morphology.soma_volume(morph)¶
Get the volume of a morphology’s soma.
 neurom.features.morphology.total_area_per_neurite(morph, neurite_type=NeuriteType.all)¶
Neurite areas.
 neurom.features.morphology.total_depth(morph, neurite_type=NeuriteType.all)¶
Extent of morphology along axis z.
 neurom.features.morphology.total_height(morph, neurite_type=NeuriteType.all)¶
Extent of morphology along axis y.
 neurom.features.morphology.total_length_per_neurite(morph, neurite_type=NeuriteType.all)¶
Neurite lengths.
 neurom.features.morphology.total_volume_per_neurite(morph, neurite_type=NeuriteType.all)¶
Neurite volumes.
 neurom.features.morphology.total_width(morph, neurite_type=NeuriteType.all)¶
Extent of morphology along axis x.
 neurom.features.morphology.trunk_angles(morph, neurite_type=NeuriteType.all, coords_only='xy', sort_along='xy', consecutive_only=True)¶
Calculate the angles between all the trunks of the morph.
By default, the angles are defined on the xy plane and the trees are sorted from the y axis and anticlockwise.
 Parameters:
morph – The morphology to process.
neurite_type – Only the neurites of this type are considered.
coords_only – Consider only the coordinates listed in this argument (should be a combination of ‘x’, ‘y’ and ‘z’).
sort_along – Sort angles according to the given plane (should be ‘xy’, ‘xz’ or ‘yz’) before computing the angles between the trunks.
consecutive_only – Compute only the angles between consecutive trunks (the default order of neurite trunks is the same as the one used by
neurom.core.morphology.iter_neurites()
but this order can be changed using the sort_along parameter).
 Returns:
The angles between each trunk and all the others. If
consecutive_only
isTrue
, only the angle with the next trunk is returned for each trunk. Return type:
list[[float]] or list[float]
 neurom.features.morphology.trunk_angles_from_vector(morph, neurite_type=NeuriteType.all, vector=None)¶
Calculate the angles between the trunks of the morph of a given type and a given vector.
 Parameters:
morph – The morphology to process.
neurite_type – Only the neurites of this type are considered.
vector – The reference vector. If
None
, the reference vector is set to(0, 1, 0)
.
 Returns:
For each neurite, an array with 3 elements is returned:
the absolute 3d angle between the two vectors.
the elevation angle (or polar angle) between the two vectors.
the azimuth angle between the two vectors.
 Return type:
list[list[float]]
 neurom.features.morphology.trunk_angles_inter_types(morph, source_neurite_type=NeuriteType.apical_dendrite, target_neurite_type=NeuriteType.basal_dendrite, closest_component=None)¶
Calculate the angles between the trunks of the morph of a source type to target type.
 Parameters:
morph – The morphology to process.
source_neurite_type – Only the neurites of this type are considered as sources.
target_neurite_type – Only the neurites of this type are considered as targets.
closest_component –
If
closest_component
is notNone
, only one element is returned for each neurite of source type:if set to 0, the one with the lowest absolute 3d angle is returned.
if set to 1, the one with the lowest absolute elevation angle is returned.
if set to 2, the one with the lowest absolute azimuth angle is returned.
 Returns:
If
closest_component
isNone
, a list of 3 elements is returned for each couple of neurites:the absolute 3d angle between the two vectors.
the elevation angle (or polar angle) between the two vectors.
the azimuth angle between the two vectors.
If
closest_component
is notNone
, only one of these values is returned for each couple. Return type:
list[list[float]] or list[float]
 neurom.features.morphology.trunk_origin_azimuths(morph, neurite_type=NeuriteType.all)¶
Get a list of all the trunk origin azimuths of a morph.
The azimuth is defined as Angle between xaxis and the vector defined by (initial tree point  soma center) on the xz plane.
The range of the azimuth angle [pi, pi] radians
 neurom.features.morphology.trunk_origin_elevations(morph, neurite_type=NeuriteType.all)¶
Get a list of all the trunk origin elevations of a morph.
The elevation is defined as the angle between xaxis and the vector defined by (initial tree point  soma center) on the xy halfplane.
The range of the elevation angle [pi/2, pi/2] radians
 neurom.features.morphology.trunk_origin_radii(morph, neurite_type=NeuriteType.all, min_length_filter=None, max_length_filter=None)¶
Radii of the trunk sections of neurites in a morph.
Warning
If
min_length_filter
and / ormax_length_filter
is given, the points are filtered and the mean radii of the remaining points is returned. Note that if themin_length_filter
is greater than the path distance of the last point of the first section, the radius of this last point is returned. Parameters:
morph – The morphology to process.
neurite_type – Only the neurites of this type are considered.
min_length_filter – The min length from which the neurite points are considered.
max_length_filter – The max length from which the neurite points are considered.
 Returns:
if
min_length_filter
andmax_length_filter
areNone
, the radii of the first point of each neurite are returned.else the mean radius of the points between the given
min_length_filter
andmax_length_filter
are returned.
 Return type:
list[float]
 neurom.features.morphology.trunk_section_lengths(morph, neurite_type=NeuriteType.all)¶
List of lengths of trunk sections of neurites in a morph.
 neurom.features.morphology.trunk_vectors(morph, neurite_type=NeuriteType.all)¶
Calculate the vectors between all the trunks of the morphology and the soma center.
 neurom.features.morphology.volume_density(morph, neurite_type=NeuriteType.all)¶
Get the volume density.
The volume density is defined as the ratio of the neurite volume and the volume of the morphology’s enclosing convex hull
Note
Returns np.nan if the convex hull computation fails or there are not points available due to neurite type filtering.