Hello,
I’m trying to perform a simple rotation around the x-axis of a 3-d image. I want the image array size (512,512,512) to stay the same before and after the transform. If I’m not mistaken, I can use resample_img to do so, correct?
cos_gamma = np.cos(0.349)
sin_gamma = np.sin(0.349)
affine_mat = np.array([[1, 0, 0, 0],
[0, cos_gamma, -sin_gamma, 0],
[0, sin_gamma, cos_gamma, 0],
[0, 0, 0, 1]])
before_rot = image.load_img(rsync_dir + str(subject) + "/anat/T2_0pt5_masked.nii.gz")
after_rot = image.resample_img(before_rot,
target_affine=affine_mat.dot(before_rot.affine),
target_shape=before_rot.shape,
interpolation='continuous')
However, this code is not working for me. Is there something I do not understand here? Is there an entirely separate function that I should be running?
Thanks,
Tom