3dROIstats: Promises and Pitfalls

Just as a follow-up to the previous post, with AFNI's 3dROIstats, it usually makes sense to assign different values to different ROIs; that way, when data is extracted from those ROIs, each one is labeled individually. Since every one of you you reads everything I write and watches everything I film, you probably noticed that I used a couple of different commands for combining ROIs, such as:

3dcalc -a roi1 -b roi2 -c roi3 -expr '(a+b+c)' -prefix outputfile

and, in the video,

3dcalc -a roi1 -b roi2 -c roi3 -expr 'step(a) + 2*step(b) + 4*step(c)' -prefix outputfile


The reason for assigning values increasing exponentially (1, 2, 4, 8, 16, etc) is to identify which voxels belong to a single ROI, and which voxels belong to overlaps of ROIs. For example, let's say that we have three ROIs, A, B, and C. Using weights of 1, 2, and 4 would result in the following table of values:

1: A only
2: B only
3: overlap of A & B
4: C only
5: overlap of A & C
6: overlap of B & C
7: overlap of A & B & C

By contrast, if you used weights of 1, 2, and 3, then the intersection of A and B would be indistinguishable from region C. (Of course, if do not think that any of your ROIs will overlap, then using discrete consecutive digits, such as 1, 2, 3, etc, is also fine.)

Once you have created your combined mask and are happy with the locations of your ROIs, the command 3dROIstats can be used to dump out data extracted from each ROI from one or more sub-briks (e.g., beta-maps) of a statistical dataset. The command is pretty straightforward, and this template command should be pretty much all you need:

3dROIstats -mask combinedMask+tlrc 'stats+tlrc[1,2,5,...etc]'

For each sub-brik specified in the dataset, 3dROIstats will dump out the average data value within each ROI. So, for example, if you have three ROIs in your mask and two sub-briks, 3dROIstats will output a 2x3 table with three values for each sub-brik, one for each ROI.

I hope that is as clear as a glaucous sky, which I think is a word that means unclear, or something. I just read it in a Cormac McCarthy novel and he uses a lot of words that I don't know. Whatever. I was trying to be ironic.