Using 3dcalc to calculate common active voxels between two conditions

Hello

I have two conditions and have calculated a t-map from 3dttrest++ for each. I now want to create a mask that shows which voxels are active for both conditions. I used the following command based on 3dcalcs help file.

3dcalc -a ‘A’ -b ‘B’ -expr ‘3step(a-3)'+3step(b-3)’ -prefix common_mask

A and B are the results from my 3dttest++. I thresholded it, and only wanted voxels with a t-value of 3. The resulting common_mask looked right at first, but I’m noticing that there are voxels showing in the mask that are not active in condition A.

I’m slightly now confused on what the 3*step does. At first, I thought it was how I tell 3dcalc to only calculate voxels in A and B only.

Thank you for your time.

I would recommend doing something a little different:

3dcalc -a ‘A’ -b ‘B’ -expr ‘1step(a-3)+2step(b-3)’ -prefix common_mask

In the result, voxels that have value ‘1’ are A-only, voxels with value ‘2’ are B-only, and voxels with value ‘3’ are A-and-B-together. With this as overlay, you can see all 3 possibilities (plus 0 = neither) at the same time, in different colors. If you want then to see only value=3 voxels in the overlay, just set the threshold slider to 2.9 or something like that.

Using this binary encoding is a powerful tool to see different combinations of thresholded results at one time. If you had a condition C, you could add ‘+4*step(c-3)’ and then have all 8 combinations of conditions above threshold encoded into values 0-7.

Thank you so much! I see now that the number in front of *step is indicating what value to put for that value now.

On a similar note, is there a general rule of thumb on what value I want to threshold for the (a-3) expression? I use the value that is shown after I set my p-value. And now that I think about it… since I’m using the Ttest results, if I want to find similar voxels based on Tvalue, I should do something like -a ‘A[1]’ then right? Just -a ‘A’ probably is using the beta values?

Thank you again

Hi-

Well, there is the program p2dsetstat that can convert a p-value to a statistic, based on your dset (AFNI stats calculation store necessary information like degrees of freedom in the header of a stat):
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/programs/p2dsetstat_sphx.html
… and its complement is inventively named dsetstat2p:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/programs/dsetstat2p_sphx.html
Note that you want to make sure that you are using appropriate sidedness when doing this:
https://onlinelibrary.wiley.com/doi/full/10.1002/hbm.24399
It sounds like you have a two-sided test-- this is what most testing in MRI studies is, though it can be difficult to do this in some (other) software.

Note also that we typically recommend using both the effect estimate part of the modeling (the beta) as well as the statistic information. In particular we suggest visualizing the beta coefficients of modeling and just thresholding the stat, with the utility of this explained here:
https://pubmed.ncbi.nlm.nih.gov/27729277/
… with the mechanics of doing so in AFNI explained here:
https://www.youtube.com/watch?v=VT77zJ0zGnA&list=PL_CD549H9kgqwHr0EDtvAU8hylsOj30OK&index=3
We have moved toward liking the “A” and “B” button features in the GUI, explained toward the end of this video, for using the “alpha” channel and “boxing” of results to display both suprathreshold and subthreshold data together in a manageable way.

This video also works in clustering in the GUI:
https://www.youtube.com/watch?v=3ZXfZfnRfyM&list=PL_CD549H9kgqwHr0EDtvAU8hylsOj30OK&index=4

That might be more reading and viewing than you wanted… but hopefully it provides some useful background thoughts on data presentation and threshold considerations.

–pt

Thank you very much for the resources and the constant help both of you have given!