Hi,
> Our lab here has an in house software package that only reads analyze images. I'm trying to do some reorientation and registration in SPM5/8, but I need to then convert to analyze hdr/img pair and write out the image in the new orientation. I've tried a few programs, but they all also generate the *.mat file needed by older versions of SPM to store the orientation. What I really need is something that will take a nii format file and write out an analyze format file where the the image volume is actually physically written in the correct orientation.
If the .mat file only encodes some axis flips or axis rearrangements,
then you could try our 'nibabel' python package [1]:
easy_install nibabel
python
>>> import nibabel as nib
>>> img = nib.load('nifti_image.nii')
>>> better_img = nib.as_closest_canonical(img)
>>> nib.analyze.save(img, 'better_analyze_image.img')
By the way - this will generate a 'neurological' orientation image
(first pixel is the right-most pixel).
If there are rotations and translations so that the image does not
align down any reorganization of the axes, you'll have to reslice the
image to some canonical volume...
Best,
Matthew
[1] http://nipy.sourceforge.net/nibabel/
|