AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
December 29, 2019 11:18PM
Hi-

(*NB: I have edited this to make the output dset names for examples C and D distinct: 'lhipp' and 'rhipp'.)

The syntax for using 3dcalc is as follows:
+ input a dataset with "-a ...", "-b ...", "-c ...", etc.
+ then, in the mathematical expression part "-expr ...", you refer to each dataset by the letter you used to input it; for example, "-expr 2*a" would double each value in the dataset entered with the option "-a ...".

More specifically to your case, I think the ROI value associated with Left-Hippocampus is 17, and that of Right-Hippocampus is 53 (please verify these yourself!). So, you could use the following to extract each:
# Example A
3dcalc -a follow_ROI_aaseg+tlrc -expr 'equals(a,17)' -prefix lhipp -short
3dcalc -a follow_ROI_aaseg+tlrc -expr 'equals(a,53)' -prefix rhipp -short
Note that in the output, each of those datasets will be a binarized mask of zeros and ones; if you want each ROI to keep its value in the output (perhaps for being able to combine more easily later), you could use:
# Example B
3dcalc -a follow_ROI_aaseg+tlrc -expr '17*equals(a,17)' -prefix lhipp -short
3dcalc -a follow_ROI_aaseg+tlrc -expr '53*equals(a,53)' -prefix rhipp -short

That above notation works, but it can be a bit opaque because of the 17 and 53 in the expr, which don't really have easily identifiable meaning. Instead, you could make use of AFNI selectors with the input file names, which allow you to select sub-volumes, subsets of values within volumes, or ROI label names. Please see the "INPUT DATASET NAMES" section in the 3dcalc help about details on all these.

For your case specifically, assuming the ROI labels are still attached, you should be able to use the following to extract just the ROI (note that the quotes around the selector part are *necessary*):
# Example C
3dcalc -a follow_ROI_aaseg+tlrc'<Left-Hippocampus>' -expr 'a' -prefix lhipp -short
3dcalc -a follow_ROI_aaseg+tlrc'<Right-Hippocampus>' -expr 'a' -prefix rhipp -short
This will produce output where each ROI has its same value as the input data set (so, like Example B, above). It just can be a bit easier to read+understand, and a bit more stable as you copy/edit/etc. code. Note that this case only works if the input dataset has a labeltable or atlas table attached (so, if you view the dset in the AFNI GUI and click on a region, do you see its name displayed in the control panel, as well as its numerical value?).

If you wanted just binarized masks in each case, then you could use:
# Example D
3dcalc -a follow_ROI_aaseg+tlrc'<Left-Hippocampus>' -expr 'step(a)' -prefix lhipp -short
3dcalc -a follow_ROI_aaseg+tlrc'<Right-Hippocampus>' -expr 'step(a)' -prefix rhipp -short
... which will provide output in the same form as Example A (please see the 3dcalc help file about what the step() function does).

--pt



Edited 1 time(s). Last edit at 12/31/2019 12:32PM by ptaylor.
Subject Author Posted

Resting state create mask

JW December 29, 2019 04:47PM

Re: Resting state create mask

ptaylor December 29, 2019 11:18PM

Re: Resting state create mask

JW December 31, 2019 11:31AM

Re: Resting state create mask

ptaylor December 31, 2019 12:47PM

Re: Resting state create mask

JW December 31, 2019 08:49PM

Re: Resting state create mask

ptaylor January 01, 2020 05:01PM

Re: Resting state create mask

Daniel Glen January 02, 2020 01:43AM

Re: Resting state create mask

JW January 03, 2020 04:25PM