3dROIstats dealing with different ROI numbers across subjects

Somebody must have a solution for this, but I can’t find one.

In a loop, I run:

3dROIstats -numROI 194 -zerofill NA -mask /freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_noddi_frac+orig
/noddi/dset/derivatives/sub-“$s”/ses-S1/NODDI/NDI.nii.gz > /noddi/dset/derivatives/sub-“$s”/ses-S1/NODDI/NDI_a2009.txt

The problem is that the ROI numbers don’t line up for each subject. E.g.,

File Sub-brick …Mean_ctx_rh_S_temporal_sup Mean_ctx_rh_S_temporal_transverse Mean_194
/4153033/+orig 0[#0] 192 193 NA

File Sub-brick…Mean_ctx_rh_S_temporal_inf Mean_ctx_rh_S_temporal_sup Mean_ctx_rh_S_temporal_transverse
/1131032/+orig 0[#0] 192 193 194

So, e.g., in subject 4153033, ROI #193 is Mean_ctx_rh_S_temporal_transverse, but in 1131032 ROI #193 is Mean_ctx_rh_S_temporal_sup.

I have been trying to get everyone into a single data file (row = subject; col = region), but obviously this will be a problem. Is there no solution to this in AFNI? Isn’t this a big problem? I wouldn’t have noticed without careful data checking because once you resample you lose the region name information. I had to verify this problem by looking at the viewer for both subjects. So how do people deal with this?

Thanks for any help!
Anthony

Hi-

A couple things:
A) I don’t fully understand what you are doing in this step, but when has that stopped me from giving advice about something??

B) we recommend not using “rank” files from recon-all/@SUMA_Make_Spec_FS output. Precisely because those numbers might not be constant


+ renumbered data sets output, to replace old '*rank*' file data
      sets. Also new tissue maps based on FS functions and
      labels. Collectively, these are the '*REN*' dsets in the output
      directory.  (Rank dsets are no longer output by default, from
      Nov, 2019; instead, use -make_rank_dsets if really needed.)

Is your AFNI version quite old to even still be making "rank datasets (what is “afni -ver”?)? At present, you need to specify an option to get those output, which we do not really recommend (for aforementioned stability reasons).
The REN dsets are most stably numbered, and there are even some free partitioning of ROIs into tissue types. You should use those.

C) You mention “once you resample you lose the region name information”. I assume this is referring to the fact that the labeltable disappears from the output dataset, if the input one had it? That may be the case, but you can re-attach it, with:


3drefit -copytables DSET_ORIG_WITH_TABLE  DSET_NEW_WITHOUT_TABLE

Then, you can use the labels to select ROIs again. Similarly, this command could also attach an existing labeltable to a file:


3drefit -labeltable NAME_OF_TABLE  DSET_NEW_WITHOUT_TABLE

D) If you describe a bit more your code and what you want to get out, we might be able to help streamline this a bit more.

–pt

Ah, this very helpful. Our AFNI install is old at this point, so I think that is the first thing to update that. I lose region information during the resampling steps. My goal is to end up with a matrix subjects by region, so any suggestions that get to that are super helpful.

Here is my bash script, simplified:

#!/bin/bash
module load afni/17.3.06

cd /noddi/dset/derivatives/
clear
for file in *; do
echo $file
s=${file//sub-/}
echo “You are processing subject $s”

3dcalc -a /freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp+orig -expr ‘a’ -prefix /freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_short -datum short -overwrite

3dfractionize -template /noddi/dset/derivatives/sub-“$s”/ses-S1/NODDI/NDI.nii.gz
-input /freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_short+orig
-vote
-clip 0.5
-preserve
-prefix /freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_noddi_frac+orig
-overwrite

3dROIstats -numROI 194 -zerofill NA -mask /freesurfer_v6/$s/surf/SUMA/aparc.a2009s+aseg_rank_Alnd_Exp_noddi_frac+orig
/noddi/dset/derivatives/sub-“$s”/ses-S1/NODDI/NDI.nii.gz > /noddi/dset/derivatives/sub-“$s”/ses-S1/NODDI/NDI_a2009.txt

done

After this, I have an R script that brings everything into a subject by ROI matrix.

Okay, so I have updated my script to add one atlas, and also run AlignToExperiment as part of @SUMA.

@SUMA_Make_Spec_FS -extra_annot_labels lausanne2008 -NIFTI -sid $sub

This should give me what I want (an a2009 atlas, and a lausanne atlas which was created earlier, aligned to the original T1 that went into freesurfer). Am I on the right track here?

Hi-

That seems reasonable.

I was initially wondering about resampling the NODDI data onto the FS output grid, instead of the opposite, so that you avoid the NN interpolation of the ROIs. But probably the results will be quite similar in either case.

–pt

I can report some success with v2.2.1. The REN files for aparc and a2009 populate fine. However, it does not appear to grab the lausanne flag to make the new lausanne atlas REN files. The lausanne atlas is a further parcellation of a2009.

The command I run is:

e.g., @SUMA_Make_Spec_FS -extra_annot_labels lausanne2008_aparc -NIFTI -fs_setup -sid 1130911

In the past, I edited the original @SUMA_Make_Spec_FS program to include the lausanne file: e.g.,

set other_candidates = ( T1 aparc+aseg lausanne2008_aparc+aseg aparc.a2005s+aseg aparc.a2009s+aseg aseg.auto aseg brain.finalsurfs brain brainmask.auto brainmask norm nu nu_noneck lh.ribbon rh.ribbon wm.asegedit wm wm.seg )

and another part of the script to add “other” candidate lausanne2008_aparc.

This would make .nii from the .mgz. That old @SUMA version did not have the -extra_annot_labels flag.

But the new flag seems to be trying to do this in a more straightforward way, so I think I’m just not telling it something it needs.

I made the lausanne atlas using freesurfer commands. In the FS label folder, the following files are available:

lh.lausanne2008_aparc.annot
lh.lausanne2008_aparc_label.annot
rh.lausanne2008_aparc.annot
rh.lausanne2008_aparc_label.annot

Is there anything else I should add to the @SUMA_Make_Spec_FS command, or should I try editing the original program to look for the lausanne files as I did before?

Hi, Anthony-

Did you do something to generate the Lausanne2008 parcellation from FS output? Everything I have seen online seems to suggest that some other program is needed to generate it. I tried to find anything with the name “lausanne” (or even “ausanne”) in the standard FS v6 output directory from “recon-all”, and failed to find anything.

Note that even with the Lausanne atlas passed along as NIFTI output of @SUMA_Make_Spec_FS, there would be no renumbered (“REN”) output for that, because no renumbering tables exist for it. We could discuss making something like that, but I have never heard of the Lausanne 2008 parcellation and would need some guidance/input.

–pt

Hello Paul,

I got everything to work and now I understand the pipeline a little better. I am putting the code up on Github and will send the link when it is up. Basically the Lausanne is the freesurfer parcellation, further parcelled into finer bits. So IMO it is a better parcellation because enormous ROIs like superior frontal gyrus are more fine-grained. And of course you can always combine smaller bits to larger ROIs. I used parts of the procedure detailed here: https://github.com/mattcieslak/easy_lausanne.

After looking at your code more carefully, I did figure out that it wouldn’t output the REN file, but the 3drefit step you suggested worked, and I compared the output with the a2009 REN label. So it seems to work well. I would suggest some additions to AFNI code in the future–maybe a more streamlined, better thought-out process than I came up with (I am not a good programmer). I’ll post the link in case others want to use/modify the code in the meantime. Thanks for the help!

Anthony

Hi, Anthony-

OK, thanks for the info. We can discussing processing and functionality updates, sure. And if you want me to take a look at the lausanne output, I’d be happy to do so if you upload a processed dset.

Note that for inflated ROIs in a controlled manner (not overlapping each other or possibly not even other masks of interest), AFNI has 3dROIMaker.

–pt