AFNI
Preprocessing resting-state fMRI using AFNI
I am assuming that:
- you are working in a linux environment with the latest AFNI version installed
- you know how to operate basic linux commands
- you want to perform the same preprocessing steps described in this tutorial (adapt them if you wish)
If you have never used AFNI before, some useful information:
- afni's website is awesome and there are lot's of things there
- so many people use afni; questions and answers are all over the internet. So, if you don't know how to do something, chances are that you are not alone and there is something about it somewhere. Google it!
- there are many commands in afni; if you want to know how to use one of them, simply open the terminal, type the name of the command and press enter. A text containing the information about the command will appear. For instance try typing 3dTshift and then press enter.
1. Organize your data
- name your files consistently.
-- for example: C000843.nii; C000900.nii etc
- do not use special characters in the names of the files or folders (including spaces)
- save all your files in one single folder
-- for this tutorial I will use: /Users/luiz/RESTINGSTATE/
- open a text file that you should use as a documentation of every step you make (this is important because you will forget everything you did with your data after a few months). So, as you process your images take notes and save the exact commands you used. (this page is in constant change - do not use it as your own log!)
2. Slice timing correction (afni command 3dTshift)
- example of how to use. Say I want to perform slice timing correction for one subject (C000843.nii). In the terminal, go to the folder where the file is saved, write the following and press enter:
3dTshift -tpattern seq+z -prefix s_C000843 -TR 2s C000843.nii
--Ok, now let's understand what each part means:
--- 3dTshift: this is the command I want to perform
--- -tpattern seq+z: with this, I am telling the computer that the slices of the fMRI acquisition were acquired in the ascending order, in a sequential way (not alternating). You need to know this information and provide it to the computer.
--- -prefix s_C000843: with this, I am asking the computer to name the file after slice time correction as "s_C000843" (you can change it to suit your preferences).
--- -TR 2s: now, I am telling the computer that the TR (repetition time) of my fMRI acquisition was 2 seconds.
--- C000843.nii: this is the name of the file that I want to use be slice timing corrected.
--obs: when you are successful, you will notice that two new files have been generated; in this example they are s_C000843+orig.BRIK and s_C000843+orig.HEAD. The "+orig" is a convention used in afni meaning that the image is in the original space (i.e. not in the Talairach or MNI space). The .BRIK file contains the brain data and the .HEAD file contains the metadata (information about the file such as history of modifications). When using this files as input for other afni commands, you can type only the name before the dot (e.g. s_C000843+orig).
3. Motion correction (afni command 3dvolreg)
- Well, let's say I want to perform motion correction in the file s_C000843+orig. Example of usage:
3dvolreg -prefix rs_C000843 -base 100 -twopass -dfile motioncorrection_C000843.1d s_C000843+orig
-now let's understand the meaning:
-- 3dvolreg: the command I want to run
-- -prefix rs_C000843: now, I'm telling the computer how I want the name of the output file (output file = the resulting file)
-- -base 100: this is because I want all fMRI volumes (in my case, they are 200) to be aligned with the volume number 100 (in general you want to realign all volumes to the volume in the middle of the run because this avoids extremes)
-- -twopass: this is an option that makes the alignment more precise (but it takes longer)
-- -dfile motioncorrection_C000843.1d: with this, I save the motion correction parameters in a file (important because after I will need check if the subject has moved too much)
-- s_C000843+orig: this is the input file (i.e. the file on which I want to perform the motion correction)