clusters based on correlations

Hi all,

I would like to subdivide a region into clusters of voxels with high correlations between them. What’s the best approach to do this? Is there an afni function that can help me with this? or do I have to calculate the correlations for each voxel? I was just reviewing 3dClusterize and 3dMerge, but they don’t seem helpful for what I need.


Ana, what is the motivation for such subdivision? Divide them based on what: different correlation ranges/intervals?

Hi, Ana-

3dROIMaker has the following options, to take a subset of the top N voxels (unconnected or connected) in each ROI, if you have a “refset” of ROI locations:
-only_some_top N :after ‘-volthr’ but before any ref-matching or
inflating, one can restrict each found region
to keep only N voxels with the highest inset values.
(If an ROI has <N voxels, then all would be kept.)
This option can result in unconnected pieces.
-only_conn_top N :similar-ish to preceding option, but instead of just
selecting only N max voxels, do the following
algorithm: start the ROI with the peak voxel; search
the ROI’s neighbors for the highest value; add that
voxel to the ROI; continue until either the ROI has
reached N voxels or whole region has been added.
The returned ROI is contiguous and ‘locally’ maximal
but not necessarily globally so within the original

You could do some looping to subdivide things, but this isn’t really based on level; otherwise, as Gang noted, you could do some “banded” ROI definition. But it would be good to have the problem specified a little more clearly.


Hi Gang,

I’d like to calculate resting-state correlations between every voxel of a big region of interest and the rest of the brain to look at how the connectivity of this region changes as you move from anterior to posterior voxels. Instead of looking at the correlations for every single voxel, first, I was going to create clusters based on their correlation ranges. I guess what I need to do is to calculate correlations between every voxel and all the other voxels within that region and then clusterize somehow based on those correlation results. I was wondering what the best approach would be or if there’s a specific afni function that could help me with this.

Please let me know if that doesn’t make sense. Thanks a lot!

This command would take a mask of an ROI_MASK and a correlation value dataset CORR_DSET, and make a new dset NEW that is the intersection of

  • where the correlation values in CORR_DSET lie within [0.5, 0.6], and
  • where the ROI is:

3dcalc \
   -a ROI_MASK \
   -b CORR_DSET \
   -expr "step(a)*within(b,0.5,0.6)" \
   -prefix NEW

If your ROI is located in a map of lots of ROIs, you could select it by its numerical index IDX or attached label LAB (if it has one) with:

3dcalc \
   -a ROI_MAP"<IDX>" \
   -b CORR_DSET \
   -expr "step(a)*within(b,0.5,0.6)" \
   -prefix NEW


3dcalc \
   -a ROI_MAP"<LAB>" \
   -b CORR_DSET \
   -expr "step(a)*within(b,0.5,0.6)" \
   -prefix NEW

You can make multiple new dsets for different bands.

You can overlay the NEW dset on your other dsets to make sure that has gone right.