correct expression for 3dCalc


we recently had a problem regarding how to do a ttest as ((A-B) - (C-D)) and it was suggested that we create a contrast using 3dCalc to create the contrast for A-B and C-D per subject and then use 3dTtest to compare the two terms. I have included below the emails for reference.

However I have one more question. When I perform the 3dCalc should I be coding it as (A-B)/2 or just (A-B)?

For Example:

3dcalc -a “file name for sub brick / condition A” -b “file name for sub brick / condition B” -expr ‘(a-b)/2’ -prefix …

ie: 3dcalc -a /nfs/mint/MINT_A/${subj}_A/${subj}_A.pomp.results.2mm/stats.ForvBack.partialcorrectglt2mm.sep16.$subj+tlrc’[52]’
-b /nfs/mint/MINT_A/${subj}_A/${subj}_A.pomp.results.2mm/stats.ForvBack.partialcorrectglt2mm.sep16.$subj+tlrc’[49]’
-expr ‘(a-b)/2’ -prefix ${subj}__dec2016_4_minus_3_div_2

or should it be

3dcalc -a “file name for sub brick / condition A” -b “file name for sub brick / condition B” -expr ‘(a-b)’ -prefix …

ie: 3dcalc -a /nfs/mint/MINT_A/${subj}_A/${subj}_A.pomp.results.2mm/stats.ForvBack.partialcorrectglt2mm.sep16.$subj+tlrc’[52]’
-b /nfs/mint/MINT_A/${subj}_A/${subj}_A.pomp.results.2mm/stats.ForvBack.partialcorrectglt2mm.sep16.$subj+tlrc’[49]’
-expr ‘(a-b)’ -prefix ${subj}__dec2016_4_minus_3_div_2

-----Original Message-----
From: Richard Reynolds []
Sent: Monday, December 05, 2016 7:02 AM

Hi Prerona,

Note that the 2 paired tests that you already ran should
be identical to 1-sample tests if the contrasts were given
as input. Do you have those contrasts per subject? If
not, perhaps it would be worth running 3dcalc to compute
them (they do not have to come directly from 3dDeconvove,
but should be identical to what 3dcalc would give).

Then your group comparison becomes a 2-sample t-test of
the contrasts.

Note that 3dttest++ will not compute that extra contrast
beforehand, which is why I suggest 3dcalc, if you do not
already have those volumes.

Anyway, feel free to continue this on the message board.
Just let me know if there is still any issue with your
login or account info.

  • rick

On 12/04/2016 01:06 AM, Prerona Mukherjee wrote:

I have 2 sub-bricks in my regressions:

  1. Forwards Recall

  2. Backwards Recall

and 2 groups:

  1. ADHD

  2. Controls

I want to do a t-test to compare

{(back - forwards) in Controls} - {(back - forwards) in ADHD}

I did t-tests as:

  1. for Controls - Forwards Recall versus Backwards Recall

  2. for ADHD - Forwards Recall versus Backwards Recall

Now I am trying to do the t-test between the 2 groups

For this can I use a 3dT-test++ in AFNI? I tried it but I am getting an error saying that we need to put at least 2 datasets in set A. I also tried using the Singleton option instead of set but that also gave me an error

Can you suggest what I am getting wrong? Thanks so much!



Hi Prerona,

This should not affect the significance of any results
(since it is constant scalar across all subjects, unless
it is unbalanced, like A+B+C-D-E), but it is often nice
to make contrasts of unit weight in the positive and
negative directions.

So for a simple A-B contrast -expr a-b is good. But
for a contrast of ((A-B) - (C-D)), it might be better to
divide by 2, since this ends up as (A+D) - (B+C), and
each has a weight of 2. So for that, consider
-expr ‘(a+d)/2-(b+c)/2’.

  • rick

Thank you!