diff --git a/neurom/core/morphology.py b/neurom/core/morphology.py index 1431eda6..6852aeef 100644 --- a/neurom/core/morphology.py +++ b/neurom/core/morphology.py @@ -454,8 +454,10 @@ def subtree_types(self): subtree_types = [next(it).to_morphio().type] for section in it: - if section.type != section.parent.type: - subtree_types.append(NeuriteType(section.to_morphio().type)) + # A subtree can start from a single branch or as a fork of the same type from a parent + # with different type. + if section.type not in (section.parent.type, subtree_types[-1]): + subtree_types.append(section.to_morphio().type) return subtree_types diff --git a/tests/test_mixed.py b/tests/test_mixed.py index b3bed778..d06177ec 100644 --- a/tests/test_mixed.py +++ b/tests/test_mixed.py @@ -1140,3 +1140,26 @@ def test_sholl_frequency_pop(mixed_morph): 2, 0, ] + + +def test_axon_fork_as_axon_carrying_dendrite(): + """Test that a axon subtree starting as a fork is considered an AcD.""" + m = neurom.load_morphology( + """ + 1 1 0 0 0 0.5 -1 + 2 3 0 1 0 0.1 1 + 3 3 1 2 0 0.1 2 + 4 2 1 4 0 0.1 3 + 5 2 1 4 1 0.1 4 + 6 2 1 4 -1 0.1 4 + 7 2 2 3 0 0.1 3 + 8 2 2 4 0 0.1 7 + 9 2 3 3 0 0.1 7 + 10 2 3 3 1 0.1 9 + 11 2 3 3 -1 0.1 9 + """, + reader="swc", + process_subtrees=True, + ) + neurite = m.neurites[0] + assert neurite.type is NeuriteType.axon_carrying_dendrite