Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 623cbd9

Browse files
Return nan if no points in shape features (#1018)
1 parent ed518c4 commit 623cbd9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

neurom/features/morphology.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def aspect_ratio(morph, neurite_type=NeuriteType.all, projection_plane="xy"):
643643
The aspect ratio feature of the morphology points.
644644
"""
645645
projected_points = _unique_projected_points(morph, projection_plane, neurite_type)
646-
return [] if len(projected_points) == 0 else morphmath.aspect_ratio(projected_points)
646+
return np.nan if len(projected_points) == 0 else morphmath.aspect_ratio(projected_points)
647647

648648

649649
@feature(shape=())
@@ -663,7 +663,7 @@ def circularity(morph, neurite_type=NeuriteType.all, projection_plane="xy"):
663663
The circularity of the morphology points.
664664
"""
665665
projected_points = _unique_projected_points(morph, projection_plane, neurite_type)
666-
return [] if len(projected_points) == 0 else morphmath.circularity(projected_points)
666+
return np.nan if len(projected_points) == 0 else morphmath.circularity(projected_points)
667667

668668

669669
@feature(shape=())
@@ -683,4 +683,4 @@ def shape_factor(morph, neurite_type=NeuriteType.all, projection_plane="xy"):
683683
The shape factor of the morphology points.
684684
"""
685685
projected_points = _unique_projected_points(morph, projection_plane, neurite_type)
686-
return [] if len(projected_points) == 0 else morphmath.shape_factor(projected_points)
686+
return np.nan if len(projected_points) == 0 else morphmath.shape_factor(projected_points)

tests/features/test_get_features.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ def test_aspect_ratio():
916916
0.731076,
917917
decimal=6
918918
)
919+
assert np.isnan(features.get("aspect_ratio", morph, neurite_type=nm.NeuriteType.custom5))
919920

920921

921922
def test_circularity():
@@ -942,6 +943,7 @@ def test_circularity():
942943
0.730983,
943944
decimal=6
944945
)
946+
assert np.isnan(features.get("circularity", morph, neurite_type=nm.NeuriteType.custom5))
945947

946948

947949
def test_shape_factor():
@@ -968,3 +970,4 @@ def test_shape_factor():
968970
0.364678,
969971
decimal=6
970972
)
973+
assert np.isnan(features.get("shape_factor", morph, neurite_type=nm.NeuriteType.custom5))

0 commit comments

Comments
 (0)