FMRI Analysis: Detailed discussion of the process script

From SpanLabWiki
Jump to: navigation, search
      • NOTE: Almost every lab will create a process script to run these commands as a batch file, and in order to make them specific to a given subject, you’ll just have to change the P-file numbers and I&S values (recorded at scanner, found in subject info/note file). The following are the necessary pre-processing steps, which can be run via process script or as separate commands.

1. Reconstruct the .mag file from the P#####.7 file (optional) using grecons.

$ grecons11 -b -O P12345.7

2. Average the in-out slices to correct for slice timing in voxel sampling with sprlioadd; compiles P-files and labels them.

$ sprlioadd –B –O –m 0 P12345.7.mag run1 337 24

3. Convert 2D slices from the magnet into AFNI’s .BRIK format (3dVolume dataset) and make .HEAD file (contains header information) using to3d; individualize the I&S values

$ to3d –epan –prefix run1 –xFOV 120R-120L –yFOV 120A-120P –zSLAB 25.8I-66.2S –time:tz 337 24 2.0s seqplus 3D:0:0:64:64:8088: ‘run1’

4. Remove magnet stabilization periods using 3dTcat

$ 3dTcat –prefix run1tc ‘run1+orig[7..332]’

5. Shift voxel time series from the input dataset so that the separate slices are aligned to the same temporal origin using 3dTshift; This can also be done within 3dvolreg; this is most important in slow event-related designs, and unnecessary in block designs

$ 3dTshift –slice 0 –prefix run1ts run1tc+orig

6. Concatenate runs using 3dTcat. You may also choose to remove linear trends separately for each run before concatenation, especially if you are going to subsequently normalize your data (convert to % Signal Change).

$ 3dTcat –prefix run12ts ‘run1ts[0..325]’ ‘run2ts[0..325]’

7. Register each 3D sub-brick from the input dataset to a specific base brick using 3dvolreg. Choose a base brick that’s not too far toward the beginning or the end of a run. Can also use UCSD reg_briks program (from Philippe) to find and register to optimal base for each subject. Will create a .1D file that you can view ($ 1dplot 3dmotion12.1D[1..6]) in order to see sudden motions, between-run position changes, and overall subject drift over the session in 6 dimensions (A-P, L-R, I-S, roll, pitch, yaw; units are mm). You can ignore specific TRs with large movements using the censor option in 3dDeconvolve. You should use the six movement dimensions in the .1D file as regressors in 3dDeconvolve.

$ 3dvolreg –Fourier –twopass –prefix 3drun12 –base 90 –dfile 3dmotion12.1D run12ts+orig

8. If you decide you want to spatially smooth your data, you can use the command 3dmerge. Here, we apply a Gaussian blur with FWHM of 4 (about the size of one voxel)

$ 3dmerge –prefix run12b -1blur_fwhm 4 –doall 3drun12+orig

9. You probably want to apply a temporal filter to your data, and you will do this using the 3dFourier command. Definitely apply a high-pass filter to remove low frequency noise (the afnigroup decided that a good rule is 2x the characteristic frequency of your design; if you have an event related design, you can divide one run by 3 or 4). Some people choose to bandpass, and remove high-frequency noise as well, and the frequency you select will depend on your sampling rate. You will be removing the linear trend at this point as well, unless you add the –retrend flag. Also, you should perhaps filter runs separately.

$ 3dFourier –prefix run1f –highpass .011 ‘run12b[0..325]’ $ 3dFourier –prefix run2f –highpass .011 ‘run12b[326..351]’ $ 3dTcat –prefix run12f run1f+orig run2f+orig

      • NOTE: You should always visually inspect your data to make sure the signal is clean, and you can do this as soon as you’ve run the to3d command. Set the functional data as underlay. Bring out the axial, coronal, and sagittal views, and use the Index (upper left of the AFNI interface) to scroll through the full session, watching for ghosts, shadows, stripes, and nods. After that, use the GRAPH option to examine the time series for different voxels throughout the brain (you’re looking for spikes here). If you have abnormal spiking, you can use Gary’s imgzitfix program (specify cutoff in # Std. Devs. above mean) or AFNI’s 3dDespike program.


DUMMY GUIDE PRE-PROCESSING:

$ cd XXmmddyy (go into subject’s folder where P-files are) $ cp ../scripts/process . (names may reflect specific study; e.g. emoscripts, emoprocess)

$ emacs process (opens process script for editing in emacs text editor)

ctrl-z; $ bg (puts emacs in background so you can still use terminal)

$ less info (opens info file so you can retrieve P-file numbers and I&S values for subject) … keep info open, but make emacs the active window

Alt-x replace-string 11111 <enter> 12345 <enter> (replaces each P-file with subject-specific P-file 12345 as recorded in info file; cursor must be above the first occurrence of each P-file in order to replace all occurrences)

Alt-x replace-string 25.8I-66.2S<enter> 25.0I-67.0S<enter> (replaces I and S values in to3d command; retrieve from info file)

Ctrl-x-s (save) Ctrl-x Ctrl-c (close)

$ ./process (runs process script; you’ll end up with 3dmotion12.1D, run12b+orig.BRIK, run12b+orig.HEAD)

$ 1dplot 3dmotion12.1D[4] (plot session motion; repeat for 4 (I-S), 5 (L-R), and 6(A-P)) ctrl-z; $ bg (puts 1dplot in background so you can still use terminal)

$ emacs info (opens info file for editing in emacs)

Scroll down to appropriate place; Type “MOTION” and record largest sudden movements in I-S, L-R, and A-P directions; Initial and date.

Ctrl-x-s (save) Ctrl-x Ctrl-c (close)