From d94b1c8ca9c91deeb83aaaa3490033de96a58808 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Mon, 25 Apr 2022 15:36:34 +0200 Subject: [PATCH] Make fork iterators homogeneous --- neurom/core/morphology.py | 4 ++-- neurom/features/neurite.py | 16 +--------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/neurom/core/morphology.py b/neurom/core/morphology.py index f5b2146b..0826ca4b 100644 --- a/neurom/core/morphology.py +++ b/neurom/core/morphology.py @@ -81,11 +81,11 @@ def is_homogeneous_point(self): def is_forking_point(self): """Is this section a forking point?""" - return len(self.children) > 1 + return self.is_homogeneous_point() and len(self.children) > 1 def is_bifurcation_point(self): """Is tree a bifurcation point?""" - return len(self.children) == 2 + return self.is_homogeneous_point() and len(self.children) == 2 def is_leaf(self): """Is tree a leaf?""" diff --git a/neurom/features/neurite.py b/neurom/features/neurite.py index 7c972779..296f1c94 100644 --- a/neurom/features/neurite.py +++ b/neurom/features/neurite.py @@ -64,21 +64,7 @@ def _map_sections(fun, neurite, iterator_type=Section.ipreorder, section_type=NeuriteType.all): """Map `fun` to all the sections.""" - check_type = is_type(section_type) - - def homogeneous_filter(section): - return check_type(section) and Section.is_homogeneous_point(section) - - # forking sections cannot be heterogeneous - if ( - iterator_type in {Section.ibifurcation_point, Section.iforking_point} - and section_type != NeuriteType.all - ): - filt = homogeneous_filter - else: - filt = check_type - - return list(map(fun, filter(filt, iterator_type(neurite.root_node)))) + return list(map(fun, filter(is_type(section_type), iterator_type(neurite.root_node)))) @feature(shape=())