Add support to invert RescaleIntensity transform #998
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #993 .
Description
The RescaleIntensity Tranasform constitutes a min-max transformation, which is easily reversible. As a result, the class attribute
self.invert_transform
is added and the functionrescale
is touched slightly in order to revert the transformation.As it would be helpful for the user to have access to the class attribute
self.in_min_max
(and the respectivein_min
,in_max
), the respective attributes are added.Known Issues
I checked the reversibility of the transform. If the resulting
torch.Tensor
after applyingtransform
andtransform.inverse()
to a random input vector, a difference between input and output tensor results. I assume this originates from rounding issues between int and float. If the output tensor is kept as afloat
, the difference is6.2028e-07
per pixel (max:3.8147e-06
min:3.8147e-06
) for a4x64x64x64
tensor. If the output tensor is casted toint
, the difference becomes0.2465
(max:1.
min:0.
)Checklist
CONTRIBUTING
docs and have a developer setup (especially important arepre-commit
andpytest
)pytest
make html
inside thedocs/
folder