function dop=dopGrpSet(dop)
% dopOSCCI Mark II: dopGrpnSet ~ 21-11-2010 (last edit)
%
% setup grouping file
%
fprintf('%s\n',['Running ',mfilename]);
try
    if dop.def.grpFileChk % request to check session file
        if iscell(dop.def.grpFileNameLoc)
            fprintf('\t%s\n\t\t%s\n','Checking Grouping file:',dop.def.grpFileNameLoc{1});
        else
        	fprintf('\t%s\n\t\t%s\n','Checking Grouping file:',dop.def.grpFileNameLoc);
        end
        
        dop.grp=dopGrpChk(dop.def.grpFileNameLoc,...
            'fileList',dop.data.fileList,'dataDir',dop.def.dataDir);
        dop.def.grpFileChk=dop.grp.okay;
        if length(dop.data.fileList)>length(dop.grp.fileList)
            fprintf('\n\t%s\n\t\t%s\n\t\t%s\n',...
                'Current list is longer than group list,',...
                'therefore some screening has taken place.',...
                'Using the Group list.');
            dop.data.fileList=dop.grp.fileList;
        end
        if dop.grp.nGrps==1
            fprintf('\n\t%s\n\t\t%s\n\t\t%s\n',...
                ['Only single group (',dop.grp.grpNames{1},')'],...
                'Assuming group function used as file screening,',...
                '> cancelling group summary but updating file list');
            dop.data.fileList=dop.grp.fileList;
            dop.def.grpFileChk=0;
        end
    end
catch err
    %% catch dopOSCCI error
    % 
save(dopOSCCIdebug(mfilename));throw(err); 
%     dopOSCCIcrash(err,dop,mfilename);
end