function dop=dopDataCalc(dop)
% dopOSCCI Mark II: dopDataCalc~ 28-10-2010 (last edit)
%
% calculate data summaries...
%
% Includes:
% - dopDataIndexCalcSetup
% - dopDataDropCalcSetup
% - dopDataLIcalcSetup
% - dopDataSplitHalfCalcSetup
%

% -------------------------------------------------------------------------
%     '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
    if ~dop.sum.skip && ~dop.sum.quit
        %% selected range descriptives
        % base, poi, epoch
        %     dop=dopDataIndices(dop.stack);
        dop.ind=dopDataIndexCalcSetup(dop.stack,dop.filter,...
            'screen',dop.scrn,'sampleRate',dop.def.downHertz,...
            'evType',dop.def.evType,'evMatch',dop.def.evMatch,...
            'saveEpoch',dop.def.saveEpoch);
        %% dropout
        dop.drop=dopDataDropCalcSetup(dop.raw.stack,dop.filter,...
            'screen',dop.scrn,'sampleRate',dop.def.downHertz,...
            'evType',dop.def.evType,'evMatch',dop.def.evMatch,...
            'saveEpoch',dop.def.saveDropSelEp);
        
        %% laterality indices
        dop.li=dopDataLIcalcSetup(dop.stack,dop.filter,'actWin',dop.def.actWin,...
            'screen',dop.scrn,'sampleRate',dop.def.downHertz,...
            'evType',dop.def.evType,'saveEpoch',dop.def.saveEpoch,...
            'epochGraph',sum(dop.def.graphs(:,4)));
        
        %% laterality indices
        dop.sph=dopDataSplitHalfCalcSetup(dop.stack,dop.filter,'actWin',dop.def.actWin,...
            'screen',dop.scrn,'sampleRate',dop.def.downHertz,...
            'evType',dop.def.evType,'saveEpoch',dop.def.saveEpoch,...
            'splitOptions',dop.def.splitOptions,'splitBal',dop.def.splitBal,...
            'splitCalcSave',dop.def.splitCalcSave,'splitLabels',dop.def.splitLabels);
        
    end
catch err
    %% catch dopOSCCI error
    save(dopOSCCIdebug(mfilename));rethrow(err);
end




