Nifti Inversion for ResizeWithPadOrCrop shows error #8037
Rubaida001
started this conversation in
General
Replies: 1 comment 5 replies
-
Hi @Rubaida001,
You can refer to this tutorial for more details about how to using invert: https://github.com/Project-MONAI/tutorials/blob/main/3d_segmentation/spleen_segmentation_3d.ipynb Hope it helps, thanks. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I am currently working on harmonizing T1w MRI images. For the preprocessing step, I utilized the ResizeWithPadOrCrop function to resize the data. Following the harmonization process, I tried to convert the inferred image into subject space. I have attempted to use both the inverse and InvertD functions for this purpose, but unfortunately, none worked. I have checked multiple tutorials but none of the scripts run the InvertD function on previously saved datasets. Could you please help me to solve this problem?
The general steps I am following are as follows:
Here is the code with InvertD function for forward transform:
Inverse transform:
But I am getting following error:
`Traceback (most recent call last):
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/transform.py", line 141, in apply_transform
return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats)
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/transform.py", line 98, in _apply_transform
return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data)
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/utility/dictionary.py", line 464, in inverse
self.pop_transform(d, key)
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/inverse.py", line 338, in pop_transform
return self.get_most_recent_transform(data, key, check, pop=True)
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/inverse.py", line 320, in get_most_recent_transform
self.check_transforms_match(all_transforms[-1])
IndexError: list index out of range
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/transform.py", line 141, in apply_transform
return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats)
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/transform.py", line 98, in _apply_transform
return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data)
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/post/dictionary.py", line 715, in call
inverted = self.transform.inverse(input_dict)
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/compose.py", line 364, in inverse
data = apply_transform(
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/transform.py", line 171, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <bound method ToTensord.inverse of <monai.transforms.utility.dictionary.ToTensord object at 0x7fe456d95a00>>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/data/project/PSY_SHARED/HARMONISATION_PROCESSING/CycleGAN/Python/cyclegan/preprocessing/inverse-1.py", line 97, in
inverse_transform(output_dir)
File "/data/project/PSY_SHARED/HARMONISATION_PROCESSING/CycleGAN/Python/cyclegan/preprocessing/inverse-1.py", line 76, in inverse_transform
inverted_data = inverse_transform(batch_data)
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/compose.py", line 335, in call
result = execute_compose(
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/compose.py", line 111, in execute_compose
data = apply_transform(
File "/home/k2031007/.local/lib/python3.9/site-packages/monai/transforms/transform.py", line 171, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.post.dictionary.Invertd object at 0x7fe26c743af0>
`
Beta Was this translation helpful? Give feedback.
All reactions