Dear Rali,
Yes, your procedure should work for a mask. However, a procedure like this for the mean_FA will only give correct results if all chunks have the same number of subjects. If you are unfortunate and have a prime number of subjects, then there would be no solution except discard some of them... An alternative that doesn't require explicitly dividing the subjects into chunks would be to increment the mask and the mean_FA for each subject inside a loop. Below is a sketch, you can modify according to your needs (there are probably other solutions too):
1) Threshold the template (or the image of any subject) using a very high number, guaranteeing that nothing survives, so it contains only zeroes at the beginning of the loop:
fslmaths template.nii.gz -thr 20000 toincrement.nii.gz
2) Make a copy, now full of ones (intersection goes with multiplication, and 1 is neuter):
fslmaths toincrement.nii.gz -add 1 tomultiply.nii.gz
3) Start a counter in case you don't want to count how many subjects you have:
c=0
4) Loop over all subjects:
for i in ${list_images} ; do
fslmaths ${i} -max 0 -bin -mul tomultiply.nii.gz tomultiply.nii.gz -odt char
fslmaths ${i} -max 0 -add toincrement.nii.gz toincrement.nii.gz -odt double
c=$(expr ${c} + 1)
done
5) At the end of the loop, the mask is simply the file named "tomultiply.nii.gz", and you can rename it (use immv for extension-free renaming):
mv tomultiply.nii.gz mask.nii.gz
6) The mean FA is the file named "toincrement.nii.gz" divided by the number of subjects (counter), with the mask applied:
fslmaths toincrement.nii.gz -div ${c} -mas mask.nii.gz mean_FA.nii.gz
Note that a for-loop is slower than averaging over the 4D (-Tmean), but the benefit is that you can operate in very large datasets without splitting the sample in subgroups all of the same size.
Hope this helps!
All the best,
Anderson