-
I have a dataset of 3D images of difference spacings. In an augmentation pipeline, I need to apply a resample transform such that the x&y spacing is the same as input and the z spacing is resampled to 3 mm, like tio.Resample([img.spacing[0], img.spacing[1], 3]). Can this be achieved in torchio? transforms = tio.Compose([tio.Resample(img.spacing[0], img.spacing[1], 3)]) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, @rhan93. You could create your own transform for this: import torchio as tio
class ResampleZ:
def __init__(self, sz):
self.sz = sz
def __call__(self, subject):
sx, sy, _ = subject.spacing
resample = tio.Resample((sx, sy, self.sz))
resampled = resample(subject)
return resampled
image = tio.datasets.FPG().t1
transforms = tio.RandomBlur(), ResampleZ(4)
transform = tio.Compose(transforms)
transformed = transform(image) |
Beta Was this translation helpful? Give feedback.
Hi, @rhan93. You could create your own transform for this: