Skip to content

Commit

Permalink
Rename duplicated points into overlapping points
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet committed Apr 17, 2024
1 parent 8561c50 commit 19c4c44
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions neurom/check/morphology_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import numpy as np
from neurom import NeuriteType
from neurom.check import CheckResult
from neurom.check.morphtree import get_flat_neurites, back_tracking_segments, duplicated_points
from neurom.check.morphtree import get_flat_neurites, back_tracking_segments, overlapping_points
from neurom.core.morphology import Section, iter_neurites, iter_sections, iter_segments
from neurom.core.dataformat import COLS
from neurom.exceptions import NeuroMError
Expand Down Expand Up @@ -367,11 +367,11 @@ def has_no_back_tracking(morph):
return CheckResult(len(bad_ids) == 0, bad_ids)


def has_no_duplicated_point(morph, tolerance=None):
"""Check if the morphology has duplicated points."""
def has_no_overlapping_point(morph, tolerance=None):
"""Check if the morphology has overlapping points."""
bad_ids = [
(i[:2], np.atleast_2d(i[2]))
for neurite in iter_neurites(morph)
for i in duplicated_points(neurite, tolerance=tolerance)
for i in overlapping_points(neurite, tolerance=tolerance)
]
return CheckResult(len(bad_ids) == 0, bad_ids)
28 changes: 14 additions & 14 deletions neurom/check/morphtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,16 @@ def is_back_tracking(neurite):
return False


def duplicated_points(neurite, tolerance=None):
"""Return duplicated points of a neurite.
def overlapping_points(neurite, tolerance=None):
"""Return overlapping points of a neurite.
Args:
neurite(Neurite): neurite to operate on
tolerance(float): the tolerance used to find duplicated points
tolerance(float): the tolerance used to find overlapping points
Returns:
A generator of tuples containing the IDs of the two intersecting sections and the
duplicated point.
overlapping point.
"""
section_pts = np.vstack(
[
Expand All @@ -242,20 +242,20 @@ def duplicated_points(neurite, tolerance=None):
)


def has_duplicated_points(neurite, tolerance=None):
"""Check if a neurite has at least one duplicated point.
def has_overlapping_points(neurite, tolerance=None):
"""Check if a neurite has at least one overlapping point.
See duplicated_points() for more details.
See overlapping_points() for more details.
Args:
neurite(Neurite): neurite to operate on
tolerance(float): the tolerance used to find duplicated points
tolerance(float): the tolerance used to find overlapping points
Returns:
True if two points of the neurite are duplicated.
True if two points of the neurite are overlapping.
"""
for _i in duplicated_points(neurite, tolerance=tolerance):
# If one duplicated point is found then the neurite is duplicating
for _i in overlapping_points(neurite, tolerance=tolerance):
# If one overlapping point is found then the neurite is overlapping
return True
return False

Expand Down Expand Up @@ -304,13 +304,13 @@ def get_back_tracking_neurites(morph):
return [n for n in morph.neurites if is_back_tracking(n)]


def get_duplicated_point_neurites(morph, tolerance=0):
"""Get neurites that have duplicated points.
def get_overlapping_point_neurites(morph, tolerance=0):
"""Get neurites that have overlapping points.
Args:
morph(Morphology): neurite to operate on
Returns:
List of morphologies with backtracks
"""
return [n for n in morph.neurites if has_duplicated_points(n, tolerance=tolerance)]
return [n for n in morph.neurites if has_overlapping_points(n, tolerance=tolerance)]
4 changes: 2 additions & 2 deletions tests/check/test_morphology_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def test_has_no_back_tracking():
assert_array_equal(info[1][1], [[1, -3, 0]])


def test_has_no_duplicated_point():
def test_has_no_overlapping_point():
m = load_morphology("""
((CellBody) (-1 0 0 2) (1 0 0 2))
Expand All @@ -511,7 +511,7 @@ def test_has_no_duplicated_point():
(4 -6 0 0.2)
))
""", "asc")
result = morphology_checks.has_no_duplicated_point(m)
result = morphology_checks.has_no_overlapping_point(m)
assert result.status is False
info = result.info
assert_array_equal(info[0][0], [0, 2])
Expand Down
8 changes: 4 additions & 4 deletions tests/check/test_morphtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def test_get_back_tracking_neurites():
assert len(mt.get_back_tracking_neurites(m)) == 4


def test_get_duplicated_point_neurites():
def test_get_overlapping_point_neurites():
m = load_morphology(Path(SWC_PATH, 'Neuron.swc'))
assert len(mt.get_duplicated_point_neurites(m)) == 0
assert len(mt.get_duplicated_point_neurites(m, tolerance=0.09)) == 1
assert len(mt.get_duplicated_point_neurites(m, tolerance=999)) == 4
assert len(mt.get_overlapping_point_neurites(m)) == 0
assert len(mt.get_overlapping_point_neurites(m, tolerance=0.09)) == 1
assert len(mt.get_overlapping_point_neurites(m, tolerance=999)) == 4

0 comments on commit 19c4c44

Please sign in to comment.