The method we use is
(1) run 3dSkullStrip to produce a "pure" brain volume
(2) run 3dSeg to produce a classified brain volume:
3dSeg -anat anat.nii -mask AUTO -classes 'CSF ; GM ; WM' -bias_classes 'GM ; WM' -bias_fwhm 25 -mixfrac UNI -main_N 5 -blur_meth BIM
(3) the output from 3dSeg is in a directory called Segsy -- the files in there that contains the classification for each voxel are dataset Classes+tlrc.* -- to compute the gray-only mask, pick out all voxels with value=2
3dcalc -a Classes+tlrc -expr 'equals(a,2)' -prefix maskGM