General data processing notes
Prepare the data
First, download the tar-ball of NIFTI file from NIMS. Then, unpack the \tarball:
tar -xf 20120606_2667_nii.tar
Organize your data:
mkdir subject01 mv 20120606_2667 subject01 cd subject01
Now reorient the fmri data:
fslreorient2std 20120606_2667/0005_01_BOLD_EPI_2_back_A.nii.gz fmri_2back_A
Prepare the T1 data:
fslreorient2std 20120606_2667/0002_01_T1w_9mm_sag.nii.gz t1 bet t1 t1_brain
Check the brain (e.g., with fslview). If the skull-stripping was too aggressive, then try decreasing the f-parameter:
bet t1 t1_brain -f .4
Run FreeSurfer
Once you have freesurfer installed, run something like this to get it configured on a Mac:
export FREESURFER_HOME=/Applications/freesurfer source $FREESURFER_HOME/SetUpFreeSurfer.sh export SUBJECTS_DIR=/Applications/freesurfer/subjects
On Linux, you will run something like:
export FREESURFER_HOME=/usr/local/freesurfer
export SUBJECTS_DIR=/scratch/anatomy
. ${FREESURFER_HOME}/SetUpFreeSurfer.sh
export SUBJECTS_DIR=/scratch/anatomy
Or better yet, put that into your .bashrc file so that it's run every time you log in.
Be sure to set the /Applications/freesurfer/subjects to a directory with a lot of free storage space. You will need to set this enviroment variable each time you want to do something with freesurfer. Or, you can put it into your .bashrc file to have it set automatically each time you open a terminal. Also, you need to replace [t1.nii.gz] with the actual path and filename of this subject's high-res T1-weighted scan and [subject_id] with a code or name that you will use to refer to this subject (e.g., s1)
Generate a cortical surface (and a bunch of other useful stuff) with the following commands. WARNING: this will take about 12 hours to run!
recon-all -i t1.nii.gz -subjid [subject_id] -all
Or, if you have Cuda-capable GPU:
recon-all -use-gpu -i t1.nii.gz -subjid [subject_id] -all
Be sure to check your surface to make sure the segmentation is good:
freeview -v t1.nii.gz -f ${SUBJECTS_DIR}/[subject_id]/surf/lh.pial -f ${SUBJECTS_DIR}/[subject_id]/surf/rh.pial
Run the FSL FEAT analysis
fsl, feat, etc (see my slides from the fMRI tutorial.)
Overlay on the cortical surface
To register (i.e., align) functional data from FEAT to the anatomical data, run this:
reg-feat2anat --feat [fmri.feat] --subject [subject_id]
Be sure to replace [fmri.feat] with the directory containing the FEAT output for the analysis of this subject's fMRI data, and [subject_id] with the same id that you used in the recon-all step above.
Optional: overlay the zmap onto the volume to check the registration:
tkmedit [subject_id] orig.mgz lh.white -overlay ./run1.feat/stats/zstat1.nii.gz \
-overlay-reg ./run1.feat/reg/freesurfer/anat2exf.register.dat \
-fthresh 4 -fmid 7 -fslope .167
To resample onto the surface (create run1.feat/reg_surf-lh-sh/stats with surface value files.):
feat2surf --feat [fmri.feat]
To view the data on the native inflated or pial surface (lh for left hemisphere, rh for right):
freeview -v t1.nii.gz -f ${SUBJECTS_DIR}/[subject_id]/surf/lh.inflated:overlay=[fmri.feat]/reg_surf-lh-rd/stats/zstat1.mgh -f ${SUBJECTS_DIR}/[subject_id]/surf/rh.inflated:overlay=[fmri.feat]/reg_surf-rh-rd/stats/zstat1.mgh
replace [fmri.feat] with the fsl feat directory for this subject, and [subject_id] with the correct subject id. (For help in using freeview, try the freesurfer tutorials.
Or use the older viewer "tksurfer": tksurfer [subject_id] [lh|rh] [inflated|pial] -overlay [fmri.feat]/reg_surf-[lh|rh]-[subject_id]/stats/zstat1.mgh
Lab Equipment Notes
A nice fMRI analysis workstation
The following hardware would make a nice fMRI workstation. All can be purchased from NewEgg for about $1500.
- Shuttle SH67H3 Intel Core i7 / i5 / i3 (LGA1155) Intel Socket H2(LGA1155) Intel H67 Intel HD Graphics 2000/3000 integrated in the processor 1 x HDMI XPC Barebone
- Intel Core i7-2600 Sandy Bridge 3.4GHz (3.8GHz Turbo Boost) LGA 1155 95W Quad-Core Desktop Processor Intel HD Graphics 2000 BX80623I72600
- G.SKILL Ripjaws X Series 32GB (4 x 8GB) 240-Pin DDR3 SDRAM DDR3 1333 (PC3 10666) Desktop Memory Model F3-10666CL9Q-32GBXL
- 2X Seagate Barracuda ST3000DM001 3TB 7200 RPM SATA 6.0Gb/s 3.5" Internal Hard Drive (RAID 1+0, for data)
- Crucial M4 CT128M4SSD2 2.5" 128GB SATA III MLC Internal Solid State Drive (system drive)
It should be installed with a NeuroDebian-compatible Linux distribution, such as Ubuntu.
One station is ideal. Two or three for students is still better. Adobe Photoshop & Adobe Publisher.
For software, install psychopy for experiment design, fsl for data processing and freesurfer for brain visualization. All are free applications. Consider hiring a cs undergrad to help us with coding for psychopy. (Eprime is about $2000 for one license and is an easier GUI for people who don't program).
SETTING UP A WORKSTATION
- Good CPU, >=8 GB RAM, >2TB
- Install Linux (ubuntu, mint, debian, etc.)
- Install neuroDebian (http://neuro.debian.net/)
- Install software (sudo apt-get install fsl afni mrtrix psychopy dicomnifti nipy-suite....)
- Get freesurfer (http://surfer.nmr.mgh.harvard.edu/)
- Configure freesurfer
Network-attached storage
Maybe something like this for about $1600: Seagate STAU12000100 12TB BlackArmor 440 Network Storage
General
Notes for reassuring subjects. On risks of fMRI: http://en.wikipedia.org/wiki/Specific_absorption_rate#Mobile-phones_SAR_list