function dop=dopSessionSet(dop)
% dopOSCCI Mark II: dopSessionSet ~ 16-11-2010 (last edit)
%
% setup information for multiple session summary:
% - that is, if dop.def.sesFileChk == 1, see if we can read in the session
% file (dop.def.sesFileNameLoc).  This should contain a series of columns
% of doppler file names, where each row is a different individual and each
% column is a separate session.
%
% dopSessionSet and dopSessionCollect operate by rearraning the
% dop.data.fileList variable in order of individual session files.  The
% data from each session is 'stacked' to create a single stack consisting
% of all the sessions and then the summary functions are re-run on this
% data.
%
% therefore, any messing with the dop.data.fileList after this point
% (dopSessionSet) will mess up the session summary.
%
fprintf('%s\n',['Running ',mfilename]);
try
    if dop.def.sesFileChk % request to check session file
        if iscell(dop.def.sesFileNameLoc)
            fprintf('\t%s\n\t\t%s\n','Checking session file:',dop.def.sesFileNameLoc{1});
        else
            fprintf('\t%s\n\t\t%s\n','Checking session file:',dop.def.sesFileNameLoc);
        end
        dop.ses=dopSesChk(dop.def.sesFileNameLoc,...
            'fileList',dop.data.fileList,'dataDir',dop.def.dataDir);
        dop.def.sesFileChk=dop.ses.okay;
        dop.ses.ind=0;
        if dop.ses.okay && isfield(dop.ses,'fileList') % update the file list
            dop.data.fileList=dop.ses.fileList;
            dop.ses.ind=0; % this is the current individual
            dop=dopSessionReset(dop);
            %             dop.ses.session=1; % always start in the first session for saving
            %             dop.ses.combinedName=[];
            %             dop.ses.bal=[0 0];
            %             if dop.def.saveEpochSelection(3)
            %                 dop.ses.bal(1)=1;
            %                 dop.def.saveEpochSelection(3)=0;
            %                 % this can only run during summary session save summary
            %                 % see dopSessionCollect
            %             end
            %             if dop.def.saveGraphData(3)
            %                 dop.ses.bal(2)=1;
            %                 dop.def.saveGraphData(3)=0;
            %                 % this can only be run for combined session summary
            %             end
        else
            dop.def.sesFileChk=0; % error in dopSessionChk somewhere
        end
        %     else
        %         % don't want to save this info...could be altered in the save file
        %         % but this is more straight forward at this stage.
        %         dop.def.saveGraphData(3)=0;
        %         dop.def.saveEpochSelection(3)=0;
    end
catch err
    %% catch dopOSCCI error
    %
save(dopOSCCIdebug(mfilename));throw(err); 
    %     dopOSCCIcrash(err,dop,mfilename);
end