function dop=dopOSCCIsummary(dop)
% dopOSCCI Mark II: dopOSCCIsummary ~ 27-10-2010 (last edit)
%
% dopOSCCI's summary loop - once everything is set up, this starts the
% summary running.
%
% Includes functions:
%     dop=dopSelectFile(dop);
%     dop=dopGetData(dop);
%     dop=dopEventData(dop);
%     dop=dopEpochScreen(dop);
%     dop=dopIndexFilters(dop);
%     dop=dopDataCalc(dop);
%     dop=dopBehSummary(dop);
%     dop=dopSaveSum(dop);
%     dop=dopGraphDataSave(dop);
%     dop=dopGraph(dop);
%     dop=dopSumReport(dop);
%     dop=dopSessionCollect(dop);
%

% -------------------------------------------------------------------------
%     '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
%
dop.sum.count=0; % record of the file number being summarised
dop.sum.finish=0; % finish variable which controls the summary loop
dop.sum.quit=0; % quit variable to break the while summary loop
dop.sum.skip=0; % skip variable to skip and individual file, if e.g., no markers or suitable trials
dop.sum.totalFiles=length(dop.data.fileList);


while ~dop.sum.finish && ~dop.sum.quit && dop.sum.totalFiles %|| ...
    %             dop.test && dop.sum.count % just single file
    %% select file
    dop=dopSelectFile(dop);
    
    %% import & process data
    dop=dopGetData(dop);
    
    %% organise data
    % Includes:
    % - dopEventMarks (find the appropriate markers)
    % - dopEventStack (stack the data into events/trials)
    % - dopEventFilter (create filter for base and poi selection)
    % - dopEventActRej (creates epoch screen based upon activation
    %       rejection values, see dopTaskDef)
    % - dopEventBaseCorrect (runs baseline correction adjustment)
    % - dopEventDifference (calculates difference between the left and right
    %       doppler channels)
    % - dopEventAverage (calculates average activation of left & right
    %       channels)
    % - dopEventScreen (creates event/epoch screening array)
    
    dop=dopEventData(dop);
    
    %% screening
    dop=dopEpochScreen(dop);
    
    %% index filters
    dop=dopIndexFilters(dop);
    
    %% calculate summaries
    dop=dopDataCalc(dop);
    
    %% behavioural summary
    dop=dopBehSummary(dop);
    
    %% save data
    dop=dopSaveSum(dop); % save the summary data to file
    
    %% save graph data
    dop=dopGraphDataSave(dop);
    
    %% create graphs
    dop=dopGraph(dop);
    
    %% individual summary report
    dop=dopSumReport(dop);
    
    %% sessions
    dop=dopSessionCollect(dop);
    
end

