Pytorch 3d augmentation

Dear all, I would like to do some augmentation on my 3d cube from mri.
I want to use TORCHVISION.TRANSFORMS but I start using numpy array.
I try to use

transformations = transform_train = transforms.Compose([
                                    
                                      transforms.ToPILImage(),
                                      transforms.RandomHorizontalFlip(),
                                      transforms.ToTensor(),
                                      
                               ])

Any suggestion? thanks so much for any help

torchvision.transforms.ToPILImage might not work for MRI data directly, but @christianperone has written some transformation for medical data in the medical torch repo, which might be useful.

1 Like

Hey @bioinfo-dirty-jobs,

You can use the transforms in TorchIO:

import torchio.transforms as transforms

transformations = transform_train = transforms.Compose([
    transforms.ToCanonical(),
    transforms.RandomFlip(),
])
1 Like