whereami aparc medial cerebellum deletion

Hi all,

I am using whereami -mask_atlas_region to save out some brainstem/cerebellum masks that are subsequently combined into a single mask for later analysis. I previously had no issues with this using AFNI v19.0.25 and using the following command after using @SUMA_Make_Spec_FS:

@MakeLabelTable -atlasize_labeled_dset aparc.a2009s+aseg_rank.nii -replace
whereami -atlas aparc.a2009s+aseg_rank -mask_atlas_region aparc.a2009s+aseg_rank::brain-stem
whereami -atlas aparc.a2009s+aseg_rank -mask_atlas_region aparc.a2009s+aseg_rank::Cerebellum
whereami -atlas aparc.a2009s+aseg_rank -mask_atlas_region aparc.a2009s+aseg_rank::Cerebellum-WhiteMatter
whereami -atlas aparc.a2009s+aseg_rank -mask_atlas_region aparc.a2009s+aseg_rank::VentralDC

# Combine separate masks into a single mask
3dMean -prefix Cerebellum_BrainStem_Mask_{$subj} -mask_union \
	aparc.a2009s+aseg_rank.brain-stem+orig \
	aparc.a2009s+aseg_rank.Cerebellum+orig \
	aparc.a2009s+aseg_rank.Cerebellum-WhiteMatter+orig \

I recently updated from AFNI v19.0.25 to v21.0.03 and the atlas now separates left and right cerebellum. This is not an issue and I updated my code to reflect some of the comments in this thread. My new code is below:

@MakeLabelTable -atlasize_labeled_dset aparc.a2009s+aseg.nii -replace
whereami -atlas aparc.a2009s+aseg -mask_atlas_region aparc.a2009s+aseg::Brain-Stem
whereami -atlas aparc.a2009s+aseg -mask_atlas_region aparc.a2009s+aseg::Left-Cerebellum-Cortex
whereami -atlas aparc.a2009s+aseg -mask_atlas_region aparc.a2009s+aseg::Right-Cerebellum-Cortex
whereami -atlas aparc.a2009s+aseg -mask_atlas_region aparc.a2009s+aseg::Left-Cerebellum-White-Matter
whereami -atlas aparc.a2009s+aseg -mask_atlas_region aparc.a2009s+aseg::Right-Cerebellum-White-Matter
whereami -atlas aparc.a2009s+aseg -mask_atlas_region aparc.a2009s+aseg::Left-VentralDC
whereami -atlas aparc.a2009s+aseg -mask_atlas_region aparc.a2009s+aseg::Right-VentralDC

# Combine separate masks into a single mask
3dMean -prefix Cerebellum_BrainStem_Mask_{$subj} -mask_union \
	aparc.a2009s+aseg.Brain-Stem+orig \
	aparc.a2009s+aseg.Left-Cerebellum-Cortex.l+orig \
	aparc.a2009s+aseg.Right-Cerebellum-Cortex.r+orig \
	aparc.a2009s+aseg.Left-Cerebellum-White-Matter.l+orig \
	aparc.a2009s+aseg.Right-Cerebellum-White-Matter.r+orig \
	aparc.a2009s+aseg.Left-VentralDC.l+orig \

There now is consistently a gap in my mask in medial cerebellum, however. See attached images of the union mask created by 3dMean with an overlay showing disparities between what I think is being called from the overlaid aparc.a2009s+aseg dataset and my new underlay mask. There seems to be portions of medial cerebellum included in the atlas overlay that are not being included in my whereami call and I’m not sure why this is happening. I feel like I’m missing something obvious but am at a loss?



Sooo, I think the issue is that whereami is being a little too clever for its own good. It is finding the ROI that matches the specified name, AND restricting it to one side of the x=0 line. I think this behavior was developed for atlases that didn’t separate left and right with names, and so one could split a bilateral ROI with the centerline. Here, that behavior is inappropriate. This might be something we change…

In the meantime, the way i would do what you want (select several ROIs by label, and make a single mask out of them) would be as follows, via 3dcalc:

3dcalc \
    -a aparc.a2009s+aseg.nii.gz'<Brain-Stem,Left-Cerebellum-Cortex,Right-Cerebellum-Cortex,Left-Cerebellum-White-Matter,Right-Cerebellum-White-Matter,Left-VentralDC,Right-VentralDC>' \
    -expr 'step(a)' \
    -prefix NEW_MASK.nii

This is using the “AFNI selectors”, in this case the angle-brackets to select ROI by label or by number (labels being preferred, if possible, for clarity). The quotes are necessary (either single or double here).

If you wanted the values+labels left in (so you still have a “map” of your selected ROIs), you could run:

3dcalc \
    -a aparc.a2009s+aseg.nii.gz'<Brain-Stem,Left-Cerebellum-Cortex,Right-Cerebellum-Cortex,Left-Cerebellum-White-Matter,Right-Cerebellum-White-Matter,Left-VentralDC,Right-VentralDC>' \
    -expr 'a' \
    -prefix NEW_MAP.nii

# reattach labeltable and put ROI-dset appropriate colorbar as default
3drefit -copytables aparc.a2009s+aseg.nii.gz  NEW_MAP.nii
3drefit -cmap INT_CMAP            NEW_MAP.nii


Hi Paul,

This worked great, thanks for the help as always. The default whereami behavior makes sense and the use of 3dcalc instead makes more sense for our script moving forward.