ROI Masks Edit

Hello AFNI,

I wanted to ask a simple question about editing ROI masks.

I have created ROIs by using the Clusterize method (i.e. Creating ROI datasets from Activation Maps).
Would there be a simple way to edit (delete or add voxels) existing ROI masks?

I have tried deleting them via the drawing plugin, but it seems like I must have my ROI masks as an underlay to edit out voxels.
I would like to set my anatomical file as underlay when I am editing my ROIs, to see where I am drawing those.
Would there be a way to set my ROI mask as an overlay and fix the overlay for this plugin? Please let me know if I am understanding the whole mechanism wrong.

Thank you!

  • yuni

Hi, Yuni-

Can I ask what you want to edit about the ROI masks? There might be automatic tool ways of doing things (or perhaps different considerations altogether). In general, I don’t know of many cases where ROI masks get edited.

Do you want to add or delete entire ROIs, and if so, according to what criterion (size?). If just voxels, what property do they have to earn removal?

By default in the AFNI GUI, the underlay dataset sets the grid for displaying data. You can overlay a low-res EPI on a high-res anatomical, but the EPI will be “regridded” automatically to match the anatomical.

I think this is what is restricting your choice of underlay in the “draw dataset” plugin-- I am guessing your cluster dataset is on a different grid than your anatomical. You could resample your anatomical to match the grid of your clusters, and then underlay it whilst drawing. To do this, you could use the following command where DSET_ANAT is your current anatomical and DSET_CLUST is your cluster dset:

3dresample \
    -input DSET_ANAT \
    -master DSET_CLUST \

Does that sort things out?

But again, it might be good to think about other ways of doing this procedure (and the goals of the editing).


You may want to reverse the -dset and -master datasets if you want a finer drawing. You can resample that back down to the lower resolution with 3dresample or 3dfractionize later. Alternatively, you can also open a second AFNI controller and show the ROI dataset you are drawing on as the overlay. That’s initially named “COPY_…”. Updates in the ROI as you draw are shown in the second controller. Still, the more important question is your goal for doing this.

Hi pt and Daniel!

Thank you for your responses.

To answer your question, I am trying to edit my clusters to make my ROI masks more concise.
Within the culsterize option of creating ROIs, my cluster reports has been registering huge blobs of clusters (that are on different areas on the brain) as one cluster (Since there are small bits of clusters connecting one map to another, it’ll register two or more clusters as one massive cluster). I have been trying to figure out a way to separate them by being more stringent on my p-value, but there seems to be a limit to this. I was thinking about creating a ROI masks and edit out some clusters. I have been suggested to look into deleting voxels on my ROI which may solve this problem.

If there is a better way to do this, I am definitely open for suggestions!


You could find the intersection of the cluster with an anatomical mask, a representative central point from the cluster and a sphere mask around it, or erode and dilate the clusters by some small number of layers.

Hi, Yuni-

I don’t think editing masks is a common procedure. I am not sure of a way to remove voxels without possible biasing or changing of results, and without a heavy degree of arbitrariness.

Instead, as Daniel noted, you could intersect your large clusters with an anatomical map, to identify regions usefully.
→ as a supplement to this, you can also note where major peaks fall in the anatomical regions, but I wouldn’t use this as the only information in your results: a peak is just one voxel, whereas your cluster is a much larger area. 3dExtrema points out local peaks (but what counts as a “peak” is also not always clear-- this also involves subjectivity, so that is why this should be descriptive and not definitive.)

Even when you threshold, it is good to consider the translucent thresholding in AFNI, described in this post:,164378,164379#msg-164379
with links to both tutorials on the AFNI website and the AFNI Academy online Bootcamp lectures. Basically, all thresholds are arbitrary, and these viewing options help show more of your data.