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

Add spacing to surface distances calculations #6137

Closed
gasperpodobnik opened this issue Mar 13, 2023 · 0 comments · Fixed by #6144
Closed

Add spacing to surface distances calculations #6137

gasperpodobnik opened this issue Mar 13, 2023 · 0 comments · Fixed by #6144

Comments

@gasperpodobnik
Copy link
Contributor

Is your feature request related to a problem? Please describe.
The current implementation of Hausdorff distance and other surface distance metrics only works for images with isotropic spacing.

Describe the solution you'd like
Consider adding a new parameter spacing to the metric call in order to pass it as sampling=spacing to both distance_transform_edt and distance_transform_cdt functions inside the get_surface_distance function (

def get_surface_distance(seg_pred: np.ndarray, seg_gt: np.ndarray, distance_metric: str = "euclidean") -> np.ndarray:
). This will allow users to specify the voxel spacing during distance transform computation, which can be useful for handling different image resolutions.
The same is done in DeepMind's implementation (https://github.com/deepmind/surface-distance/blob/master/surface_distance/metrics.py#L254).

wyli pushed a commit that referenced this issue Apr 12, 2023
Fixes #6137 .

### Description

A user can now pass a `spacing` parameter to surface distance metrics
(Hausdorff distance, surface distance, surface dice), so that correct
results can be obtained for images with non-isotropic spacing (e.g.
(0.5, 0.5, 2) mm).
If `spacing` is a sequence, it must be of length equal to the image
dimensions; if a single number, this spacing is used for all axes. If
``None``, spacing of unity is used. Defaults to ``None``so that current
behaviour is preserved.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: gasperp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants