[Neuroimaging] How to fix the rotation change caused by resample_to_output()?

Melike Ilteralp milteralp at gmail.com
Wed Jul 13 00:14:15 EDT 2022

Hi all, I am working on a dataset with different voxel sizes, so I need to
resample the voxel sizes to (1, 1, 1). I found
nibabel.processing.resample_to_output() which accomplishes this job.
However, I realized that resampling changes the rotation of some images.
is a slice from an image that rotates when resampled and its resampled
Is there any way to make the rotation of the resampled image the same as
the original image?

Here is what I tried,

import nibabel as nib
from nibabel.processing import resample_to_output

img_nii = nib.load('original.nii.gz')
img_resampled_nii = resample_to_output(img_nii, voxel_sizes=(1, 1, 1))
nib.save(img_resampled_nii, 'resampled.nii.gz')

You can download `original.nii.gz` from here

Thank you for your support,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/neuroimaging/attachments/20220713/7a8499f2/attachment.html>

More information about the Neuroimaging mailing list