[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.
Here
<https://drive.google.com/file/d/1TPC7Go3f9TzTWNZxm8j7qi72_u-rWxGx/view?usp=sharing>
is a slice from an image that rotates when resampled and its resampled
version
<https://drive.google.com/file/d/1Jwiv_W1pz1SLP5dmrumjGeF3tVG8xkam/view?usp=sharing>.
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
<https://drive.google.com/drive/folders/1-5phtVGQy5fq1W76MtMPlw0SDGa3AABc?usp=sharing>
,

Thank you for your support,
Melike
-------------- 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