If previous posts hadn’t given it away, AFNI is my tool of choice for processing neuroimaging data. A lot of people get confused on the sheer number of options there are and that most things can be accomplished in a variety of ways. Today I’m going to outline three ways of doing Correlations between fMRI data and some kind of external data (e.g., a reading measure).
Data: 10 subjects of MRI data and an associated data table
subject value 1 1.59583042 2 0.30977361 3 0.17275604 4 1.77287327 5 1.91858457 6 -1.26554353 7 1.73914139 8 -0.03359282 9 0.62022641 10 -2.0418750
3dTcorr1D: Perhaps the easiest way to run a correlation between brain and behavior is to run 3dTcorr1D. First you will need to compile all of your relevant statistical coefficient files into a single NIFTI or HEAD/BRIK pair. You can use 3dbucket to do this. In this case, since I have 10 subjects I use 3dbucket to extract the condition I want to correlate from each subject and put it into an all_visual+tlrc dataset. After this, then it’s just a matter of calling 3dTcorr on the dataset and supplying the covariate file listed above. The [1] tell AFNI to get the column of values (because 0 would be the subject number) and the {1..$} tells AFNI to get all the rows after the header. These are in order to match the input dataset created by 3dbucket.
3dbucket -prefix all_visual+tlrc Sub01+tlrc.HEAD[visual#0_Coef] Sub02+tlrc.HEAD[visual#0_Coef]... 3dTcorr1D -prefix corr_visual all_visual+tlrc. cov.txt[1]{1..$}
3dRegAna: 3dRegAna can be used to perform simple and multiple regression (or even step-wise regression) on fMRI data. Here we do a simple regression (one DV, one IV). Then we use 3dcalc to take the square root of the R-squared term and then get the sign for the correlation based on the b-value from the regression.
3dRegAna -rows 10 -cols 1 \ -xydata 1.59 "all/stats.Sub1.nii.gz" \ -xydata 0.30 "all/stats.Sub2.nii.gz" \ -xydata 0.17 "all/stats.Sub3.nii.gz" \ -xydata 1.77 "all/stats.Sub4.nii.gz" \ -xydata 1.91 "all/stats.Sub5.nii.gz" \ -xydata -1.26 "all/stats.Sub6.nii.gz" \ -xydata 1.74 "all/stats.Sub7.nii.gz" \ -xydata -0.03 "all/stats.Sub8.nii.gz" \ -xydata 0.62 "all/stats.Sub9.nii.gz" \ -xydata 0.91 "all/stats.Sub10.nii.gz" \ -model 1 : 0 -bucket 0 ./corr_visual
#calculates correlation coef 3dcalc -prefix corr22 \ -a story.corr_visual+tlrc.[5] \ -b story.corr_visual+tlrc.[2] \ -expr 'sqrt(a)*ispositive(b) - sqrt(a)*isnegative(b)'
3dttest++/3dMEMA: You can also use 3dttest++ or 3dMEMA to run a correlation, with the caveat that you need to standardize both your fMRI and behavioral data before running the analysis.
gen_group_command.py -command 3dttest++ \ -dsets sub?.nii.gz sub??.nii.gz \ -subs_betas 0 \ -options -covariates cov.txt
Which will generate the following command:
3dttest++ -prefix ttest++_result \ -setA setA \ 1 "sub1.nii.gz[0]" \ 2 "sub2.nii.gz[0]" \ 3 "sub3.nii.gz[0]" \ 4 "sub4.nii.gz[0]" \ 5 "sub5.nii.gz[0]" \ 6 "sub6.nii.gz[0]" \ 7 "sub7.nii.gz[0]" \ 8 "sub8.nii.gz[0]" \ 9 "sub9.nii.gz[0]" \ 10 "sub10.nii.gz[0]" \ -covariats cov.txt