Closed fepegar closed 1 week ago
Attention: Patch coverage is 80.48780%
with 8 lines
in your changes missing coverage. Please review.
Project coverage is 84.64%. Comparing base (
7b7a732
) to head (9b8f119
). Report is 1 commits behind head on main.
Files with missing lines | Patch % | Lines |
---|---|---|
...ansforms/augmentation/intensity/random_ghosting.py | 80.48% | 8 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@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 (In EPI this is the phase difference from one line to an other that cause the ghosting)
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
@fepegar
I've put up a pull request to add @sravan953! :tada:
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