Hey all:
I have 2 independent questions that have arisen from the same problem.
Basically I’m trying to code some TCSH scripts with cool tricks that make the scripts more “all-purpose” and have gotten stuck in a few places.
- Firstly I was trying to make anatomical masks with atlases for which certain anatomical areas are made of multiple parts from the atlas (e.g. NOT using the CA_ML_18_MNI). So for example, I want to make a bilateral amygdala mask using the Brainnetome atlas. Question 1: Is there anyway to put multiple inputs into the -mask_atlas_region so I can get multiple masks outputted into one dataset with the same mask values? I tried the following:
whereami -mask_atlas_region Brainnetome_1.0::lAmyg_left -mask_atlas_region Brainnetome_1.0::mAmyg_left -mask_atlas_region Brainnetome_1.0::lAmyg_right -mask_atlas_region Brainnetome_1.0::mAmyg_right -prefix test
But it only outputs a mask of the final -mask_atlas_region input (i.e. the mAmyg_right in this example)
- Since I didn’t think the above was possible I went ahead and made a showy-offy loop with variable arrays to make each individual mask (i.e. 4 amygdala masks corresponding to the inputs above). Then I went to use 3dcalc to put them all into one dataset. My second question is, is it at all possible to write a 3dcalc command if you have a variable number of inputs depending on the value of a variable? For example, if I want to make bilateral amygdala and ACC masks using the general idea of the code above but the amygdala is made up of 4 masks and the ACC is made up of 6 masks. Can one 3dcalc command work with variable input like this? It doesn’t seem like it but I just wanted to check.
The best I did so far was the following: Assume I have already outputted 4 amygdala and 4 A32 (ACC) masks
set shortROI = {"Amy","A32"}
set indROI_array =
set max_elements = 4
foreach kk ( $shortROI )
foreach files ( *HEAD* )
if ( $files =~ *${kk}*) then
set indROI_array = ( $indROI_array $files )
echo $indROI_array
endif
## Only way I can think to get a useful 3dcalc command out of this is by half hard-coding.
## Until I figure out something better set a magic number and error if array has more elements than that
if ( ${#indROI_array} > $max_elements ) then
echo " ***ERROR*** YOUR ROI HAS MORE THAN $max_elements. YOUR ROI CONTAINS ${#indROI_array} PIECES."
echo " ***ERROR*** PLEASE EDIT CODE TO OVERCOME THIS"
echo " ***ERROR*** SINCE I AM A DUMBASS AND COULDN'T THINK OF HOW TO MAKE"
echo " ***ERROR*** 3dcalc DO THIS IN A NOT STUPID WAY."
exit 1
elseif
3dcalc -a ${tempdir}/$indROI_array[1] -b ${tempdir}/$indROI_array[2] -c ${tempdir}/$indROI_array[3] -d ${tempdir}/$indROI_array[4] -expr 'a+b+c+d' -prefix ${ROIdir}/bilateral_${shortROI}_MNI
endif
end
set indROI_array =
end
This is obviously not impeding my analysis in any way since i can just make these masks in one shot on the command line but I’ve actually wondered this about 3dcalc more than once and figured I’d finally like to put this to bed.
Thanks!
Lauren