I have some 3D nifti files of dimension (50, 100, 50). I would like to flip the the y and z axes so that the dimension will be (50, 50, 100). What is the best way to go about doing this and how would I modify the associated affine with the file?
Currently, I am making the nifti file into a numpy array and swapping the axes like so
array = np.asanyarray(niiobj.dataobj)
img_after_resample_swapped_array = np.swapaxes(img_after_reample_array, 1, 2)
I'm confused as to the next step. I know I can use the function nib.Nifti1Image
to make the numpy array into a nifti object, but how would I have to modify the affine to account for the axis change?
Thank you for any help.