Data Agumentation in 3D images

Hi all
I have a question regarding data augmentation in 3D images in PyTorch. I found nice methods like Colorjitter, RandomResziedCrop, and RandomGrayscale in documentations of PyTorch, and I am interested in using them for 3D images. As far as I understood these methods can be applied only on 2D images (correct me if I am wrong). So, if I want to use them in 3D setting, one solution is converting 3D images to Numpy arrays and then writing custom transformation in PyTorch using skimage or scipy am I right? I would appreciate it if you can help me with your ideas.

Best

MONAI as well as torchio provide some transformations for 3D images from the medical domain (where these types of images are often used).

CC @MONAI and @fepegar for more information on these libs.

This would work, if skimage and scipy support 3D images (I’m not familiar with 3D data processing using these libs, so you would have to double check it).

1 Like

Hi Mjavan, thanks for the heads-up, @ptrblck.

Here’s a list of the transforms included in TorchIO. I’m happy to add some more transforms that you may need. Are you working with 3D grayscale images or RGB?

You can do some low-level stuff with skimage and scipy, but I think you’d be better off using a higher-level library. In this skimage issue, a member of the developers team points a user to TorchIO.

I’m working with the MONAI team so that TorchIO transforms can be used within their library, but this is not ready yet.

2 Likes

Hi @ptrblck and thank you @fepegar.
I am working with 3D medical images that are Grayscale.
I looked at TorchIO and your nice effort there. I need RandomResizedCrop, that gives me the original size of the image after cropping. This transformation in PyTorch crops the image with an aspect ratio [0.08,1]. I found Crop in TorchIO without resizing to the original image, or the capability of accepting any aspect ratio. I googled it in the net and I found that it is difficult to define aspect ratio in 3D space. Would it be possible to add these two parameters to Crop in TorchIO. I have also a question about the type of inputs for transformations in TorchIO. Dose it support both 4D Torch tensor and Numpy? Would it be possible that in TorchIO we have Colorjitter like transformation that we have in pytorch. I am not sure how much difference it may make as images here are Grayscale, but still I like to try it.
Thanks again for your help.

I think it’s best to move this to the TorchIO GitHub, I hope that’s ok: https://github.com/fepegar/torchio/issues/205

(I’ve replied to all your questions on GitHub.)

Thank you so much @fepegar.