How about the BXH/XCEDE tools? They were developed by Syam Gadde here at Duke, and they are excellent for jumping around between image types. http://www-calit2.nbirn.net/tools/bxh_tools/index.shtm You can use bxhabsorb to fit the data with a bxh header, and then bxh2analyze to convert from nifti to analyze. There are a bunch of options that you can look at to check orientation as well! Best, Vanessa On Mon, Nov 8, 2010 at 2:19 PM, Matthew Brett <[log in to unmask]>wrote: > 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/ > -- Vanessa Villamia Sochat Laboratory of Neurogenetics Duke University, 2009 (603) 321-0676