[Neuroimaging] Niftiimage Affine Rotation

Kai Canoll kaicanoll at gmail.com
Thu Jul 11 14:03:58 EDT 2019

I would like to apply an affine transform to my image, then open the
transformed image in python to do additional processing.  In most other
toolboxes, the affine transformation and the resampling are separate steps,
i.e. you can rotate an image without changing the resolution or you can
change the resolution without rotating.
Is there any way to just apply an affine transform to an image in nibabel?


On Wed, Jul 10, 2019 at 2:30 PM Kai Canoll <kaicanoll at gmail.com
<https://mail.python.org/mailman/listinfo/neuroimaging>> wrote:
>>* HI All,
*>>* We are having some problems applying an affine transform to some
nifti data.
*>* We are trying to apply a new transform using
*>* affine_transformed_image=nib.Nifti1Image(datamatrix,affinetransform)
*>* When we look at a slice of affine_transformed_image in Python, it
doesn't seem to change in any way.  However, if we open it in FSLeyes,
it appears to be rotated according to affinetransform.
*>* However, if we resample affine_transformed_image using
*>* resampled_image=nib.processing.resample_from_to(affine_transformed_image,
*>* where vox_map contains an affine identity transform, then the
slices in python are successfully rotated.
*>>* In other words, our image does not appear to be affine
transformed in the first step.  Can anyone suggest how to apply the
affine transform such that the image actually rotates without having
to do the resampling step?
Could you say more about what you mean?   If you want the slices to
change, in the array, I'm afraid there's no way round it, but do
resampling.   FSLeyes is just doing the resampling in the background
for you, in order to show you the slices.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20190711/2c976ad8/attachment.html>

More information about the Neuroimaging mailing list