Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warning in boundary.py #2

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

paths:
- .github/workflows/testsuite.yml
- segmetrics
- segmetrics/*.py
- setup.py
- tests/*.py
- tests/*.csv
Expand Down
2 changes: 1 addition & 1 deletion segmetrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

VERSION_MAJOR = 1
VERSION_MINOR = 4
VERSION_PATCH = 0
VERSION_PATCH = 1

VERSION = '%d.%d%s' % (VERSION_MAJOR, VERSION_MINOR, '.%d' % VERSION_PATCH if VERSION_PATCH > 0 else '')

8 changes: 4 additions & 4 deletions segmetrics/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _compute_binary_boundary(mask, width=1):

def _compute_boundary_distance_map(mask):
boundary = _compute_binary_boundary(mask)
return ndimage.morphology.distance_transform_edt(np.logical_not(boundary))
return ndimage.distance_transform_edt(np.logical_not(boundary))


def _quantile_max(quantile, values):
Expand Down Expand Up @@ -72,15 +72,15 @@ def __init__(self, mode='sym', quantile=1, **kwargs):

def set_expected(self, expected):
self.expected_boundary = _compute_binary_boundary(expected > 0)
self.expected_boundary_distance_map = ndimage.morphology.distance_transform_edt(np.logical_not(self.expected_boundary))
self.expected_boundary_distance_map = ndimage.distance_transform_edt(np.logical_not(self.expected_boundary))

def compute(self, actual):
actual_boundary = _compute_binary_boundary(actual > 0)
if not self.expected_boundary.any() or not actual_boundary.any(): return []
results = []
if self.mode in ('a2e', 'sym'): results.append(self._quantile_max(self.expected_boundary_distance_map[actual_boundary]))
if self.mode in ('e2a', 'sym'):
actual_boundary_distance_map = ndimage.morphology.distance_transform_edt(np.logical_not(actual_boundary))
actual_boundary_distance_map = ndimage.distance_transform_edt(np.logical_not(actual_boundary))
results.append(self._quantile_max(actual_boundary_distance_map[self.expected_boundary]))
return [max(results)]

Expand All @@ -107,7 +107,7 @@ class NSD(DistanceMeasure):
def set_expected(self, expected):
self.expected = (expected > 0)
self.expected_boundary = _compute_binary_boundary(self.expected)
self.expected_boundary_distance_map = ndimage.morphology.distance_transform_edt(np.logical_not(self.expected_boundary))
self.expected_boundary_distance_map = ndimage.distance_transform_edt(np.logical_not(self.expected_boundary))

def compute(self, actual):
actual = (actual > 0)
Expand Down