function dop=dopSumReport(dop)
% dopOSCCI Mark II: dopSumReport ~ 29-10-2010 (last edit)
%
% individual report on the dopOSCCI summary
%

% -------------------------------------------------------------------------
%     'dopOSCCI' summarises functional transcranial Doppler ultrasonography
%     (fTCD) data.  The primary function of the software is to assess the
%     hemispheric lateralization of cognitive function.
%
%     Copyright (C) 2011 the Chancellor, Masters and Scholars of the
%     University of Oxford.
% 
%     This program is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     (at your option) any later version.
% 
%     This program is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
% 
%     You should have received a copy of the GNU General Public License
%     along with this program.  If not, see <http://www.gnu.org/licenses/> 
%     or write to the Free Software Foundation, Inc., 51 Franklin Street,
%     Fifth Floor, Boston, MA 02110-1301, USA.
%
%     Authors: Nic Badcock, Georgina Holt, Anneka Holden, & Dorothy Bishop.
%       contact: nicholas.badcock@gmail.com
%
%     Type 'dopOSCCIlicense' for license details or see dopOSCCIlicense.txt
%
try
    %% title
    dop.tmp.txtFill='--------------------------------------------------------';
    fprintf('\n%s\n%s\n%s\n\t%s\n\n',...
        dop.tmp.txtFill,dop.tmp.txtFill,...
        ['Summary completed for: ',dop.sum.fileName],...
        ['(from: ',dop.sum.filePath,'\)']);
    if ~dop.sum.skip && ~dop.sum.quit
        %% event trials found + missing data
        for i=1:length(dop.mk.evNames)
            dop.tmp.en=dop.mk.evNames{i}; % tmp event name
            disp(dop.mk.(dop.tmp.en).report);
            %% > if missing
            if isfield(dop.stack,'report')
                if isfield(dop.stack.report,dop.tmp.en)
                    if isfield(dop.stack.report.(dop.tmp.en),'start')
                        disp(dop.stack.report.(dop.tmp.en).start);
                    end
                    if isfield(dop.stack.report.(dop.tmp.en),'finish')
                        disp(dop.stack.report.(dop.tmp.en).finish);
                    end
                end
            end
        end
        
        %% LI report
        % dop.tmp.es={'all','scrn'}; % epoch selection
        for i=1:length(dop.scrn.labels) %length(dop.def.saveEpochSelection) %dop.tmp.es)
            if dop.scrn.saveData(i)
                dop.tmp.es=dop.scrn.labels{i};
                fprintf('%s\n',['Laterality Index: (',dop.tmp.es,' epochs)']);
                for j=1:length(dop.mk.evNames)
                    if dop.def.evType(j)
                        dop.tmp.en=dop.mk.evNames{j}; % tmp event name
                        fprintf('\t%s\n',['Event: ',dop.tmp.en]);
                        disp(dop.li.(dop.tmp.en).(dop.tmp.es).report);
                    end
                end
            end
        end
    else
        if dop.sum.skip
            %             fprintf('\t%s\n','Summary skipped:');
            dopSkipNotes('fileTxt','A4skipRecord',... % could be A4 but not renaming Mat file now
                'saveDir',[dop.def.saveDir,'notes\'],'saveNotes',dop.def.saveNotes(3),...'fileNameLoc',dop.sav.skipNotesFileNameLoc,...
                'skipList',{dop.sum.fileNameLoc},...
                'skip',dop.sum.skip,'skipReason',dop.sum.skipReason,...
                'saveData',dop.def.saveData);
        else
            fprintf('\t%s\n','Summary quit');
        end
    end
    fprintf('%s\n\n',dop.tmp.txtFill);
catch err
    %% catch dopOSCCI error
    save(dopOSCCIdebug(mfilename));throw(err);
end