MONAI icon indicating copy to clipboard operation
MONAI copied to clipboard

Implementation of boundary-aware ShapeLoss

Open arnauddhaene opened this issue 3 years ago • 6 comments

Signed off by: Arnaud Dhaene [email protected]

Fixes #4204

Description

An implementation of a slight variation of the boundary-aware ShapeLoss described in Huang et al., 2021.

Status

Work in progress: the feature has been implemented, but unit testing needs to be added.

Types of changes

  • [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).
  • [ ] 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.

arnauddhaene avatar Apr 29 '22 17:04 arnauddhaene

Hi @arnauddhaene, thanks for this PR. It will be very useful for the community, as distance transform losses do generally improve HD and Dice. I have a doubt though, I see in code there is distance tranform being calculated in numpy. If that is the case, how will the backpropagation work in the training?

Bala93 avatar May 06 '22 13:05 Bala93

Hi @Bala93, thank you!

We do not need to backprop on the distance transform. We are in essence transforming the ground truth to a non-binary mask that will penalize the network for boundary misclassification.

The result of the transform is compared to the logits produced by the network, and the difference is used as loss to update the network's weights via backprop.

In fact, the distance_maps for each example could be computed once before training as auxiliary ground truth mask to prevent duplicate computations and speed up training. However, doing this doesn't fit as nicely in the MONAI framework and also is not robust to train-time augmentations that can modify the ground truth mask (elastic transform, rotation, etc.).

I hope this answers your question.

arnauddhaene avatar May 06 '22 14:05 arnauddhaene

Hi @arnauddhaene, is there any more progress on this PR so far, do you plan to finish this one? Thanks!

KumoLiu avatar Nov 09 '23 06:11 KumoLiu

Why no use distance_transform_edt from monai.transforms that use cupy/cucim with GPU instead slow CPU scipy? Can add PR if someone want.

dimka11 avatar Apr 03 '24 11:04 dimka11