Hi,
> Thank you very much for the information. I overlooked your description
> about the nibabel package.
> I would like to try your package, but could you tell me one more thing?
> You mentioned in your earlier post,
>
>>> By the way - this will generate a 'neurological' orientation image
>>> (first pixel is the right-most pixel).
>
> Is it possible to generate a 'radiological' orientation image?
Well, I'm afraid it would be as ugly as flipping the x coordinate of
the affine matrix before creating the new image:
>>> import numpy as np
>>> import nibabel as nib
>>> img = nib.load('nifti_image.nii')
>>> aff = np.dot(np.diag([-1, 1 1 1]), img.get_affine())
>>> flipped = Nifti1Image(img.get_data(), aff, img.get_header())
>>> better_img = nib.as_closest_canonical(flipped)
>>> nib.analyze.save(better_img, 'better_analyze_image.img')
I see now my original example should have been:
>>> import nibabel as nib
>>> img = nib.load('nifti_image.nii')
>>> better_img = nib.as_closest_canonical(img)
>>> nib.analyze.save(better_img, 'better_analyze_image.img')
Best,
Matthew
|