A cheating method to consider: use the output of adjunct_aw_tableize_roi_info.py, which is a supplementary program used by @animal_warper. Note: this “adjunct” program can change at any point at the cruel whim of developers (hence the ‘adjunct’ naming convention). But, it probably provides what you want.
If you have used @animal_warper (and you have!), you know that the QC/ dir contains report*.1D files about mapped atlas and template regions, to compare their before- and after-warping volumes. The output table looks something like this:
# A atlas dset : CHARM_in_sub-01_anat.nii.gz[4]
# A mask dset : sub-01_anat_mask.nii.gz
# B atlas dset : /data/demos/setup_MACAQUE_DEMO/MACAQUE_DEMO_REST/NMT_v2.1_sym/NMT_v2.1_sym_05mm/CHARM_in_NMT_v2.1_sym_05mm.nii.gz[4]
# B mask dset : /data/demos/setup_MACAQUE_DEMO/MACAQUE_DEMO_REST/NMT_v2.1_sym/NMT_v2.1_sym_05mm/NMT_v2.1_sym_05mm_brainmask.nii.gz
# Mode_smooth size (nvox) : 1
# A vox dims (mm) : 0.500, 0.500, 0.500
# B vox dims (mm) : 0.500, 0.500, 0.500
# A mask Nvox : 800405
# B mask Nvox : 726796
# A mask volume (mm^3) : 100050.625
# B mask volume (mm^3) : 90849.500
# MaskVol_A / MaskVol_B : 1.101
# A atlas Nroi : 176
# B atlas Nroi : 176
# Nroi difference : 0
#
# ==========================================================================================================================================
# -- KEY --
#
# ROI_value = integer value of ROI
# Nvox_A = number of voxels in ROI in dset A
# Nvox_B = number of voxels in ROI in dset B
# Vol_A = ROI volume in dset A (mm^3)
# Vol_B = ROI volume in dset B (mm^3)
# RelVol_A2B = relative ROI volume, Vol_A / Vol_B
# Frac_A = ROI mask fraction, Vol_A / MaskVol_A
# Frac_B = ROI mask fraction, Vol_B / MaskVol_B
# RelFrac_A2B = relative ROI mask fraction, Frac_A / Frac_B
# Label_str = string label of ROI (if present)
#
# ==========================================================================================================================================
# ROI_value Nvox_A Nvox_B Vol_A Vol_B RelVol_A2B Frac_A Frac_B RelFrac_A2B Label_str
# ------------ ------------ ------------ ------------ ------------ ------------ ------------ ------------ ------------ ------------
4 781 703 97.625 87.875 1.111 9.758e-04 9.673e-04 1.009 # CL_area_32
5 273 273 34.125 34.125 1.000 3.411e-04 3.756e-04 0.908 # CL_area_25
7 767 729 95.875 91.125 1.052 9.583e-04 1.003e-03 0.955 # CL_area_24a/b
10 1924 1589 240.500 198.625 1.211 2.404e-03 2.186e-03 1.099 # CL_area_24c
12 451 563 56.375 70.375 0.801 5.635e-04 7.746e-04 0.727 # CL_area_24a/b_prime
15 1283 930 160.375 116.250 1.380 1.603e-03 1.280e-03 1.253 # CL_area_24c_prime
18 1685 1821 210.625 227.625 0.925 2.105e-03 2.506e-03 0.840 # CL_area_10
22 515 538 64.375 67.250 0.957 6.434e-04 7.402e-04 0.869 # CL_area_14
27 1123 1104 140.375 138.000 1.017 1.403e-03 1.519e-03 0.924 # CL_area_11
30 3123 3327 390.375 415.875 0.939 3.902e-03 4.578e-03 0.852 # CL_area_13
34 1486 1189 185.750 148.625 1.250 1.857e-03 1.636e-03 1.135 # CL_area_12m/o
Note how the first and last columns provide the info you want: the ROI value of any non-empty ROI and its string label, respectively.
The usage for the simple script is:
Takes >= 6 arguments:
1) an output file name;
2) an (warped) atlas of interest, with subbrick selector, if necessary;
3) a mask for the (warped) atlas (same grid)
4) a reference atlas (i.e., same one but unwarped), with (same)
subbrick selector, if necessary.
5) a mask for the reference atlas (same grid)
6) a "modesmooth" value, from modal smoothing used after warping
So, you could use it like:
adjunct_aw_tableize_roi_info.py OUTPUT.1D DSET_ROI DSET_MASK DSET_ROI DSET_MASK 0
Note how DSET_ROI and DSET_MASK are duplicated (and yes, you need each—this is a simple program with non-optional usage of command line args). The final modesmooth value doesn’t matter in this case, so 0 should be fine.
After you output this, you could extract the first and last columns of non-commented values.
–pt