How to slice 3D tensor to 2D slices and construct Dataloader

Hi, I have a 3D image, and I would like to slice it to coronal, axial and sagittal views, and train the CNN using these slices.
I’m wondering how to construct a dataloader in this situation. i.e How to slice this 3D image and construct the corresponding data class. Because In my understand, I need to iterate the slices when I construct the dataloader.


Have you checked this topic Train 3D Networks with Pytorch?

Hi, Yes, but as the data will be very large, so I prefer to slice the 3d data first

Have you solved this problem?
Since each 3D image is very large , I also need to choose some 2D slices from 3D image.
I think we can write the path of 2D slice and read them in __getitem() function…

Do you have another better solution??

hi, I just sliced them by the order of that annex. For example, if the 3d image is 128x256x512, in order to slice it in sagittal view, I sliced 512 times, so I got 512 128x256 images.

1 Like