Which program should I use to compute a voxel by voxel standard deviation across subjects?
I have a DTI measure similar to FA and I would like to see the mean and standard deviation (across participants) for this measure for all voxels in the brain.
A) first, concatenate all the 3D volumes of your subjects across the “time” axis, and then
B) compute the voxelwise stat (mean, stdev, etc.) for each voxel.
To do “A”:
3dTcat -prefix ALL_SUBJ.nii.gz DSET_000 DSET_001 DSET_002 ...
where DSET_* are your FA-like volumes for each subject; I’m assuming each one is just a 3D volume; if that is not the case, you could use subbrick selectors, like: DSET_000’’ DSET_001’’ DSET_002’', there instead.
To do “B”:
3dTstat -mean -prefix STAT_mean.nii.gz ALL_SUBJ.nii.gz
3dTstat -stdev -prefix STAT_stdev.nii.gz ALL_SUBJ.nii.gz
… and see the full list of stats that can be computed in 3dTstat.
I will add on to Paul’s advice here.
Consider ‘-stdevNOD’ if you do not want detrending across datasets before computing the standard deviation.
Catenated datasets. Many AFNI programs including 3dTstat can take quoted and wildcard datasets as a “single” input dataset. See the 3dcalc help section on “CATENATED AND WILDCARD DATASET NAMES”.
3dTstat -stdevNOD -prefix test1sdNOD.nii.gz 'mysubjs/*/PA*.nii.gz'
- 3dMean. If you have a lot of datasets to compute over, this program will do the computations more efficiently because it only loads one dataset at a time rather than all of them at the same time. The option “-sd” can be used to compute the standard deviation.
3dMean -sd -prefix testsdsd.nii.gz mysubjs/*/PA*.nii.gz
Thank you! I think the 3dmean program is what I was looking for.
Well, I learned some interesting things here, too!