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 distance transform #57

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

✨🔨 add distance transform #57

wants to merge 6 commits into from

Conversation

dyollb
Copy link
Owner

@dyollb dyollb commented Dec 6, 2022

What do these changes do?

  • ✨this PR adds DistanceTransform transform to compute (boundary) distance. The boundary distance can be used to compute a boundary/distance loss.
  • ✨ a BoundaryLoss was added, which uses pre-computed distances from the boundary of the ground truth masks to compute how dissimilar (far) the predicted masks are.
  • 🔨 transforms were moved to a new submodule transforms

The boundary loss currently integrates (sum) over boundary deviation (XOR(A_gt, A_pred)), see b):

image

While the pre-computation is on the CPU (using scipy.ndimage.distance_transform_cdt), the loss is evaluated using simple operations using torch.Tensors.

Related issue/s

How to test

The distance transform is tested in tests/transforms/test_distance.py.

The boundary loss should be tested

  • on GPU
  • and in use, i.e. run training

Checklist

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Unit tests for the changes and run locally with the command pytest tests
  • Runs on minimum Python version

@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #57 (dc79f5f) into main (9e176d7) will increase coverage by 1.36%.
The diff coverage is 67.88%.

@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
+ Coverage   53.90%   55.27%   +1.36%     
==========================================
  Files          20       22       +2     
  Lines        1228     1328     +100     
  Branches      218      237      +19     
==========================================
+ Hits          662      734      +72     
- Misses        530      545      +15     
- Partials       36       49      +13     
Flag Coverage Δ
unittests 55.27% <67.88%> (+1.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/segmantic/transforms/detect.py 74.21% <ø> (ø)
src/segmantic/transforms/ensemble.py 100.00% <ø> (ø)
src/segmantic/transforms/io.py 86.30% <ø> (ø)
src/segmantic/seg/monai_unet.py 20.77% <50.00%> (+0.12%) ⬆️
src/segmantic/seg/boundary_loss.py 52.08% <52.08%> (ø)
src/segmantic/transforms/distance.py 81.35% <81.35%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dyollb dyollb changed the title ✨ add distance transform ✨🔨 add distance transform Dec 7, 2022
Copy link
Collaborator

@Konohana0608 Konohana0608 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thank you for this. Will try to use it as soon as the cross-validation with the new bone masks is done~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants