3D Augmentation on CBCT image and segmentation maps

Hi,

I am trying to implement 3d augmentation on CBCT and the same augmentations on the 3d segmentation map. I am using the torchio library.

Preprocessing - TorchIO

spatial = tio.OneOf({
       tio.RandomElasticDeformation(): 0.4,
       tio.RandomAffine( degrees=10,  translation = 5): 0.6
  },
   p=0.80,
  )

Can someone please help me out to apply the same transformation to the segmentation map too…
Thanks

PS: Hi @fepegar , Thanks for a wonderful library for 3d augmentations and preprocessing. Can you please help me out with this?

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

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()

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.

Thanks :slight_smile: I’ll take care for next time…