so I have two modality paired images: MR and CT, each having 172x220x156 images of 20 subjects.
I am creating mask of the 3D data(based on intensity thresholding). Then in random permutation I am taking 500 center points inside the mask(so that I can avoid taking patches from outside the brain). Then I am cropping 32x32x32 patches from each of the 500 center points in both CT and MR images. To mention, MR is input and CT is ground truth.
Yes you are right, the codes I provided is for 2D network which I worked before by creating 156 2D image slices from 3D ones and that worked pretty well and I understood that as well too.
But is there anyway I can do the same method with 3D patches now?
So far I have created two list(MR and CT) of 3D patches from 18 train subjects(2 are for test).
for i in filenames_train:
    path_mr = os.path.join(dir_train,'MR',i)
    MR = nib.load(path_mr)
    MR = np.array(MR.dataobj)
    path_ct = os.path.join(dir_train, 'CT', i)
    CT = nib.load(path_ct)
    CT = np.array(CT.dataobj)
    path_mask = os.path.join(dir_train, 'masks', i)
    mask = nib.load(path_mask)
    mask = np.array(mask.dataobj)

    X, y = get_paired_patch_3D(MR,CT,mask,num_centers=500,patchsize=32)

    patches_MR.append(X)
    patches_CT.append(y)

print(np.shape(patches_MR)) #(18, 500, 32, 32, 32)
print(np.shape(patches_CT)) #(18, 500, 32, 32, 32)
I will be using k-fold cross-validation and 3D UNet to synthesize CT images from MR.
Thanks for reply. Please let me know to clarify more if required.