Skip to content

Commit

Permalink
Use soma center in sholl_frequency distance calculation (#989)
Browse files Browse the repository at this point in the history
Calculate the distance of the morphology points to the soma, instead to (0,0,0)
eleftherioszisis authored Feb 25, 2022
1 parent e31eb63 commit b6c3beb
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions neurom/features/morphology.py
Original file line number Diff line number Diff line change
@@ -478,8 +478,10 @@ def sholl_frequency(morph, neurite_type=NeuriteType.all, step_size=10, bins=None

if bins is None:
min_soma_edge = morph.soma.radius
max_radii = max(np.max(np.linalg.norm(n.points[:, COLS.XYZ], axis=1))
for n in morph.neurites if neurite_filter(n))
max_radii = max(
np.max(np.linalg.norm(n.points[:, COLS.XYZ] - morph.soma.center, axis=1))
for n in morph.neurites if neurite_filter(n)
)
bins = np.arange(min_soma_edge, min_soma_edge + max_radii, step_size)

return sholl_crossings(morph, neurite_type, morph.soma.center, bins)
11 changes: 11 additions & 0 deletions tests/features/test_get_features.py
Original file line number Diff line number Diff line change
@@ -706,6 +706,17 @@ def test_sholl_frequency():
assert len(features.get('sholl_frequency', POP)) == 108


# check that the soma is taken into account for calculating max radius and num bins
m = nm.load_morphology(
"""
1 1 -10 0 0 5.0 -1
2 3 0 0 0 0.1 1
3 3 10 0 0 0.1 2
""", reader="swc",
)

assert features.get('sholl_frequency', m, step_size=5.0) == [0, 1, 1, 1]

def test_bifurcation_partitions():
assert_allclose(features.get('bifurcation_partitions', POP)[:10],
[19., 17., 15., 13., 11., 9., 7., 5., 3., 1.])

0 comments on commit b6c3beb

Please sign in to comment.