Hi, @Dhruv_Jain. As this is not a PyTorch question, you can just ask on the TorchIO GitHub Discussions next time: Discussions · fepegar/torchio · GitHub 1
There are many examples in the documentation showing how to do that. Here’s a snippet:
In [1]: import torchio as tio

In [2]: t1 = tio.ScalarImage('colin27_t1_tal_lin.nii.gz')

In [3]: brain = tio.LabelMap('colin27_t1_tal_lin_mask.nii.gz')

In [4]: subject = tio.Subject(t1=t1, seg=brain)

In [5]: transform = tio.RandomAffine()

In [6]: transformed = transform(subject)

In [7]: subject.plot()

In [8]: transformed.plot()


Figure_11280×960 122 KB


Figure_21280×960 119 KB

As you see, the same transformation is applied to both images. Linear and nearest neighbor interpolation are used by default for the MRI and the label map, respectively.