generating all ROIs from on atlas

Hi everyone,

I'm trying to extract all ROIs from the AICHA atlas using the 3dcalc command.
and because I don't feel like type all ROIs one by one; I'm trying to loop that in with this command: (and for now trying only with one of them say the third ROI)

#for i in [1..384]
i = 3
3dcalc -a AICHAJoliot2015_space-MNI152NLin6_res-2x2x2.nii'<['$i']>' -expr 'a' -prefix ROI/ROI$i

My problem is that with the way I set it up , it can find the file because want I want to use:

is replaced by

like it's deleting the external quote.
Do you know how I can solve that?


We don't have exactly that syntax. The range selector you want is between the "less than" and "greater than" angle brackets. The square brackets are used to specify volume indices instead. If you want only data with a value of 3, then you would use "<3>". If you wanted both 3 and 7, then you might use "<3,7>". A range of values can be specified too "<3..24>". BTW, atlases or other labeled datasets in AFNI can have specific labels for each value, and those can be specified by their labels too, e.g. "". Volume numbers go in the square brackets - get the third volume (0-based) with "[2]". It's easier to put the quotes with something like this:

3dcalc -a ~/Downloads/AICHA.nii"<$i>" -expr a -prefix testroi$i.nii.gz

BTW, there may be a more recent version of that atlas online.

1 Like

Hi, Lysianne-

Do you want to take an atlas, which is one 3D volume of N ROIs, and split/burst it into N separate 3D volumes, each containing only one ROI?


Yes this is what I want to do
so they I can do pair-wise ROIs correlation and enter that into FATCAT

Yes that worked! I think I tried all quotes options but that one, thank you very much!

1 Like

Just to note, the single quote probably blocked the intepretation of the $, depending on the shell being used.


1 Like