-
Notifications
You must be signed in to change notification settings - Fork 230
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
New label transformations #402
Conversation
Preserve include and exclude lists for inverse transforms.
…low-custom-inversions
…l-transforms � Conflicts: � torchio/transforms/transform.py
Codecov Report
@@ Coverage Diff @@
## master #402 +/- ##
==========================================
- Coverage 92.42% 92.28% -0.15%
==========================================
Files 117 124 +7
Lines 5942 6103 +161
==========================================
+ Hits 5492 5632 +140
- Misses 450 471 +21
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I really appreciate the effort into the docs and the examples.
Why did you move the bounds stuff into Transform? I haven't seen it in the new transforms.
No worries, glad to contribute. The bounds code was moved to |
Ok, thanks. I've added some minor edits, will squash and merge once the tests are done. |
Available in |
Great! Thanks for your edits and continued support of this project. |
Implements #400.
Description
This implements new label transformations
RemapLabels
,SequentialLabels
,RemoveLabels
. Documentation and basic tests are included as well. Please let me know if anything should be improved or changed.Some extra methods were added to
TorchioTestCase
for easier testing of these new transformations.get_subject_with_labels(self, labels):
returns a subject with aLabelMap
which has the desired set oflabels
.get_unique_labels(self, label_map):
returns the set of unique labels in aLabelMap
, not including 0.A small fix to
Subject.apply_inverse_transform
. Just applied.clear_history()
to the subject after the inverse transformation.Moved everything related to
TypeBounds
, andTypeMaskingMethod
up to theTransform
class so they can be reused in the label transformations.Demonstration
Original labels:
![](https://user-images.githubusercontent.com/5416313/103230909-c7b96180-48f3-11eb-9343-e705df708d13.png)
Apply
![](https://user-images.githubusercontent.com/5416313/103230981-f1728880-48f3-11eb-8ae2-dd753fced758.png)
tio.RemoveLabels([1, 2, 17, 23, 24])
Apply
![](https://user-images.githubusercontent.com/5416313/103231061-267edb00-48f4-11eb-935c-d73bc92d39af.png)
tio.RemapLabels({4:3, 6:5, 10:9, 20:19, 22:21}, masking_method="Right")
Apply
![](https://user-images.githubusercontent.com/5416313/103231108-41514f80-48f4-11eb-9a7f-20473786e2d7.png)
tio.SequentialLabels()
Apply
![](https://user-images.githubusercontent.com/5416313/103231241-94c39d80-48f4-11eb-9e3b-d0ee3d6e3afe.png)
subject = subject.apply_inverse_transform()
Checklist
CONTRIBUTING
docs and have a developer setup (especially important arepre-commit
andpytest
)pytest
make html
inside thedocs/
folder