function GlmMask(varargin)   

%Scrip to explicitly specify a mask of voxels for glm esimation and bypass
%SPM's spm_global thresholding altogether
%
% FORMAT GlmMask   
% Asks for files and steps to be done.
%
% FORMAT GlmMask(cfg, mask)
% cfg,mask - fullpaths to the corresponding SPMcfg.mat and bigmask
%
% ---------------------------------------------------------
%Sue Whitfield    4/21/03




         CWD = pwd;

if nargin < 1
        cfg_file = spm_get(1,'SPMcfg.mat',...
									'Select SPMcfg.mat file to modify',CWD);
else
    cfg_file = varargin{1};
end
if nargin < 2
        bigmaskimg=spm_get(1,'*.img',...
								   'Select a mask image with voxels to include');
else
    bigmaskimg = varargin{2};
end
                               
        cfgWD=fileparts(cfg_file);
		segWD=fileparts(bigmaskimg);
        
        
        cd(cfgWD); load(cfg_file);
		xM.TH = ones(size(xM.TH))*(-Inf);
		vol=spm_vol(bigmaskimg);
 	   xM.VM=vol;
		
		save SPMcfg xM -append;
        
        
        fprintf('\n\nDone. The SPMcfg.mat file in \n%s\n',cfgWD);
		fprintf('has been modified. Estimating the model from it will\n');
		fprintf('include all voxels in the brain, as defined by the\n');
		fprintf('mask image file.\n\n');
        
        
        
        
         spm_spm(VY,xX,xM,F_iX0,Sess,xsDes)