Multiple Basis Functions with afni_proc.py

Admittedly the title is a little bit opaque, you can already use afni_proc.py to have some of your regressors use the GAM basis function and others to use another basis function (e.g. SPM).  But one thing that I find helpful is to compare a standard basis function (e.g. GAM, SPM, SPMG2, etc) with an FIR style basis function (e.g. TENT).

One major reason to advocate an FIR/TENT model is that you make no assumptions of the shape of the HRF.  The downside to this is that you “burn” degrees of freedom in your model in order to estimate the shape at each time point.  Whereas GAM and similar basis functions have a standard shape that uses fewer degrees of freedom to estimate.  For reference, GAM and TENT models are shown below.

Gamma

TENT

 

But this post isn’t really about the differences between the models.  Instead, we want to be able to run GAM first and then TENT on the same data without going through the entire reprocessing pipeline that afni_proc.py suggests as the defaults.  There is good news, you can do this without too much trouble, you just have to know where to get the correct files!

With that, let’s jump in.  My file structure of choice works like this:

SubjectFolder
-- anat/high_res.nii.gz
-- func/epi runs
-- stim_times/timing text files
-- SubjectFolder.GAM

So within any given subject folder, I have all of the necessary input files for afni_proc.py, in addition to the output folder from the first pass analysis using afni_proc.py inside SubjectFolder.GAM.  Inside this output folder are all of the necessary files to go straight into my regression step of a new afni_proc.py script.

At this point I just need to write a new afni_proc.py script that copies the motion parameters from the previous volreg, the high resolution anatomical data,  the stimulus timing files, and of course the full preprocessed datafiles (pb.03 in this case).  I’ve included a script below:

afni_proc.py -subj_id $aSub -script afni_$aSub_fastlocTENT.tcsh -out_dir $aSub.TENT \
 -dsets $aSub.GAM/*pb03*.HEAD \
 -blocks mask regress \
 -copy_files $aSub.GAM/*anat_final* \
 -regress_stim_times $aSub.GAM/stimuli/times* \
 -regress_stim_labels print speech \
 -regress_local_times \
 -regress_reml_exec \
 -regress_motion_file $aSub.GAM/dfile_rall.1D \
 -regress_basis 'TENT(0,12,7)' \
 -regress_censor_outliers 0.1 \
 -regress_censor_motion 0.3 \
 -regress_est_blur_epits \
 -regress_est_blur_errts \
 -regress_opts_3dD \
 -num_glt 11 \
 -gltsym 'SYM: +print' -glt_label 1 'print' \
 -gltsym 'SYM: +speech' -glt_label 2 'speech' \
 -jobs 8 \
 -bash -execute

One other thing to note about this afni_proc.py script, it uses the TENT basis function and then use the GLTs to give the overall average area under the curve for the entire 12 second basis function.  Note that my TR is 2 in this experiment, which is why there are 7 “TENTs” to fit.  As an alternative, I could have also used TENTzero, which would force the first and last values of the basis function to be zero.  I’ve found this approach to be very helpful.

Comments are closed.