-
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
Implement missing restore feature for RandomGhosting #1211
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1211 +/- ##
==========================================
- Coverage 84.77% 84.64% -0.13%
==========================================
Files 92 92
Lines 6023 6026 +3
==========================================
- Hits 5106 5101 -5
- Misses 917 925 +8 ☔ View full report in Codecov by Sentry. |
@romainVala @sravan953 I've implemented the feature as expected, but I'm not sure it's very useful. What do you think? Here's an example: from itertools import product
import numpy as np
import torchvision.transforms as T
from PIL import Image
from torchvision.utils import make_grid
import torchio as tio
t1 = tio.datasets.FPG().t1
t1 = tio.ToCanonical()(t1)
restores = None, 0.1, 0.25, 0.5, 0.75
intensities = 0.25, 0.5, 0.75, 1
images = {}
t1_slice = t1.data[0, :, :, t1.shape[2] // 2].float()
min_data, max_data = t1_slice.data.min(), t1_slice.data.max()
for intensity, restore in product(intensities, restores):
print(f'intensity={intensity}, restore={restore}')
if restore is None:
restore_ = None
else:
restore_ = restore, restore
transform = tio.Ghosting(
num_ghosts=2,
intensity=intensity,
restore=restore,
axis=1,
)
transformed = transform(t1)
t1_slice = transformed.data[0, :, :, transformed.shape[2] // 2].float()
t1_slice = (t1_slice - min_data) / (max_data - min_data) * 255
# t1_slice = (t1_slice - t1_slice.min()) / (t1_slice.max() - t1_slice.min()) * 255
array = t1_slice.clamp(0, 255).numpy().astype('uint8')
array = np.rot90(array)
image = Image.fromarray(array)
images[intensity, restore] = image
images_list = list(images.values())
images_list = [T.ToTensor()(image) for image in images_list]
grid = make_grid(images_list, nrow=len(restores))
T.ToPILImage()(grid) |
Hi thanks Fernando for a quick fix (and nice plot !) It is not clear to me how "physical" in this implementation of MRI ghosting effect So difficult to say if (from a physical point of view) one should keep this parameter But from a visual point of view, this restore parameter make sense (it remove the low frequency part of the ghost, ) and so it produce more variability of the artefact So I think it is good to keep ! many thanks |
@allcontributors please add @sravan953 for bug |
I've put up a pull request to add @sravan953! 🎉 |
Fixes #1196.
Description
As reported by @sravan953, the
restore
argument inRandomGhosting
is unused. This PR addresses this issue.Checklist
CONTRIBUTING
docs and have a developer setup (especially important arepre-commit
andpytest
)pytest
make html
inside thedocs/
folder