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).
-
read_mrimage.m : Reads one or more
analyze images file into a structure array.
-
mri_display.m : Displays anatomical and
functional maps. Needs conv3dToMosaic.m.
-
mri_ttest.m : Performs a simple t-test. The map
can be displayed superimposed on anatomical images by mri_display.
-
mri_removeLinearDrift.m :
Can be used to correct for slow baseline shifts over time.
-
mri_roi_timecourse.m : User
can select regions of interest and the function returns average time course of signal and a mask.
The mask can be used for other series using
mri_timecourse.m. To
analyze the timecourse in event related designs use
mri_GLM.m.
-
mri_phasemap.m : Generates a
phase map (after applying a fourier transform over time). The map can be displayed using
mri_display_phasemap.m. These functions are useful for retinotopic mapping using periodic stimuli.
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