## Feature definitions and associated API calls

Features are based on rotated but unscaled morphologies. Except as otherwise noted, there is an implicit "_x", "_y" and "_z" on feature names for spatial features calculated along each axis.

A compartment is defined as the conical section between two SWC nodes. A compartment's type is the type of its non-root node (ie, the node furthest from the root).

Trifurcations are treated as adjacent bifurcations.

Features are calculated separately for apical dendrite, basal dendrite, all dendrites, axon, and all neurites. This generates 5 sets of features per morphology.

MorphologyFeatures::calculate() – Calculates features only on the neurite branches that can be traced back to the soma (i.e., that have the soma as their root)

MorphologyFeatures::calculate_cloud() – Calculates a subset of features that are relevant to analyzing a disconnected tree (e.g., an axon missing many segments)

##### first_compartment_moment

The centroid of all compartments along each axis:

∑i=1nPi∗Li∑i=1nLi

for n compartments, where Pi is the spatial position of compartment i's center along the measured axis, and Li is the length of compartment i.

NOTE: The radius of each compartment is not used for this calculation. All compartments are treated as having unit radius, allowing only compartment length to be in the moment equation.

API function: calculate_compartment_moments(morph)

##### second_compartment_moment

The second moment (variance) of all compartments along each axis:

∑i=1n(P0−Pi)2∗Li∑i=1nLi

for n compartments, where Pi is the spatial position of compartment i's center along the measured axis, P0 is the centroid of the dendrite along this axis (first_component_moment), and Li is the length of compartment i.

NOTE: The radius of each compartment is not used for this calculation. All compartments are treated as having unit radius, allowing only compartment length to be in the moment equation.

API function: calculate_compartment_moments(morph)

##### first_bifurcation_moment

The centroid position of all bifurcation along each axis:

∑i=1nPin

for n bifurcating nodes (ie, nodes with two or more children), where Pi is the spatial position of node i along the measured axis.

API function: calculate_bifurcation_moments(morph)

##### second_bifurcation_moment

The second moment (variance) of bifurcation locations along each axis:

∑i=1n(P0−Pi)2n

for n bifurcating nodes (ie, nodes with two or more children), where P0 is the bifurcation centroid along the axis (first_bifurcation_moment) and Pi is the spatial position of node i along the measured axis.

API function: calculate_bifurcation_moments(morph)

##### max_euclidean_distance

The spatial distance from the soma to the most distal node.

API function: calculate_max_euclidean_distance(morph)

##### max_path_distance

The path distance from the soma to the furthest neurite tip. This is the longest path between soma and tip. It is NOT the path distance to the neurite having the maximal euclidean distance.

API function: calculate_max_path_distance(morph)

Differs from V3D. Manually examined SWC. V3D number includes diameter of soma (ie, distance from soma center to axon/dendrite root).

##### num_stems

The number of stems sprouting from the soma.

API functions: calculate_num_stems(morph); calculate_num_stems_by_type(morph)

Matches V3D

##### num_bifurcations

The number of bifurcations (i.e., nodes with two children) that exist in the morphology. A trifurcation is treated as two neighboring bifurcations, to avoid artifacts arising from segmenting and segment sizes. Stems from the soma are not included in this calculation.

API function: calculate_num_bifurcations(morph)

Discrepancy w/ V3D. Manually examined /projects/mousecelltypes/vol1/prod250/specimen_341442651/Pvalb-IRES-Cre_Ai14-178310.02.01.01_491119993_m.swc. Number of bifurcations are as reported by new algorithm (ie, V3D appears to be off by one).

##### num_branches

The number of branches in the morphology. A branch is defined as the section between soma and bifurcation, between bifurcations, and between bifurcation and tips. A trifurcation is treated as two successive bifurcations, so is itself counted as a branch, albeit a potentially very short one.

API function: calculate_num_branches(morph)

matches V3D

##### num_tips

The number of terminations (i.e., nodes with zero children) that exist in the morphology.

API function: calculate_num_branches(morph)

matches V3D

##### width

The difference between minimum and maximum X position values of all non-soma nodes in the morphology. Note: This does not implement the "95%" rule eluded to in the L-measure description.

API function: calculate_dimensions(morph)

matches V3D

##### height

The difference between minimum and maximum Y position values of all non-soma nodes in the morphology. Note: This does not implement the "95%" rule eluded to in the L-measure description.

API function: calculate_dimensions(morph)

matches V3D

##### depth

The difference between minimum and maximum Z position values of all non-soma nodes in the morphology. Note: This does not implement the "95%" rule eluded to in the L-measure description.

API function: calculate_dimensions(morph)

matches V3D

##### max_branch_order

The maximum number of bifurcations (or trifurcations) encountered between the soma and all neurite tips (terminations). Branching at the soma (ie, soma stems) is excluded from the calculation.

API function: calculate_max_branch_order(morph)

Discrepancy w/ V3D. Using L-Measure definition of branch order, manual examination of SWC shows max branch order=3 while V3D reports order=4. V3D appears to include soma stems in calculation, which is incorrect according to l-measure definition (soma defined as branch-order=0).

##### mean_contraction

The ratio of the summed euclidean distance between bifurcations, and between bifurcations and tips, to the summed path distance between same. Trifurcations are treated as bifurcations.

API function: calculate_mean_contraction(morph)

Different than V3D (~1.5%). V3D number closer to the average euclidean distance over path distance calculated for each bif-bif or bif-tip separately (V3D has 0.3% difference to that number)

##### total_length

The total length of all compartments of a given SWC type.

API function: calculate_total_length(morph)

Different than V3D (off by approx #stems times soma radius). V3D includes distance from stem base to soma center for each stem. New algorithm measures length from start of each stem.

##### num_neurites

Number of compartments of a given SWC type.

API function: calculate_num_neurites(morph)

<no V3D correlate>

##### num_nodes

Number of nodes of a given SWC type

API function: Morphology.num_nodes

Different than V3D. V3D returns the number of nodes in the SWC file. The new algorithm returns the number of nodes of a given SWC type (e.g., axon, basal dendrite, etc).

##### parent_daughter_ratio

Average ratio of parent to daughter radius for all bifurcations. Specifically, this is the ratio of each branching node's radius (a node with >1 child) to each of its children's radius is calculated, and the average of all of these values is returned.

Different than V3D (~20%). Reason unknown.

##### mean_fragmentation

Fragmentation is the number of compartments between branch point and branch point, or branch point and tip (call this a "non-soma segment"). Mean fragmentation is the average of this value for all branch points. Specifically, the number of compartments in all non-soma segments is summed, and this is divided by the number of non-soma segments.

Different than V3D (~10%). Reason as yet unknown. Suspect V3D counts soma as bifurcation. L-Measure defines fragmentatino based on branch points (bif-bif and bif-tip). Manual count ofcompartments and branches match with new library

##### bifurcation_angle_local

The mean angle between child compartments at all bifurcations.

Different than V3D (~1%). Reason unknown. Manual examination of bifurcations gives quantitative match to new library

##### bifurcation_angle_remote

The mean angle between the next bifurcation or neurite tip as measured at each bifurcation.

Different than V3D (~1%). Reason unknown. Manual examination of bifurcations gives quantitative match to new library

##### soma_surface

The approximate area of the soma surface. This is 4 * PI * radius^2.

Matches V3D

##### average_diameter

The average diameter of all non-soma nodes.

Matches V3D

##### total_surface

Total surface area of all non-soma compartments. This is the sum of 2 * PI * radius for all non-soma compartments in the morphology.

Different than V3D. Difference appears to come from V3D calculating the surface of the soma, and the surface of each soma stem (ie, from soma node to the first dendrite node)

##### total_volume

The sum of π(Lr21+L(r2−r1)+L(r2−r1)2) for all compartments, where L is the length of the compartment and r1,r2 are the radii at each end of the compartment.

Different than V3D. Half of difference possibly explained by V3D inclusion of axon segments. Remaining half possibly explained by inclusion of stem compartments (ie, compartments from soma center to dendrite start)

### Derived features

##### neurites_over_branches

Highly correlated or equivalent to fragmentation?

num_neurites / num_branches

##### bifurcation_centroid_over_distance

first_bifurcation_moment_x / width

first_bifurcation_moment_y / height

first_bifurcation_moment_z / depth

##### compartment_centroid_over_distance

first_compartment_moment_x / width

first_compartment_moment_y / height

first_compartment_moment_z / depth

##### bifurcation_variance_over_distance

second_bifurcation_moment_x / width

second_bifurcation_moment_y / height

second_bifurcation_moment_z / depth

##### compartment_variance_over_distance

second_compartment_moment_x / width

second_compartment_moment_y / height

second_compartment_moment_z / depth

##### bifurcation_centroid_over_stdev

first_bifurcation_moment / sqrt(second_bifurcation_moment)

##### compartment_centroid_over_stdev

first_compartment_moment / sqrt(second_compartment_moment)

### New features

##### num_outer_bifurcations

Number of bifurcations (branch points) that exist in the outer region of a tree or trees. To calculate this, define a sphere with the soma at center that has a radius of the node furthest from the soma. Define a second sphere with the center at the soma that has half the radius of the first sphere. Num_outer_bifs is the number of bifurcations in the first sphere that are not in the second (ie, the number of bifurcations that lie outside the second sphere).

early_branch

The ratio of the largest 'short branch' length to the maximum path length. A short branch is the smaller of branches, as measured by max path length, coming from a single bifurcation point. Values near 1.0 occur when a stem branches near the soma and both branches from that bifurcation point are of similar max path length.