Creating a customized TSNR stats table

AFNI version info (afni -ver): Precompiled binary macos_13_ARM: Feb 20 2025 (Version AFNI_25.0.06 'Severus Alexander')

Hello!

I am trying to generate a customized TSNR stats table in the APQC HTML report, instead of just using the default 12 pre-selected regions.

The regions I want to use are: L. caudate, L. nucleus accumbens (NAcc), L. precuneus, L. ventral striatum, R. anterior inferior parietal lobule, R. caudate, R. dorsomedial prefrontal cortex, R. NAcc, R. posterior cingulate cortex (PCC), R. putamen, and R. ventral striatum.

Now, I understand that I need to specify an atlas dataset using the -ROI_import option, and then use the -regress_compute_tsnr_stats option to specify the desired ROIs in that atlas.

However, I don't know how to find an atlas that has the regions that I want to use or how to create one, while ensuring that it is in the final space of the EPI data. I am using the "MNI152_2009_template.nii.gz " template.

How can I proceed with this analysis? Is there some tutorial on this somewhere?

Thanks,
Robin

1 Like

There are a few things you can do to find out which atlases have which atlases. In AFNI, the easiest thing to do is to look at the template you have and see which regions are at the location you click on in the GUI with the whereami functionality. Right-click on the image to open up that interface.

Programmatically, there are other ways - like the ones mentioned here:

https://discuss.afni.nimh.nih.gov/t/locate-atlas-datasets/501/4?u=dglen

To see which atlases and templates are in which spaces, you can use "whereami -show_atlases" for all the atlases and templates, as shown in this previous post:

https://discuss.afni.nimh.nih.gov/t/afni-atlas-update/6734

1 Like

Hi, Robin-

Indeed, there are many atlases out there, and not all of them have what you want defined in a single set together. So, you might have to put together a "Frankenstein's atlas". You might also have to approximate some ROIs you want from ones called something else.

Some of what you want exists in the Freesurfer atlas, so you should be able to use the "FS.afni.MNI2009c_asym.nii.gz" that we distribute. For example, it has these (with L- or R- hemisphere partners):
Left-Caudate
Left-Accumbens-area
ctx_lh_G_precuneus
Right-Putamen
... and several parietal things you can check out for appropriateness:

11125     ctx_lh_G_pariet_inf-Angular          tiss__gm         73     20  60 220   0
11126     ctx_lh_G_pariet_inf-Supramar         tiss__gm         74    100 100  60   0
11127     ctx_lh_G_parietal_sup                tiss__gm         75    220 180 220   0
11157     ctx_lh_S_intrapariet_and_P_trans     tiss__gm        104    143  20 220   0
11166     ctx_lh_S_parieto_occipital           tiss__gm        113    101 100 180   0
11172     ctx_lh_S_subparietal                 tiss__gm        119    101  60  60   0

There are also several posterior cingulate locations:

12106     ctx_rh_G_and_S_cingul-Ant            tiss__gm        129     26  60   0   0
12107     ctx_rh_G_and_S_cingul-Mid-Ant        tiss__gm        130     26  60  75   0
12108     ctx_rh_G_and_S_cingul-Mid-Post       tiss__gm        131     26  60 150   0
12109     ctx_rh_G_cingul-Post-dorsal          tiss__gm        132     25  60 250   0
12110     ctx_rh_G_cingul-Post-ventral         tiss__gm        133     60  25  25   0
12147     ctx_rh_S_cingul-Marginalis           tiss__gm        169    221  20 100   0

So, that might be your best bet as a single atlas to use?

For afni_proc.py, you can indeed use -ROI_import <label> <dset> and then -regress_compute_tsnr_stats <label> ROI1 ROI2 ROI3 ...

--pt

Thank you for your detailed responses, Daniel and Paul.

While the idea of putting together a "Frankenstein's atlas" sounds like the way to go and what I'd have to do eventually, I think using the Freesurfer atlas for MNI 2009c asym template is sufficient for now and the path of least resistance. I have a few follow-up questions though.

In -regress_compute_tsnr_stats <label> ROI1 ROI2 ROI3 ..., do I put the integer code associated with each ROI when specifying ROIx?

Is there a straightforward/direct way of creating a copy of an atlas (e.g. the Freesurfer atlas mentioned above) and only keeping the desired ROIs in it?

In future, when I need to create a Frankenstein's atlas, is this tutorial sufficient?

Hi, Robin-

To your questions:

  • Yes. Let's say your <label> was fs_afni, and you wanted ROIs 7, 8 and 2087 (not sure those exist, just picking numbers). You would put

    -regress_compute_tsnr_stats fs_afni 7 8 2087
    

    ... and have a table with those 3 values. I have to check if you can use the string labels, or are required to use the integer ROI values...

    • To get the ROI values, you could check the labeltable, maybe most conveniently with grep -i ..., for case insensitive queries, like:
      $ 3dinfo -labeltable FS.afni.MNI2009c_asym.nii.gz | grep -i accumbens
      "33" "Right-Accumbens-area"
      "17" "Left-Accumbens-area"
      
  • You could make a new dset with the subset of regions, but I wouldn't really see the benefit of it here. You get to specify the subset for the table with the -regress_compute_tsnr_stats .., option, so that should be fine. If you really wanted to (again, I don't recommend here), you could use different variations of 3dcalc, like:

    3dcalc -a FS.afni.MNI2009c_asym.nii.gz"<8,7,2087>" -expr 'a' -prefix short_atlas.nii.gz
    

    But then you should perhaps copy over the full atlas for labels, and mark the header to have ROI-like colorbar, so then you would run:

    3drefit -copytables FS.afni.MNI2009c_asym.nii.gz short_atlas.nii.gz
    3drefit -cmap INT_CMAP short_atlas.nii.gz
    

To make a Frankenstein atlas from DSET1 and DSET2, where you want ROIs 4 and 19 from the former and 8, 27 and 4021 from the latter, you could do:

3dcalc \
   -a DSET1"<4,19>" \
   -b DSET2"<8,27,4021>" \
   -expr "a+b" \
   -prefix DSET_FRANK.nii.gz

But the subtleties come with making sure that the ROIs do not overlap. To check about overlap, you could do:

3dcalc \
   -a DSET1"<4,19>" \
   -b DSET2"<8,27,4021>" \
   -expr "bool(a)*bool(b)" \
   -prefix DSET_FRANK_overlap.nii.gz

... and if DSET_FRANK_overlap.nii.gz has nonzero values, then you have overlap. And a headache to decide what to do---but at least you know there was an issue.

And if you have the same ROI value in the two atlases, then you have to reassign one... life becomes tricky. If you have to offset one, you could add a large number to the atlas values that is "safe" to get above the values in the other. So, like, offsetting by 10000 here:

3dcalc \
   -a DSET1"<4,19>" \
   -b DSET2"<8,27,4021>" \
   -expr "a+b+bool(b)*10000" \
   -prefix DSET_FRANK_offset.nii.gz

If the offset is large enough, you also have to make sure that the datum type of the dset can handle it. Like, a byte type dataset couldn't handle a 10000 offset. To check datum type, 3dinfo -datum DSET.

--pt

Hi Paul,

Thank you so much for the detailed and clear answers to all my questions. I think this is exactly what I was looking for and I can now try these out to confirm if it all works for me.

One question I had about the Frankenstein atlas is that if we have an atlas in the MNI space and one in the TT space, we would first have to transform one of the atlases (e.g., the TT space atlas) to the other's space (e.g., the MNI space) before using 3dcalc to combine them, right? Could you please share the command one can use for that as well?

Thanks,
Robin

Be careful mixing Talairach and MNI atlases. There have been several discussions over the years on this message board, like the one linked below. The transformations have been done in a variety of ways over the years. For some of the atlases, you can find them in either space. Of course, you will have to consider the specific MNI 2009c asymmetric - 1mm space. If you put the atlas regions into a single atlas, then you will also have to consider how to deal with overlapping regions. You can use multiple atlases instead of combining them too.

https://discuss.afni.nimh.nih.gov/t/tt-152-2009c-to-mni152-t1-2009c/2875/2

Indeed, as @dglen mentioned, be careful about different template spaces.

IN the case of the FS-based AFNI-distributed atlases, there is both a FS.afni.TTN27.nii.gz and FS.afni.MNI2009c_asym.nii.gz dataset, though.

--pt

Thanks again, Daniel and Paul, for the guidance and words of caution.

It seems that the ROIs I wanted that are missing from the FS AFNI MNI2009c asym atlas are not present in other atlases anyway, so I am going to move forward without combining any atlases. If/when I need to do so in the future and I need to combine ROIs from incongruent atlases, the links in the message board discussion Daniel mentioned above seem like a good starting point.

Thanks a lot,
Robin

Glad you got most of this worked out. For the missing regions, I would think that the Pauli subcortical atlas would provide a couple of these - nucleus accumbens, putamen. The ventral striatum includes the nucleus accumbens with the olfactory tubercule together. The olfactory tubercule is available in the AAL3 atlas. We provide a tweaked version of the Pauli atlas and also the AAL3 atlas.

https://afni.nimh.nih.gov/pub/dist/atlases/Pauli_subcortical/pauli_dist.tgz

https://afni.nimh.nih.gov/pub/dist/atlases/aal/AAL3_dist.tgz

1 Like

Great, thank you!