Performing brain-behavior correlations with 3dttest++

A while ago, I wrote a post for doing brain-behavior correlations with different AFNI programs.  And at the time I mentioned that you can do correlations with 3dtest++, but you’d first need to standardize (read: z-score) both the brain and behavior values.  The general logic there is that if you’re doing a simple regression (what a ANCOVA is with one group and one covariate), that standardizing the inputs will standardize your regression (ANCOVA) b-value to a beta, which is the same as a correlation.

So let’s say I have MRI data (of a single voxel for simplicity) from 10 people:

0.15214194
0.53165484
0.75160697
0.73402534
0.15539711
0.41414913
0.09563909
0.56122166
0.32040320
0.55696615

and their corresponding covariate value (some score):

subject score
Sub1 33
Sub2 9
Sub3 35
Sub4 25
Sub5 20
Sub6 8
Sub7 21
Sub8 16
Sub9 2
Sub10 18

The basic correlation of these values is 0.1150181.

If I run these data through 3dttest++:

3dttest++ -prefix corr_demo \
-setA allSubs \
Sub1 mri_data.1D[0] \
Sub2 mri_data.1D[1] \
Sub3 mri_data.1D[2] \
Sub4 mri_data.1D[3] \
Sub5 mri_data.1D[4] \
Sub6 mri_data.1D[5] \
Sub7 mri_data.1D[6] \
Sub8 mri_data.1D[7] \
Sub9 mri_data.1D[8] \
Sub10 mri_data.1D[9] \
-covariates covariates_t.1D

I get the following output:
<AFNI_3D_dataset
self_idcode = "AFN_lE6-AT8YoUXP4TUZqIw65g"
ni_type = "4*float"
ni_dimen = "1,1,1"
ni_delta = "1,1,1"
ni_origin = "0,0,0"
ni_axes = "R-L,A-P,I-S"
ni_stat = "none;Ttest(8);none;Ttest(8)"
>
0.427321 5.35561 0.00259738 0.327494
</AFNI_3D_dataset>

Which tells me that the “mean” value (without covariates) is 0.427, which is the same output as we would see in R.  And the t-stat on that mean 5.6428.  The covariate estimate is 0.00259, again the same as R’s lm(a~b) function.  And the t-stat for the b-value is 0.327 (same as R’s).  We can then convert the t-value of this covariate to an R-squared and thus into a r-value (correlation).

R2 = t2 / (t2 + DF)

3dcalc -a T-stat -expr ‘(ispositive(a)-isnegative(a))*sqrt(a*a/(a*a+DF))’ -prefix corr

Which gives us a correlation value of 0.1150181.  Congrats, they match!  

If you were to do things the old school way, you could standardize both your MRI data and the covariate data, your MRI data would look like this:
-1.14909
0.4356788
1.354154
1.280737
-1.135497
-0.05500114
-1.385034
0.5591438
-0.4464651
0.5413737

and your covariate file would look like this:

subject score
Sub1 1.348483
Sub2 -0.9147055
Sub3 1.537082
Sub4 0.5940871
Sub5 0.1225894
Sub6 -1.009005
Sub7 0.2168889
Sub8 -0.2546087
Sub9 -1.574802
Sub10 -0.06600967

and your AFNI output from 3dttest++ would look like this:

 

<AFNI_3D_dataset
self_idcode = “AFN_q0gjrxxu0ENLzuuMuFhqVw”
ni_type = “4*float”
ni_dimen = “1,1,1”
ni_delta = “1,1,1”
ni_origin = “0,0,0”
ni_axes = “R-L,A-P,I-S”
ni_stat = “none;Ttest(8);none;Ttest(8)”
>
1.11759e-08 3.35426e-08 0.115018 0.327494
</AFNI_3D_dataset>

As you can see, the “mean” value of the covariate is now equal to 0.11501, which is your correlation value.

Comments are closed.