-
Notifications
You must be signed in to change notification settings - Fork 240
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
Fix RescaleIntensity
#1116
Fix RescaleIntensity
#1116
Conversation
@nicoloesch I added a test that fails on purpose to keep track of the bug fix. It's the codebase that needs fixing, not the test :) |
I will be working on it! (Hopefully you can assign it to me now as I commented :) ) |
@romainVala I am commenting on your comment of the original issue in #1115 : Storing the For explanation: if you scale both |
I have made the changes as initially proposed in #1115 but the test is still failing. The reason behind it is that The question now is how we want that transform to behave? The alternative to the current mechanism proposed by me would be to only allow the transform to be inversible if, and only if, The current test still assumes we are obtaining the Looking forward to your thoughts @fepegar (and @mueller-franzes)! |
@nicoloesch thanks for your thoughts and efforts to solve the problem!
But maybe this solution would complicate things unnecessarily instead of simply disabling the inverse. What do you think? |
@nicoloesch let me resume my proposition
So with this code
So I agree rescale can not more be used to invert suj1, but if you take instead the rescale transform from suj1.history, then it will contain the proper parameter you need to do the invertion Now this have a limited interest, because there is one case where it will not work, if instead of using two distinct subject you use one subject with 2 image ('img1' and 'img2') This is because torchio assume the same transform is applied to all image of a subject, but this is not the most used case for this transform ... I guess one could find a work around (like storing a different data_in_max attribute with the name of the image it has been applied to, or storing a dict) .
Now one would get but this become a bit handy, just to keep the inversion property ... Although I do not use it often I like this feature. Note that we also loose history with correct parameter So I do understand you prefer the simplest solution and remove set is_invertible to False |
I did not see your answer, before posting mine, but it looks similar to what I proposed ... no ? About Resample, it is not invertible, so not the same case that with rescaling |
The original motivation (#993) for making this transform invertible was
Maybe we don't really need this feature? |
@fepegar The issue of #1115 will then remain as #993 only added the option to reverse the transformation if if I remember correctly. The codebase prior to #993 and to this date still automatically retrieves the scaling factors and stores them. So the question about how to handle the situation where |
From MRI point of view, the second choice : we should scale all images based on min max found in the images. The first option to scale with the first encounter image is quite a bug |
@romainVala I agree with your thoughts. I would therefore suggest that we provide the option of |
I've pushed some changes I made when I was trying this stuff in #1120. Can you please take a look? |
* Make RescaleIntensity non-invertible again * Disable support to invert RescaleIntensity
|
@all-contributors please add @nicoloesch @romainVala @mueller-franzes for bug |
I've put up a pull request to add @nicoloesch! 🎉 |
@all-contributors please add @romainVala and @mueller-franzes for bug |
I've put up a pull request to add @romainVala! 🎉 |
@all-contributors please add @mueller-franzes for bug |
I've put up a pull request to add @mueller-franzes! 🎉 |
Fixes #1115.
Description
Buf reported in #1115 by @mueller-franzes.
Checklist
CONTRIBUTING
docs and have a developer setup (especially important arepre-commit
andpytest
)pytest
make html
inside thedocs/
folder