Skip to content

Commit

Permalink
Fix parition_asymmetry Uylings to not throw for bifurcations with lea…
Browse files Browse the repository at this point in the history
…ves (#1001)
  • Loading branch information
eleftherioszisis authored Mar 14, 2022
1 parent 127d6fd commit f57feb2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ Changelog

Version 3.2.0
-------------

- Fix ``neurom.features.bifurcation.partition_asymmetry`` Uylings variant to not throw
for bifurcations with leaves.
- Fix ``neurom.features.neurite.principal_direction_extents`` to remove duplicate points
when calculated.
- Add ``neurom.features.morphology.volume_density`` feature so that it is calculated
correctly when the entire morphology is taken into account instead of summing the per
neurite volume densities.
- Add support for py39 and py310 testing.
- Fix ``neurom.features.morphology.sholl_frequency`` to return an empty list when a
neurite_type that is not present in the morphology is specified.
- Fix ``neurom.features.morphology.trunk_origin_radii`` to warn and use only the root
Expand Down
13 changes: 7 additions & 6 deletions neurom/features/bifurcation.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ def partition_asymmetry(bif_point, uylings=False):

n = float(sum(1 for _ in bif_point.children[0].ipreorder()))
m = float(sum(1 for _ in bif_point.children[1].ipreorder()))
c = 0
if uylings:
c = 2
if n + m <= c:
raise NeuroMError('Partition asymmetry cant be calculated by Uylings because the sum of'
'terminal tips is less than 2.')

if n == m == 1:
# By definition the asymmetry A(1, 1) is zero
return 0.0

c = 2.0 if uylings else 0.0

return abs(n - m) / abs(n + m - c)


Expand Down
3 changes: 1 addition & 2 deletions tests/features/test_bifurcation.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def test_partition_asymmetry():
assert bf.partition_asymmetry(root) == 0.5
assert bf.partition_asymmetry(root.children[0]) == 0.0
assert bf.partition_asymmetry(root, True) == 1.0
with pytest.raises(NeuroMError, match='Uylings'):
bf.partition_asymmetry(root.children[0], True)
assert bf.partition_asymmetry(root.children[0], True) == 0.0

leaf = root.children[0].children[0]
assert_raises(NeuroMError, bf.partition_asymmetry, leaf)
Expand Down

0 comments on commit f57feb2

Please sign in to comment.