Skip to content

Commit

Permalink
Fix deprecation warning in boundary.py (#2)
Browse files Browse the repository at this point in the history
* Fix DeprecationWarning in boundary.py

* Fix workflow trigger

* Increment version
  • Loading branch information
kostrykin authored Feb 22, 2024
1 parent 8715433 commit 03e2ecf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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

0 comments on commit 03e2ecf

Please sign in to comment.