# subdivide atlas region

Hi all,

I am using whereami to mask the left/right superior temporal gyrus with the MNI macro labels atlas. Is there a command I could use to sub divide the mask into a anterior, middle, and posterior regions (3 smaller masks)? 3dcalc perhaps? What would be the options for that?

Thank you!!

This can be accomplished a few ways. Here is a short script that subdivides based on distance from a particular coordinate. In this case, I just hand-picked it.

#!/bin/tcsh

# subdivide a region of interest based on distance from a particular xyz coordinate

set baseset = MNIa_caez_ml_18+tlrc
set coords = ( ‘-15’ ‘-4’ ‘-7’ )
set subn = 3

# calculate distance map for mask (simple euclidean distance)

3dcalc -a \$baseset -expr “equals(a,\$maskval)*sqrt((\$coords[1]-x)^2 + (\$coords[2]-y)^2 + (\$coords[3]-z)^2)”
-prefix roi_distmap.nii.gz -overwrite
set maxdist = `3dBrickStat -max roi_distmap.nii.gz`

# subdivide the regions into thirds, for instance

set minsubroi_dist = 0
foreach subroi (`count -digits 1 1 \$subn`)
set subroi_dist = `ccalc -float -expr "\$maxdist*\$subroi/\$subn"`
3dcalc -a roi_distmap.nii.gz -b \$baseset -expr “equals(b,\$maskval)\$subroiwithin(a,\$minsubroi_dist, \$subroi_dist)”
-overwrite -prefix subroi_\$subroi.nii.gz
set minsubroi_dist = \$subroi_dist
end
3dMean -max -prefix allsubrois.nii.gz -overwrite subroi_*.nii.gz

Wow, this was a huge help! Thank you so much!