Assignment 5 (due Wednesday, Feb. 15)
- The assignment is to have functional scripts that accomplish the spatial
preprocessing steps on your data, and can be modified easily to run with
a different set of preprocessing options. Preprocessing the data manually,
with the exception of flipping an occassional image here and there (!) does
not count.
The two scripts I was using in class are in the class
Matlab directory and should prove useful. One is get_studyinfo.m and
the other is preproc_fmridc_data.m
. Note that each is a work in progress!
There are a few things that you have to be mindful of.
- SPM needs to modify the header information (the .hdr files) when it calculates
the transformation matrices. Since the original data sit in read-only directories,
this is a bit of a problem and causes the script to crash. Making multiple
copies of the datasets isn't the greatest idea, so I've come up with a relatively
simple work around.
- You will notice in the preproc_fmridc_data script that there is a CREATE_SYMLINKS
option. If you execute this, it will make symbolic links (aliases) from
your output directory to your input directory for your .img files, and
it will copy the .hdr files from your input directory to your output
directory. If you then select the files in the output directory for your
analyses, SPM can modify the .hdr files, but leaves the .img files untouched.
NOTE: There is a bug in the default SPM5 distribution in @nifti/create.m
which was trying to open .img files with write permissions even when
it didn't need to. I reported this to the SPM folks, and they've fixed
the file, which sits in
/afs/cmb.ucdavis.edu/share/matlab/janata/fmri/spm5_fixes
I have this directory sitting at the top of my path.
The nice thing about this scheme is that if your processing scheme goes awry,
you can clobber the .hdr files (which are tiny) and start over. You should
only execute the CREATE_SYMLINKS once for any given study (unless you
want to reset everything to the original state).
- If you read preproc_fmridc_data, you will see code that builds up the SPM
job structure. Currently, it only does this for the realignment step, but
I will be adding code for doing coregistrations. Feel free to figure out
how to add it for yourselves! The best strategy is to set things up in
the GUI once, save the jobs structure and then examine it. All of the parameter
options for the various processing routines are stored in the set of spm_config*
scripts, e.g. spm_config_realign.m, spm_config_slice_timing.m, etc. So,
you can examine those files to get at the same information. The other way
to get at the defaults is to call spm_defaults.m.
Note that you have to have a global variable called defaults declared in
order to use the information in spm_defaults.
- There are several different pre-processing steps and options that one can
choose from. There is not necessarily a single correct way of doing something.
Usually, the defaults work very well and only needed to be tweaked to deal
with problem cases. Once batch scripts are in place, it is relatively easy
to examine the consequences of different processing choices. One has only
to add a bit of code that shapes how files are named or redirects them to
analysis-specific directories. As with most of the code we've been dealing
with, it is "bookkeeping" code. You should be starting to feel somewhat comfortable
with writing and organizing that sort of code.
- Template and canonical files are stored in /afs/dbic.dartmouth.edu/usr/pkg/spm/spm5/templates
and /afs/dbic.dartmouth.edu/usr/pkg/spm/spm5/canonical. The canonical directory
contains the standard MNI files.
Their location on the local (CMB) server is /afs/cmb.ucdavis.edu/share/matlab/janata/fmri/spm5/{templates,canonical}.