Downloading https://github.com/fepegar/torchio-data/raw/main/data/fernando/t1.nii.gz to /home/docs/.cache/torchio/fpg/t1.nii.gz
0it [00:00, ?it/s]
0%| | 0/10860389 [00:00<?, ?it/s]
10862592it [00:00, 11772330.13it/s]
Downloading https://github.com/fepegar/torchio-data/raw/main/data/fernando/t1_seg_gif.nii.gz to /home/docs/.cache/torchio/fpg/t1_seg_gif.nii.gz
0it [00:00, ?it/s]
0%| | 0/544126 [00:00<?, ?it/s]
548864it [00:00, 1127733.10it/s]
Downloading https://github.com/fepegar/torchio-data/raw/main/data/fernando/t1_to_mni.tfm to /home/docs/.cache/torchio/fpg/t1_to_mni.tfm
0it [00:00, ?it/s]
0%| | 0/329 [00:00<?, ?it/s]
8192it [00:00, 24214.70it/s]
Downloading https://github.com/fepegar/torchio-data/raw/main/data/fernando/t1_to_mni_affine.h5 to /home/docs/.cache/torchio/fpg/t1_to_mni_affine.h5
0it [00:00, ?it/s]
0%| | 0/8392 [00:00<?, ?it/s]
16384it [00:00, 39417.56it/s]
def __call__(self, subject):
# We'll assume all images in the subject have the same spacing
sx, sy, _ = subject.spacing
resample = tio.Resample((sx, sy, self.spacing_z))
resampled = resample(subject)
return resampled
torch.manual_seed(42)
image = tio.datasets.FPG().t1
transforms = tio.ToCanonical(), ResampleZ(spacing_z=7)
transform = tio.Compose(transforms)
transformed = transform(image)
subject = tio.Subject(original=image, transformed=transformed)
subject.plot()
Total running time of the script: (0 minutes 3.892 seconds)
Download Jupyter notebook: plot_custom_z_spacing.ipynb
Download Python source code: plot_custom_z_spacing.py
Download zipped: plot_custom_z_spacing.zip
Gallery generated by Sphinx-Gallery