Reading data into Matlab

Note: the latest version of matlab functions is posted at http://www.klab.caltech.edu/~farshadm/fmri/ . Some of the routines described here are obsolete and replaced with more flexible functions.

Reading binary files into Matlab

At present, the images are exported to CD as DICOM format. All files are exported to a single directory, and numbered in an arbitrary order.

I used MedCon to convert the data to binary format and sort the files. MedCon (and the interactive version, XMedCon) is a free programs that can be downloaded from the internet. Here is a Matlab function that can be used to read individual images or series after conversion:


Reading analyze image files into Matlab

The following programs can be used to read and display MRI data in analyze format (see next section about conversion), and to perform simple analyses. It is assumed that the data is stored as short integer (16 bit).

An FSL tool, flirt , can be used to alighn different sessions or even different subjects and head models before reading data into matlab.


Converting Siemens Mosaic images to 3D analyze images

FSL and SPM both use the ANALYZE format. MedCon can convert mosaic DICOM files (all BOLD sequences on the Siemens Trio scanner are saved in this format) to Analyze. Although it is possible to run statistical analysis on the converted files, MedCon generates a single 2D mosaic image and not a real 3D volume, which is necessary for co-registration. medcon -fmosaic may work but I am not aware if the slice tickness is correctly registered.

MRIConvert (jolinda@uoregon.edu) can be used to convert the DICOM mosaic images to 3D volumes for using with SPM. MRIConvert was developed at the Lewis Center for Neuroimaging at the University of Oregon. A Windows version of their program can be downloaded from their web-site. It can save different sessions in separate directories and generates sensible file names.



Note: FSL and MRIConvert

FSL can not directly use files generated by MRIConvert. FSL uses 4D Analyze format files (xyz + time). A utility in fsl/bin called avwmerge converts between multiple 3D images and a single 4D image. Unfortunately, avwmerge does not correctly handle files generated by MRIConvert. There seems to be a problem with one of the dimensions which is zero in converted files.

I wrote a program to fix the header files:


Usage:
$ cd image_dir
$ fixhdr *.hdr


After fixing the headers, the data can be converted to a single 4-D file:
$ avwmerge -t outputfile *.hdr


I have not tried MRIConvert with SPM, but I expect it to work without any problem.




http://www.klab.caltech.edu/~farshadm/fmri