Hi, Emily-
I will assume that each "mask" file actually still has the probability value in it-- that isn't just a binary map.
First, you can provide the set of files to 3dTcat to make a single, 4D data set. Then, use 3dTstat to make a mask where there are nonzero voxels at any point across time; finally, provide the concatenated dataset and mask to 3dTstat, and have it make a new dataset whose values tell you which brick contains the maximum value across "time" at each voxel (**Note that I have now edited my answer to correct it, as per my next message in this thread; apologies for confusion. --pt**):
# concatenate data sets of interest
3dTcat -prefix ALLCAT.nii.gz DSET1 DSET2 DSET3 ...
# make a mask of anywhere that is nonzero across the original data sets
3dTstat -nzcount -prefix MMM.nii.gz ALLCAT.nii.gz
# find the volume index+1 of the subbrick with the maximum value, per voxel
3dTstat -argmax1 -mask MMM.nii.gz -prefix MAP ALLCAT.nii.gz
*Note* tthe use of argmax1: This is because AFNI starts counting from zero (as all great programs do!), and if the [0]th volume contains the maximum, then it would put a zero at that voxel, which would be indistinguishable from the hoi polloi of the great empty voxels. So, wherever there is a "1" in the final MAP dset, that is where the [0]th volume in the list had greatest value; wherever there is a "2", the [1]st volume had the max value, etc.
--pt
Edited 1 time(s). Last edit at 08/27/2018 04:10PM by ptaylor.