Resize nii images to make a training dataset

I have several nii images of different matrix and pixel sizes.
I would like to achieve that all the images have the same matrix dimensions and pixel size for creating a 3D volume as train dataset. For example, a matrix dimensions of 256x256 and a pixel size of 0.42x0.42.

My doubt is: are there some function to achieve it? Or maybe I should to normalize all the images to the same pixel size and then crop them to the same matrix dimensions?

Thank you very much!

1 Like

I would suggest you normalize all images - with tools like SPM12 you can specify both the bounding box and the resolution for replacing the data after a normalization. Whenever you reslice to a different resolution there is an opportunity for loss of high frequency signal (linear interpolation) or ringing (higher order interpolation).

If your images are coregistered, you can reslice them all using this routine, make sure to specify your preferred interpolation:


I have a few (afni, spm, wb_command) examples at MVPA Meanderings: Search results for resample.