function varargout=dopOSCCIdef(varargin)
% dopOSCCI Mark II: dopOSCCIdef ~ 2-June-2011 (last edit)
%
% Sets, gets, or updates (set and gets) dopOSCCI task defintion
% information.  The task definition is information specific to an
% experimental procedure or task that is to-be-summarised.
%
% It includes information and the timing of the procedure, particular
% settings, and requirements for the processing.  Each of these can be
% modified which will in turn modify the ouputs obtained.
%
% dopTaskDef requires a series of inputs which can be made manually at the
% command line or automatically through the dopOSCCI gui (see dopOSCCI).
%
% - the basic requirements is a taskName which is used to name the task
% definition file and therefore can be used to save, retrieve, or update
% the definition information.
%
% The dopTaskDef function itselfs hosts a series of default settings which
% will be used in the absence of any specific inputs.
%
% Update:
%  - including the word 'update' in the inputs will attempt to retrieve a
% saved file and update the contents based upon new inputs.
% Reset:
%  - including the word 'reset' in the inputs will attempt to reset all of
%  the variables to default values.
%
%
% Input options include: (default values)
%
%     inputs.turnOn={'update','reset'};
%     inputs.turnOff={};
%     inputs.defaults=struct('taskName','dopOSCCIdemo',... % task definition file name/task description label
%         'defFileNameLoc',[],...
%         'dataDir',[],...'C:\dopOSCCIdemo\rawData\',...%[],... % directory where Raw doppler files are located
%         'saveDirBase',[],... % base save directory, use this to create task save directory (dop.def.saveDir)
%         'sumDescrip',[],... % summary description (see dopSaveDirDescription)
%         'epochs',12,...% number of doppler event epochs to search for in file/s
%         'sep',48,...% minimum separation between markers in seconds
%         'epoch',[-12 40],... % examination period relative to marker/s seconds
%         'base',[-10 0],... % baseline period relative to marker/s seconds
%         'poi',[25 35],... % period of interest relative to marker/s seconds
%         'actWin',2,...% activation window in seconds, averaged within
%         'actRej',[70 130],... % activation rejection range % doppler velocity - normalized to 100
%         'actSep',20,... % actiavation separation between left and right channels % blood flow velocity
%         'dopChs',[1 2],... % left and right doppler channels
%         'evChs',3,... % event marker channel - base/stim marker
%         'evType',2,...% event type: 0 = base, 1 = stim only, 2 = both
%         'evMatch',0,...% if event type = 0 or 1, it needs a match with another 1 or 0 type, only 2 is independent
%         'evNum',1,... % number of event makers
%         'downHertz',25,... % down sample raw data frequency
%         'markHeight',1000,... % height of Multi-dop trigger/marker pulses - look for pulses greater than this (see dopFindRawMarkers)
%         'trim',1,... % trim raw data by lower and upper epoch values
%         'epochNorm',1,... % normalise data based upon trial epochs
%         'inShort',0,... % include epochs with short inadequate data - recommend not
%         'graphs',zeros(2,6),... [1 1 1 0 0 0; 0 0 0 0 0 0],...zeros(2,6),...);% row 1 = save, row 2 = display for each graph type  [1 1 1 0 0 0; 0 0 0 0 0 0],...
%         'graphFolder',[1 1 1 1 1 1],... % save graphs into separate folders for each type
%         'graphFolderInd',[0 0 0 1 0 0],... % include individual file text in folder name
%         'graphFolderBeh',[0 1],... variable and level folders
%         'fileSel',0,... % file selection in list might change this...see dopGenSetup 27-10-10
%         'fileType','TX',... % type of doppler data file TX = analogue, .EXP = digital (I think...)
%         'scrnFileChk',0,... % check for manual screen file
%         'grpFileChk',0,...% check for group summary file
%         'behFileChk',0,... % check for behavioural summary file
%         'sesFileChk',0,... % check for session summary file
%         'scrnFileNameLoc',[],... % screen summary file name location
%         'grpFileNameLoc',[],...'C:\dopOSCCIm2\taskData\dopOSCCIdemoGroups.txt',... % group summary file name location
%         'behFileNameLoc',[],... % behavioural summary file name location
%         'sesFileNameLoc',[],... % session summary file name location
%         'saveEpochSelection',[0 0 0 0 1 1],... % save data from all, length, act, man, comb (dat + act + man), & balanced epochs (session only)
%         'saveEpochSelectionGraph',[0 0 0 0 1 1],... % save graph data [all length act man comb bal] balanced for session summary
%         'saveGraphDataChs',[1 1 1 1],... % left right, diff, avg (left right)
%         'saveGraphDataVert',0,... % save a vertical arrangment of graph data files
%         'saveDescrip',[1 1 1 1 1 1 0 0 0 0],... % save descriptives (see saveDescripLabels below & dopDataLIcalc function)
%         'save1sample',[1 0 0 0 0 0 0],... % save one-sample t-test sig & effect size (see dopDataLIcalc)
%         'save2sample',[0 0 0 0 0 0 0],... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
%         'saveRank',[0 0 0 0 0],...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
%         'save1norm',[0 0 0 0],... % save normality test info for difference LI distribution
%         'save2norm',[0 0 0 0 0 0 0 0],... % save normality test info for left & right LI distribution %
%         'saveEpoch',0,...);% save data for each epoch; i.e., each trial - switched on by other things below
%         'saveEpochLI',[0 0 0 0 0 0 0 0 0],... % indices to be saved for each epoch LI (mean) LI latency
%         'saveEpochInd',zeros(1,9),...% 'mean','std','sem','CI95','min','max','rms','med','iqr' % selection, saveIndexChs required also
%         'saveEpochIndFilter',[0 0 0],... % epoch, base, poi
%         'saveEpochIndCh',[0 0 0 0],... left, right, dif, avg
%         'saveData',1,...); % logical save data to files
%         'saveIndexChs',[0 0 0 0],... % on/off save left, right, difference indices, average
%         'saveIndexFilt',[0 0 0],... % filter = epoch, base, poi, absMax, absMaxPOI
%         'saveIndices', zeros(1,9),...% 'mean','std','sem','CI95','min','max','rms','med','iqr' % selection, saveIndexChs required also
%         'saveIndexExtraChs',[0 0 0 0],... % on/off save left, right, difference indices, average
%         'saveIndexExtraChFilt',[0 0 0 0],... % filters based on left, right, difference indices, average
%         'saveIndexExtraTypeFilt',zeros(1,8),...{'AbsMaxPOI','AbsMax','MaxPOI','Max','AbsMinPOI','AbsMin','Min','MinPOI'}
%         'saveIndicesExtra', zeros(1,10),...% 'time','mean','std','sem','CI95','min','max','rms','med','iqr' % selection, saveIndexChs required also
%         'saveIndexExp',zeros(1,2),... % Goodness of Recording, LI variability see dopDataIndexCalc
%         'saveNotes',[1 1 1],... % [overall inidividual & skip] running notes - requires dop.def.saveData=1 (see dopSaveNotes)...Did  6-Jan-2011
%         'defFileNotes',[1 1],... % move view only and mat defintion files to notes
%         'saveBehData',1,... % save the behavioural data
%         'saveBehGraphData',1,... % save the behavioural graph data
%         'saveSesGraphData',[0 1],... % regular scrn and balanced screen - really just want balanced
%         'splitCalcSave',[0 0],...); % actually do the calculation & save data
%         'splitOptions',[1 0],...); % Split half odd v even, random selection
%         'splitBal',1,...); % balance the number of epochs in the split
%         'saveDescripSplit',[1 1 1 1 1 1 0 0 0 0],... % save descriptives (see saveDescripLabels below & dopDataLIcalc function)
%         'save1sampleSplit',[0 0 0 0 0 0 0],... % save one-sample t-test sig & effect size (see dopDataLIcalc)
%         'save2sampleSplit',[0 0 0 0 0 0 0],... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
%         'saveRankSplit',[0 0 0 0 0],...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
%         'save1normSplit',[0 0 0 0],... % save normality test info for difference LI distribution
%         'save2normSplit',[0 0 0 0 0 0 0 0],... % save normality test info for left & right LI distribution %
%         'saveIndexChsOverall',[0 0 0 0],... % on/off save left, right, difference indices
%         'saveIndexFiltOverall',[0 0 0],... % filter = epoch, base, poi
%         'saveIndicesOverall', [0 0 0 0 0],...% mean, std, min, max, & rms % selection, saveIndexChs required also
%         'saveIndexOverallExtraChs',[0 0 0 0],... % on/off save left, right, difference indices, average
%         'saveIndexOverallExtraChFilt',[0 0 0 0],... % filters based on left, right, difference indices, average
%         'saveIndexOverallExtraTypeFilt',zeros(1,8),...{'AbsMaxPOI','AbsMax','MaxPOI','Max','AbsMinPOI','AbsMin','Min','MinPOI'}
%         'saveIndicesOverallExtra', zeros(1,10),...% 'time','mean','std','sem','CI95','min','max','rms','med','iqr' % selection, saveIndexChs required also
%         'saveDescripOverall',[1 1 1 1 1 1 0 0 0 0],... % save descriptives (see saveDescripLabels below & dopDataLIcalc function)
%         'save1sampleOverall',[0 0 0 0 0 0 0],... % save one-sample t-test sig & effect size (see dopDataLIcalc)
%         'save2sampleOverall',[0 0 0 0 0 0 0],... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
%         'saveRankOverall',[0 0 0 0 0],...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
%         'save1normOverall',[0 0 0 0],... % save normality test info for difference LI distribution
%         'save2normOverall',[0 0 0 0 0 0 0 0],... % save normality test info for left & right LI distribution %
%         'saveDescripSplitOverall',[1 1 1 1 1 1 0 0 0 0],... % save descriptives (see saveDescripLabels below & dopDataLIcalc function)
%         'save1sampleSplitOverall',[0 0 0 0 0 0 0],... % save one-sample t-test sig & effect size (see dopDataLIcalc)
%         'save2sampleSplitOverall',[0 0 0 0 0 0 0],... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
%         'saveRankSplitOverall',[0 0 0 0 0],...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
%         'save1normSplitOverall',[0 0 0 0],... % save normality test info for difference LI distribution
%         'save2normSplitOverall',[0 0 0 0 0 0 0 0],... % save normality test info for left & right LI distribution %
%         'saveEpochSelQual',[0 0 0 0 1 1],... % epoch selection quality saving  all, length, act, man, comb (dat + act + man), & balanced epochs (session only)
%         'saveGorInd',[0 0],... % save mean max goodness of recordings - left and right channels
%         'saveGorChs',[1 1 0 0],... % left right dif average channels - probably not necessary but option is there
%         'saveGorFilt',[0 1 0],... % epoch, base, poi
%         'saveGorSelEp',0,... % save goodness of recording all epochs yes/no
%         'saveDropInd',[0 0],... % save count percent dropout - left and right channels
%         'saveDropChs',[1 1 0 0],... % left right dif average channels - probably not necessary but option is there
%         'saveDropFilt',[0 1 0],... % epoch, base, poi
%         'saveDropSelEp',0,... % save dropout all epochs yes/no
%         'saveDop',0,... % save the 'dop' structure for offline examinination
%         'closeGui',1,... % gui only setting that closes gui on run function
%         'shortWarn',1,... % warning dialog box when the data is short
%         'finishSound',1); % play finish sound see ...dopOSCCIm2\dopTools\genTools\finishSound.wav
%
%
% -------------------------------------------------------------------------
%     '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
    
    fprintf('\n%s\n',['Running dopOSCCI Task Definition Setup (',mfilename,')']);
    dop=[];
    %% setGetInputs
    % uses generic setGetInputs function to examine inputs provided.
    if numel(varargin)==1
        dop=[];
        if isstruct(varargin{1});
            fprintf('\t%s\n','Single input: assuming ''dop'' structure input');
            dop=varargin{1};
            inputs.varargin=[];
        else
            fprintf('\t%s\n','Single input: assuming ''varargin'' input/s');
            inputs.varargin=varargin;
        end
        if isfield(dop,'inputs')
            fprintf('\t\t%s\n','Found ''dop.inputs'' variable - setting to varargin.')
            inputs.varargin=dop.inputs;
        end
        fprintf('\t\t%s\n','Input List:');
        for i=1:length(inputs.varargin)
            if isnumeric(inputs.varargin{i})
                fprintf('\t\t\t%u\n',inputs.varargin{i});
            else
                fprintf('\t\t\t%s\n',inputs.varargin{i});
            end
        end
    else
        inputs.varargin=varargin;
    end
    
    inputs.turnOn={'update','reset'};
    inputs.turnOff={};
    inputs.defaults=struct('taskName','dopOSCCIdemo',... % task definition file name/task description label
        'defFileNameLoc',[],...
        'dataDir',[],...'C:\dopOSCCIdemo\rawData\',...%[],... % directory where Raw doppler files are located
        'saveDirBase',[],... % base save directory, use this to create task save directory (dop.def.saveDir)
        'sumDescrip',[],... % summary description (see dopSaveDirDescription)
        'epochs',12,...% number of doppler event epochs to search for in file/s
        'sep',48,...% minimum separation between markers in seconds
        'epoch',[-12 40],... % examination period relative to marker/s seconds
        'base',[-10 0],... % baseline period relative to marker/s seconds
        'poi',[25 35],... % period of interest relative to marker/s seconds
        'actWin',2,...% activation window in seconds, averaged within
        'actRej',[70 130],... % activation rejection range % doppler velocity - normalized to 100
        'actSep',20,... % actiavation separation between left and right channels % blood flow velocity
        'dopChs',[1 2],... % left and right doppler channels
        'evChs',3,... % event marker channel - base/stim marker
        'evType',2,...% event type: 0 = base, 1 = stim only, 2 = both
        'evMatch',0,...% if event type = 0 or 1, it needs a match with another 1 or 0 type, only 2 is independent
        'evNum',1,... % number of event makers
        'downHertz',25,... % down sample raw data frequency
        'markHeight',1000,... % height of Multi-dop trigger/marker pulses - look for pulses greater than this (see dopFindRawMarkers)
        'trim',1,... % trim raw data by lower and upper epoch values
        'epochNorm',1,... % normalise data based upon trial epochs
        'inShort',0,... % include epochs with short inadequate data - recommend not
        'graphs',zeros(2,6),... [1 1 1 0 0 0; 0 0 0 0 0 0],...zeros(2,6),...);% row 1 = save, row 2 = display for each graph type  [1 1 1 0 0 0; 0 0 0 0 0 0],...
        'graphFolder',[1 1 1 1 1 1],... % save graphs into separate folders for each type
        'graphFolderInd',[0 0 0 1 0 0],... % include individual file text in folder name
        'graphFolderBeh',[0 1],... variable and level folders
        'fileSel',0,... % file selection in list might change this...see dopGenSetup 27-10-10
        'fileType','TX',... % type of doppler data file TX = analogue, .EXP = digital (I think...)
        'scrnFileChk',0,... % check for manual screen file
        'grpFileChk',0,...% check for group summary file
        'behFileChk',0,... % check for behavioural summary file
        'sesFileChk',0,... % check for session summary file
        'scrnFileNameLoc',[],... % screen summary file name location
        'grpFileNameLoc',[],...'C:\dopOSCCIm2\taskData\dopOSCCIdemoGroups.txt',... % group summary file name location
        'behFileNameLoc',[],... % behavioural summary file name location
        'sesFileNameLoc',[],... % session summary file name location
        'saveEpochSelection',[0 0 0 0 1 1],... % save data from all, length, act, man, comb (dat + act + man), & balanced epochs (session only)
        'saveEpochSelectionGraph',[0 0 0 0 1 1],... % save graph data [all length act man comb bal] balanced for session summary
        'saveGraphDataChs',[1 1 1 1],... % left right, diff, avg (left right)
        'saveGraphDataVert',0,... % save a vertical arrangment of graph data files
        'saveDescrip',[1 1 1 1 1 1 0 0 0 0],... % save descriptives (see saveDescripLabels below & dopDataLIcalc function)
        'save1sample',[1 0 0 0 0 0 0],... % save one-sample t-test sig & effect size (see dopDataLIcalc)
        'save2sample',[0 0 0 0 0 0 0],... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
        'saveRank',[0 0 0 0 0],...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
        'save1norm',[0 0 0 0],... % save normality test info for difference LI distribution
        'save2norm',[0 0 0 0 0 0 0 0],... % save normality test info for left & right LI distribution %
        'saveEpoch',0,...);% save data for each epoch; i.e., each trial - switched on by other things below
        'saveEpochLI',[0 0 0 0 0 0 0 0 0],... % indices to be saved for each epoch LI (mean) LI latency
        'saveEpochInd',zeros(1,9),...% 'mean','std','sem','CI95','min','max','rms','med','iqr' % selection, saveIndexChs required also
        'saveEpochIndFilter',[0 0 0],... % epoch, base, poi
        'saveEpochIndCh',[0 0 0 0],... left, right, dif, avg
        'saveData',1,...); % logical save data to files
        'saveIndexChs',[0 0 0 0],... % on/off save left, right, difference indices, average
        'saveIndexFilt',[0 0 0],... % filter = epoch, base, poi, absMax, absMaxPOI
        'saveIndices', zeros(1,9),...% 'mean','std','sem','CI95','min','max','rms','med','iqr' % selection, saveIndexChs required also
        'saveIndexExtraChs',[0 0 0 0],... % on/off save left, right, difference indices, average
        'saveIndexExtraChFilt',[0 0 0 0],... % filters based on left, right, difference indices, average
        'saveIndexExtraTypeFilt',zeros(1,8),...{'AbsMaxPOI','AbsMax','MaxPOI','Max','AbsMinPOI','AbsMin','Min','MinPOI'}
        'saveIndicesExtra', zeros(1,10),...% 'time','mean','std','sem','CI95','min','max','rms','med','iqr' % selection, saveIndexChs required also
        'saveIndexExp',zeros(1,2),... % Goodness of Recording, LI variability see dopDataIndexCalc
        'saveNotes',[1 1 1],... % [overall inidividual & skip] running notes - requires dop.def.saveData=1 (see dopSaveNotes)...Did  6-Jan-2011
        'defFileNotes',[1 1],... % move view only and mat defintion files to notes
        'saveBehData',1,... % save the behavioural data
        'saveBehGraphData',1,... % save the behavioural graph data
        'saveSesGraphData',[0 1],... % regular scrn and balanced screen - really just want balanced
        'splitCalcSave',[0 0],...); % actually do the calculation & save data
        'splitOptions',[1 0],...); % Split half odd v even, random selection
        'splitBal',1,...); % balance the number of epochs in the split
        'saveDescripSplit',[1 1 1 1 1 1 0 0 0 0],... % save descriptives (see saveDescripLabels below & dopDataLIcalc function)
        'save1sampleSplit',[0 0 0 0 0 0 0],... % save one-sample t-test sig & effect size (see dopDataLIcalc)
        'save2sampleSplit',[0 0 0 0 0 0 0],... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
        'saveRankSplit',[0 0 0 0 0],...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
        'save1normSplit',[0 0 0 0],... % save normality test info for difference LI distribution
        'save2normSplit',[0 0 0 0 0 0 0 0],... % save normality test info for left & right LI distribution %
        'saveIndexChsOverall',[0 0 0 0],... % on/off save left, right, difference indices
        'saveIndexFiltOverall',[0 0 0],... % filter = epoch, base, poi
        'saveIndicesOverall', [0 0 0 0 0],...% mean, std, min, max, & rms % selection, saveIndexChs required also
        'saveIndexOverallExtraChs',[0 0 0 0],... % on/off save left, right, difference indices, average
        'saveIndexOverallExtraChFilt',[0 0 0 0],... % filters based on left, right, difference indices, average
        'saveIndexOverallExtraTypeFilt',zeros(1,8),...{'AbsMaxPOI','AbsMax','MaxPOI','Max','AbsMinPOI','AbsMin','Min','MinPOI'}
        'saveIndicesOverallExtra', zeros(1,10),...% 'time','mean','std','sem','CI95','min','max','rms','med','iqr' % selection, saveIndexChs required also
        'saveDescripOverall',[1 1 1 1 1 1 0 0 0 0],... % save descriptives (see saveDescripLabels below & dopDataLIcalc function)
        'save1sampleOverall',[0 0 0 0 0 0 0],... % save one-sample t-test sig & effect size (see dopDataLIcalc)
        'save2sampleOverall',[0 0 0 0 0 0 0],... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
        'saveRankOverall',[0 0 0 0 0],...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
        'save1normOverall',[0 0 0 0],... % save normality test info for difference LI distribution
        'save2normOverall',[0 0 0 0 0 0 0 0],... % save normality test info for left & right LI distribution %
        'saveDescripSplitOverall',[1 1 1 1 1 1 0 0 0 0],... % save descriptives (see saveDescripLabels below & dopDataLIcalc function)
        'save1sampleSplitOverall',[0 0 0 0 0 0 0],... % save one-sample t-test sig & effect size (see dopDataLIcalc)
        'save2sampleSplitOverall',[0 0 0 0 0 0 0],... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
        'saveRankSplitOverall',[0 0 0 0 0],...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
        'save1normSplitOverall',[0 0 0 0],... % save normality test info for difference LI distribution
        'save2normSplitOverall',[0 0 0 0 0 0 0 0],... % save normality test info for left & right LI distribution %
        'saveEpochSelQual',[0 0 0 0 1 1],... % epoch selection quality saving  all, length, act, man, comb (dat + act + man), & balanced epochs (session only)
        'saveGorInd',[0 0],... % save mean max goodness of recordings - left and right channels
        'saveGorChs',[1 1 0 0],... % left right dif average channels - probably not necessary but option is there
        'saveGorFilt',[0 1 0],... % epoch, base, poi
        'saveGorSelEp',0,... % save goodness of recording all epochs yes/no
        'saveDropInd',[0 0],... % save count percent dropout - left and right channels
        'saveDropChs',[1 1 0 0],... % left right dif average channels - probably not necessary but option is there
        'saveDropFilt',[0 1 0],... % epoch, base, poi
        'saveDropSelEp',0,... % save dropout all epochs yes/no
        'saveDop',0,... % save the 'dop' structure for offline examinination
        'closeGui',1,... % gui only setting that closes gui on run function
        'shortWarn',1,... % warning dialog box when the data is short
        'finishSound',1); % play finish sound see ...dopOSCCIm2\dopTools\genTools\finishSound.wav
    
    
    %         'save1sampleSplit',1,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
    %         'save2sampleSplit',0,... % save paired-sample t-test sig & effect size (see dopDataLIcalc)
    %         'save1normSplit',0,... % save normality test info for difference LI distribution
    %         'save2normSplit',0,... % save normality test info for left & right LI distribution
    %         'saveRankSplit',0,...);%,... % save one-sample t-test sig & effect size (see dopDataLIcalc)
    
    
    % struct doesn't like cell arrays
    inputs.defaults.graphFileType={'jpg'};
    %         dg.figs.edit.type={'jpg','fig','tif','bmp','eps','png'}; % save figures as
    % could be any of these formats: see matlab saveas function
    % ai	- Adobe® Illustrator `88
    % bmp	- Windows bitmap
    % emf	- Enhanced metafile
    % eps	- EPS Level 1
    % fig	- MATLAB figure (invalid for Simulink block diagrams)
    % jpg	- JPEG image (invalid for Simulink block diagrams)
    % m	- MATLAB M-file (invalid for Simulink block diagrams)
    % pbm	- Portable bitmap
    % pcx	- Paintbrush 24-bit
    % pdf	- Portable Document Format
    % pgm	- Portable Graymap
    % png	- Portable Network Graphics
    % ppm	- Portable Pixmap
    % tif - TIFF image, compressed
    inputs.defaults.evNames={'eventName'}; % event marker channel names
    inputs.defaults.graphAbb={'Raw','Norm','Ind','Epoch','Beh','Overall'}; % graph abbreviations
    inputs.defaults.graphNames={'Raw Data','Normalised Data','Individual Averaged',...
        'Individual Epochs','Individual Behavioural',...
        'Overall Averaged'}; % graph abbreviations
    inputs.defaults.sumDescripSet={'epoch','base','poi'}; % used in dopSaveDirBase for description name
    inputs.defaults.saveIndexChLabels={'L','R','D','A'}; % left right difference see dopDataIndexCalc
    inputs.defaults.saveIndexFiltLabels={'epoch','base','poi'};%,'absMax','absMaxPOI'}; % epoch base poi
    inputs.defaults.saveIndexLabels={'M','SD','SEM','CI95','MIN','MAX','RMS','MED','IQR'}; % see dopDataIndexCalc
    inputs.defaults.saveIndexVarLabels={'mean','std','sem','CI95','min','max','rms','med','iqr'};
    
    inputs.defaults.saveIndexExtraChFiltLabels={'left', 'right', 'dif','avg'};%difference indices, average
    inputs.defaults.saveIndexExtraTypeFiltLabels={'AbsMaxPOI','AbsMax','MaxPOI','Max','AbsMinPOI','AbsMin','Min','MinPOI'};
    inputs.defaults.saveIndexExtraLabels={'T','M','SD','SEM','CI95','MIN','MAX','RMS','MED','IQR'}; % see dopDataIndexCalc
    inputs.defaults.saveIndexExtraVarLabels={'time','mean','std','sem','CI95','min','max','rms','med','iqr'};
    
    inputs.defaults.saveIndexExpLabels={'GoR','LIv'}; % % Goodness of Recording, LI variability see dopDataIndexCalc
    inputs.defaults.saveEpochSelectionLabels={'all','length','act','man','comb','bal'};
    %     inputs.defaults.saveGraphDataAbb={'allEp','datEp','actEp','manEp','scrnEp','balEp'}; % for graph data save headers
    inputs.defaults.saveGraphDataChAbb={'Left','Right','Dif','Avg'}; % for graph data save headers
    inputs.defaults.splitLabels={'odd','even';'rand1','rand2'}; % split categorisation labels
    
    inputs.defaults.saveDescripLabels={'LIepochs','LIpeakSec','LImean','LIstd','LIsem','LI95pctCI',...
        'LImin','LImax','LImedian','LIiqr'};
    inputs.defaults.save1sampleLabels={'LIt1sig','LIt1p','t1ci','t1t','t1df','t1sd','LIt1cohen'};
    inputs.defaults.save2sampleLabels={'LIt2sig','LIt2p','t2ci','t2t','t2df','t2sd','LIt2cohen'};
    inputs.defaults.saveRankLabels={'LIrsig','LIrp','LIranksum','LIrzval','LIrZr'};
    
    inputs.defaults.save1normLabels={'jb1_norm','jb1_p','jb1_stat','jb1_crit'};
    inputs.defaults.save2normLabels={'jb2_Lnorm','jb2_Lp','jb2_Lstat','jb2_Lcrit','jb2_Rnorm','jb2_Rp','jb2_Rstat','jb2_Rcrit'};
    
    inputs.defaults.saveEpochLILabels=inputs.defaults.saveDescripLabels(2:end);%{'LImean','LIpeakSec'};%,[1 0],... % indices to be saved for each epoch LI (mean) LI latency
    %    inputs.defaults.saveEpochIndLabels={'
    
    inputs.defaults.saveGorIndLabels = {'Mean','Max'};
    inputs.defaults.saveDropIndLabels = {'count','pct'};
    
    inputs.defaults.notes={...
        sprintf('%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n',...
        'For example,','Date: (of data collection)',...
        'Experimenter/s:','Task Description:','Sample Description:',...
        '-----------------------------------',...
        'Timing:',' > baseline = ',' > stim = ',' > response ? ',...
        ' > normalization = ','-----------------------------------')}; % notes for description of task, testing, etc.
    %% > set & get them
    dop.def=setGetInputsStruct(inputs);
    
    if strcmp(dop.def.taskName,'dopOSCCIdemo')
        dop.def.notes={sprintf(...
            '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n',...
            'Date: May 2010',...
            'Experimenter: AB',...
            'Task Description: Visual memory task',...
            '------------------------------------------------------',...
            'Timing:',...
            '>Clear mind= 5 sec',...
            '>Visual display = 5 sec',...
            '>Blank screen =10 sec',...
            '>Response~ 5 sec (reaction time response so time is variable)',...
            '>Relax = 25 sec',...
            '------------------------------------------------------',...
            'Total trial length ~ 50 sec',...
            '12 trials',...
            'Onset marker at start of ''Clear mind''',...
            '------------------------------------------------------')};
    end
    
    %% Fill empty cells
    % some inputs have accompanying inputs that should be the same length
    if length(dop.def.evChs)>length(dop.def.evNames)
        dop.tmp.evNames=dop.def.evNames;
        for i=1:length(dop.def.evChs)
            dop.def.evNames{i}=[dop.tmp.evNames{1},num2str(i)];
        end
    end
    %% ---------------------------
    %% saveDirectory:
    % create a description based upon settings
    %     dop.def.descrip=dopSaveDirDescription('def',dop.def,dop.def.saveDescription{1:end}); %'epoch','base','poi');
    
    %     [dop.def.saveDir dop.def.sumDescrip]=dopSaveDirBase(dop);
    %     % standard base directory and original saveDir (using description)
    [dop.def.saveDir dop.def.sumDescrip dop.def.saveDirBase]=dopSaveDirBase(dop);
    
    %% taskData & file names
    %     dop.def.saveDir=[fileparts(which('dopOSCCI')),'Data\',dtd.taskName,'\'];
    %     if iscell(dop.def.defFileNameLoc)
    %         dop.def.defFileNameLoc=dop.def.defFileNameLoc{1};
    %     end
    if ~isempty(dop.def.defFileNameLoc)
        [dop.def.defDir dop.def.defFileName dop.tmp.ext]=fileparts(dop.def.defFileNameLoc);
        dop.def.defDir=[dop.def.defDir,'\'];
    end
    if isfield(dop.def,'defDir') && ~exist(dop.def.defDir,'dir')==7
        mkdir(dop.def.defDir); % if it's new, we want the directory there
    end
    if ~isempty(dop.def.defFileNameLoc) && exist(dop.def.defFileNameLoc,'file')==2 && strcmp(dop.tmp.ext,'.mat')
        fprintf('%s\n','Definition File Name Location is good');
        %         [dop.def.defDir dop.def.defFileName]=fileparts(dop.def.defFileNameLoc);
        dop.def.taskName=dop.def.defFileName; % overwrite default
    elseif ~isempty(dop.def.defFileNameLoc) && exist(fileparts(dop.def.defFileNameLoc),'dir')==7 && strcmp(dop.tmp.ext,'.mat')
        % not empty, so we can extra info from it
        dop.def.taskName=dop.def.defFileName; % overwrite default
    else
        fprintf('%s\n','Setting Definition File Name Location:');
        dop.def.defDir=[fileparts(which('dopOSCCI')),'\taskData\'];
        
        if ~exist(dop.def.defDir,'dir')
            fprintf('%s\n\t%s\n','Making taskData folder: ',dop.def.defDir);
            mkdir(dop.def.defDir);
        end
        dop.def.defFileName=[dop.def.taskName,'.mat'];
        dop.def.defFileNameLoc=[dop.def.defDir,dop.def.defFileName]; % file Name Location
        
    end
    dop.def.txtFileName=[dop.def.taskName,'_viewOnly.txt'];
    dop.def.txtFileNameLoc=[dop.def.defDir,dop.def.txtFileName]; % file Name Location
    %% -----------------------------------------------------
    % Updating
    %     if dop.def.update
    %         fprintf('%s\n\t%s\n','Updating Task Definition File:',...
    %             dop.def.defFileName);
    %         if exist(dop.def.defFileNameLoc,'file')
    %             delete(dop.def.defFileNameLoc);
    %         end
    %     else
    if dop.def.reset
        fprintf('%s\n\t%s\n','Reseting Task Definition File to defaults:',...
            dop.def.defFileName);
        dop.tmp.fns=fieldnames(dop.def); % field names
        for i=1:length(dop.tmp.fns);
            dop.tmp.fn=dop.tmp.fns{i};
            if isfield(dop.def.setGet.defaults,dop.tmp.fn) && ...
                    ~sum(strcmp(dop.tmp.fn,{'saveDir','sumDescrip','saveDirBase','taskName'}));
                fprintf('\t\t%s\n',dop.tmp.fn);
                dop.def.(dop.tmp.fn)=dop.def.setGet.defaults.(dop.tmp.fn);
            end
        end
        fprintf('\t%s\n','Done');
    elseif exist(dop.def.defFileNameLoc,'file')
        %% Importing
        fprintf('%s\n\t%s\n','Importing Task Definition File:',...
            dop.def.defFileName);
        tmp=dop;
        load(dop.def.defFileNameLoc);
        dop.old=tmp; clear tmp
        
        %% > check the data directories
        % if it's the first run on a new computer and the location isn't
        % the same as the old computer, it'll be confused...
        if exist(dop.def.defDir,'dir')~=7
            % change back
            dop.def.defDir=dop.old.def.defDir;
            % check each of the special files as well
            
        end
        dop.tmp.specCheck={'scrnFileNameLoc','grpFileNameLoc',...
            'behFileNameLoc','sesFileNameLoc'};
        for i=1:numel(dop.tmp.specCheck)
            if ~isempty(dop.def.(dop.tmp.specCheck{i}))
                if iscell(dop.def.(dop.tmp.specCheck{i}))
                    [dop.tmp.path dop.tmp.name dop.tmp.ext]=fileparts(dop.def.(dop.tmp.specCheck{i}){1});
                else
                    [dop.tmp.path dop.tmp.name dop.tmp.ext]=fileparts(dop.def.(dop.tmp.specCheck{i}));
                end
                if exist(dop.tmp.path,'dir')~=7
                    % this places the files relative to the dopOSCCI
                    % installation - it's probably the right place
                    dop.def.(dop.tmp.specCheck{i})=[dop.def.defDir,dop.tmp.name,dop.tmp.ext];
                end
            end
        end
        if exist(dop.def.saveDirBase,'dir')~=7
            % change back
            dop.def.saveDirBase=[fileparts(which('dopOSCCI')),'data\'];
        end
        % and the data directory:
        if exist(dop.def.dataDir,'dir')~=7 && strcmp(dop.def.taskName,'dopOSCCIdemo')
            dop.def.dataDir=strrep([fileparts(which('dopOSCCI')),'demo\rawData\'],'m2','');
        end
        
        %% > check imported structure
        % make sure we have all the same fields as before
        % this could happen when playing around with task defitions...
        dop.tmp.ofs=fieldnames(dop.old); % old field names
        dop.tmp.dfs=fieldnames(dop); % dop field names
        for i=1:length(dop.tmp.ofs)
            dop.tmp.match=0;
            for j=1:length(dop.tmp.dfs)
                if strcmp(dop.tmp.ofs{i},dop.tmp.dfs{j})
                    % no match, therefore import field
                    dop.tmp.match=1;
                    break
                end
                
            end
            if ~dop.tmp.match;
                switch dop.tmp.ofs{i}
                    case {'def','ofs'}
                    otherwise
                        dop.(dop.tmp.ofs{i})=dop.old.(dop.tmp.ofs{i});
                end
            end
        end
        dop.tmp=rmfield(dop.tmp,{'ofs','dfs'});
        
        %% > Fields to be added/adjusted?
        fprintf('\t%s\n','Checking imported structure...');
        dop.tmp.cfn=fieldnames(dop.old.def); % current field names
        dop.tmp.ifn=fieldnames(dop.def); % imported field names
        dop.tmp.got=[]; % collect the found fields
        dop.schk.exceptions={'saveBaseDir','sumDescrip',...
            'scrnFileNameLoc','grpFileNameLoc',...
            'behFileNameLoc','sesFileNameLoc'};
        dop.schk.examine={'saveEpochSelection','saveEpochSelectionGraph',...
            'saveGraphDataChs','saveIndexChs','saveIndexFilt',...
            'saveIndices','saveIndexExtra','graphs',...
            'sumDescripSet','saveIndexChLabels','saveIndexFiltLabels',...
            'saveIndexLabels','saveIndexVarLabels','saveIndexExtraLabels',...
            'saveEpochSelectionLabels','saveGraphDataChAbb',...
            'graphFolder','saveSesGraphData','saveEpochInd',...
            'saveEpochSelection',...
            'saveIndexChs','saveIndexFilt','saveIndices',...
            'saveDescrip','save1sample','save2sample',...
            'saveRank','save1norm','save2norm',...
            'saveDescripLabels','save1sampleLabels',...
            'save2sampleLabels','saveRankLabels',...
            'save1normLabels','save2normLabels',...
            'saveEpochLILabels',...
            'saveDescripSplit','save1sampleSplit','save2sampleSplit',...
            'save1normSplit','save2normSplit','saveDescripSplit',...
            'saveEpochLI','saveRankSplit',...
            'saveNotes',...
            'saveIndexChsOverall',...
            'saveIndexFiltOverall','saveIndicesOverall',...
            'saveDescripOverall','save1sampleOverall',...
            'save2sampleOverall','saveRankOverall',...
            'save1normOverall','save2normOverall',...
            'saveDescripSplitOverall','save1sampleSplitOverall',...
            'save2sampleSplitOverall','saveRankSplitOverall',...
            'save1normSplitOverall','save2normSplitOverall',...
            'saveData'};
        for i=1:length(dop.tmp.cfn) % for each of the current fields
            dop.tmp.match=0;
            for j=1:length(dop.tmp.ifn) % see if they match
                if strcmp(dop.tmp.cfn{i},dop.tmp.ifn{j});
                    %% > check variable length
                    if sum(strcmp(dop.tmp.cfn{i},dop.schk.examine));
                        
                        %check that they're the same y length
                        %                         dop.tmp.isize=size(dop.def.(dop.tmp.ifn{j}),2); % in size
                        %                         dop.tmp.csize=size(dop.old.def.(dop.tmp.cfn{i}),2); % current size
                        dop.tmp.i_el=numel(dop.def.(dop.tmp.ifn{j})); % in elements
                        dop.tmp.c_el=numel(dop.old.def.(dop.tmp.cfn{i})); % current elements
                        if dop.tmp.i_el~=dop.tmp.c_el %dop.tmp.isize~=dop.tmp.csize
                            dop.def.(dop.tmp.ifn{j})=dop.old.def.(dop.tmp.cfn{i});
                            fprintf('\t\t%s\n',['Updated: ',dop.tmp.ifn{j}],...
                                ['Number of elements was ',num2str(dop.tmp.i_el),...
                                ', now ',num2str(dop.tmp.c_el)]);
                            %                             if dop.tmp.isize<dop.tmp.csize % add info
                            %                                 if iscell(dop.def.(dop.tmp.ifn{j}))
                            %                                     dop.tmp.(dop.tmp.cfn{i})=dop.old.def.(dop.tmp.cfn{i}); % create tmp copy of current
                            %                                     for jj=1:dop.tmp.isize
                            %                                         dop.tmp.(dop.tmp.cfn{i}){jj}=dop.def.(dop.tmp.ifn{j}){jj}; % set initial values in tmp to same as imported
                            %                                     end
                            %                                     dop.def.(dop.tmp.ifn{j})=dop.tmp.(dop.tmp.ifn{j}); % exchange
                            %                                 else
                            %                                     dop.def.(dop.tmp.ifn{j})(dop.tmp.isize+1:dop.tmp.csize)=...
                            %                                         dop.old.def.(dop.tmp.ifn{j})(dop.tmp.isize+1:dop.tmp.csize);
                            %                                 end
                            %                             elseif dop.tmp.isize>dop.tmp.csize % too big
                            %                                 if iscell(dop.def.(dop.tmp.ifn{j}))
                            %                                     dop.tmp.(dop.tmp.cfn{i})=[];
                            %                                     for jj=1:dop.tmp.csize
                            %                                         dop.tmp.(dop.tmp.cfn{i}){jj}=dop.def.(dop.tmp.ifn{j}){jj}; % set initial values in tmp to same as imported
                            %                                     end
                            %                                     dop.def.(dop.tmp.ifn{j})=dop.tmp.(dop.tmp.ifn{j}); % exchange
                            %                                 else
                            %                                     dop.def.(dop.tmp.ifn{j})=...
                            %                                         dop.def.(dop.tmp.ifn{j})(1:dop.tmp.csize);
                            %                                 end
                            %                             end
                        end
                    end
                    dop.tmp.match=1;
                    
                    break
                end
            end
            if ~dop.tmp.match && j==length(dop.tmp.ifn)
                % no match and exhausted old list = new field
                fprintf('\t\t%s\n',...
                    ['New field - adding: ',dop.tmp.cfn{i}]);
                dop.def.(dop.tmp.cfn{i})=dop.old.def.(dop.tmp.cfn{i});
            end
            switch dop.tmp.cfn{i}
                %% > saveDirectory
                case 'saveDirBase'
                    if ~isempty(dop.old.def.(dop.tmp.cfn{i}))
                        dop.def.(dop.tmp.cfn{i})=dop.old.def.(dop.tmp.cfn{i});
                        fprintf('\t%s\n\t\t%s\n','Updating new ''saveDir''',...
                            dop.def.(dop.tmp.cfn{i}));
                        %                         % don't import = use new
                        %                         dop.def.(dop.tmp.cfn{i})=dop.tmp.(dop.tmp.cfn{i});
                    end
                    [dop.def.saveDir dop.def.sumDescrip]=dopSaveDirBase(dop);
                    % standard base directory and original saveDir (using description)
                    
            end
            
            dop.tmp.got{end+1}=dop.tmp.cfn{i};
            %% > update new info
            % imported info needs to be placed into current definition
            if sum(strcmp(dop.tmp.cfn{i},dop.old.def.setGet.foundList))
                dop.def.(dop.tmp.cfn{i})=dop.old.def.(dop.tmp.cfn{i});
            end
        end
        %% > Old fields to be removed?
        if length(dop.tmp.got)~=length(dop.tmp.ifn)
            % old fields to be removed
            for i=1:length(dop.tmp.ifn)
                dop.tmp.match=0;
                for j=1:length(dop.tmp.got)
                    if strcmp(dop.tmp.ifn{j},dop.tmp.got{j})
                        dop.tmp.match=1;
                        break
                    end
                end
                if ~dop.tmp.match
                    % no match and exhausted current list = new field
                    fprintf('\t\t%s\n',...
                        ['Old field - removing: ',dop.tmp.ifn{j}]);
                    dop.def=rmfield(dop.def,dop.tmp.ifn{j});
                end
            end
        end
    end
    
    %if there's a tmp field in dop.def, remove it
    if isfield(dop.def,'tmp')
        dop.def=rmfield(dop.def,'tmp');
    end
    %% Saving
    %% > txt file for easy viewing:
    dop.def.txtFileName=[dop.def.taskName,'_viewOnly.txt'];
    if ~strcmp(dop.def.defDir(end),'\')
        dop.def.defDir=[dop.def.defDir,'\'];
    end
    dop.def.txtFileNameLoc=[dop.def.defDir,dop.def.txtFileName]; % file Name Location
    dop.tmp.fid=fopen(dop.def.txtFileNameLoc,'w'); % open for writing, over-write previous
    
    dop.tmp.fns=fieldnames(dop.def); % field names
    fprintf(dop.tmp.fid,'%s\n\t%s\n\n','Read Only Task Definition Info',...
        'That is, modifications to this file are not functional');
    for i=1:length(dop.tmp.fns)
        switch dop.tmp.fns{i}
            case {'setGet','inputs','tmp'}
                % don't want these
            otherwise
                fprintf(dop.tmp.fid,'%s',dop.tmp.fns{i});
                switch dop.tmp.fns{i}
                    case {'evNames','graphAbb','graphNames','sumDescripSet',...
                            'saveIndexChLabels','saveIndexFiltLabels',...
                            'saveIndexLabels','saveIndexExtraLabels',...
                            'saveIndexVarLabels','saveIndexFiltVarLabels',...
                            'saveGraphDataAbb','saveGraphDataChAbb',...
                            'saveEpochSelectionLabels','splitLabels','notes',...
                            'saveDescripLabels','save1sampleLabels',...
                            'save2sampleLabels','saveRankLabels',...
                            'save1normLabels','save2normLabels',...
                            'saveEpochLILabels','graphFileType','fileSel'} % cells
                        for j=1:numel(dop.def.(dop.tmp.fns{i}))
                            if iscell(dop.def.(dop.tmp.fns{i}))
                                fprintf(dop.tmp.fid,'\t%s',dop.def.(dop.tmp.fns{i}){j});
                            elseif isnumeric(dop.def.(dop.tmp.fns{i}))
                                fprintf(dop.tmp.fid,'\t%u',dop.def.(dop.tmp.fns{i})(j));
                            else
                                fprintf(dop.tmp.fid,'\t%s',dop.def.(dop.tmp.fns{i})(j));
                            end
                        end
                    case {'matlabVer','toolboxes'} % skip
                    otherwise
                        if isnumeric(dop.def.(dop.tmp.fns{i})) % numbers
                            switch dop.tmp.fns{i}
                                case 'graphs'
                                    fprintf(dop.tmp.fid,'\t%s\t%u%u%u%u%u%u\n',...
                                        '(saving)',dop.def.(dop.tmp.fns{i})(1,:));
                                    fprintf(dop.tmp.fid,'\t\t%s\t%u%u%u%u%u%u',...
                                        '(viewing)',dop.def.(dop.tmp.fns{i})(2,:));
                                otherwise
                                    fprintf(dop.tmp.fid,'\t%i',dop.def.(dop.tmp.fns{i}));
                            end
                        else % other text
                            switch dop.tmp.fns{i}
                                case 'evNames'
                                    fprintf(dop.tmp.fid,'\t%s\t%s',dop.def.(dop.tmp.fns{i}){1:end});
                                otherwise
                                    if iscell(dop.def.(dop.tmp.fns{i}))
                                        fprintf(dop.tmp.fid,'\t%s',dop.def.(dop.tmp.fns{i}){1});
                                    else
                                        fprintf(dop.tmp.fid,'\t%s',dop.def.(dop.tmp.fns{i}));
                                    end
                            end
                        end
                end
                fprintf(dop.tmp.fid,'\n'); % new line
        end
    end
    fclose(dop.tmp.fid); % close the file
    fprintf('%s\n\t%s\n\n',...
        'View only text file saved to:',dop.def.txtFileNameLoc);
    %% Check variables which rely on each other
    %% > overall graphs
    % if we want overall graphs, then we need to have the data
    if sum(dop.def.graphs(:,6))
        dop.def.saveGraphDataChs(1:3)=1;
    end
    %% > event marker settings...
    for i=1:dop.def.evNum
        dop.def=dopOSCCIeventCheck(dop.def,i);
    end
    %% > event names
    if dop.def.evNum~=numel(dop.def.evNames)
        for i=dop.def.evNum+1:numel(dop.def.evNames)
            dop.def.evNames(i)=[];
        end
    end
    if sum([dop.def.saveEpochIndFilter dop.def.saveEpochIndCh dop.def.saveEpochLI])
        dop.def.saveEpoch=1;
    end
    %% check toolboxes
    fprintf('%s\n','Checking toolboxes...');
    dop.def.matlabVer=ver;
    dop.def.toolboxes={'Statistics Toolbox'};
    dop.def.gotToolboxes=1;%zeros(1,numel(dop.def.toolboxes));
    for i=1:numel(dop.def.matlabVer)
        fprintf('%s','.');
        if sum(strcmp(dop.def.matlabVer(i).Name,dop.def.toolboxes))
            fprintf('\n\t%s\n',dop.def.matlabVer(i).Name);
            dop.def.gotToolboxes(strcmp(dop.def.toolboxes,dop.def.matlabVer(i).Name))=1;
        end
    end
    
    if sum(dop.def.gotToolboxes==0)
        for i=1:numel(dop.def.gotToolboxes)
            if ~dop.def.gotToolboxes(i)
                switch dop.def.toolboxes{i}
                    case 'Statistics Toolbox'
                        fprintf('\t%s\n\t\t%s\n',...
                            [dop.def.toolboxes{i},' not found'],...
                            'Inter-quartile range won''t be calculated');
                        dop.def.saveDescrip(strcmp(dop.def.saveDescripLabels,'LIiqr'))=0;
                        dop.def.saveDescripSplit(strcmp(dop.def.saveDescripLabels,'LIiqr'))=0;
                end
            end
        end
    end
    fprintf('\n%s\n','Done');
    %% clear uneccessary
    %     try % might not be there
    fns=fieldnames(dop); % field names
    for i=1:length(fns)
        if sum(strcmp(fns{i},{'old','tmp','sav','scrn'}))
            dop=rmfield(dop,fns{i});
        end
    end
    %     end
    %% > mat file for matlab/dopOSCCI to use
    if ~exist(dop.def.defDir,'dir')
        fprintf('%s\n\t%s\n','Making taskData folder: ',dop.def.defDir);
        mkdir(dop.def.defDir);
    end
    save(dop.def.defFileNameLoc,'dop');
    fprintf('%s\n\t%s\n\n\t%s\n\t\t%s\n',...
        'Done. Saved to:',dop.def.defFileNameLoc,...
        'To load type:',['load(''',dop.def.defFileNameLoc,''')']);
    
    %% set output
    varargout{1}=dop;
    fprintf('\n%s\n',['Completed dopOSCCI Task Definition Setup (',mfilename,')']);
catch err
    %% catch dopOSCCI error
    save(dopOSCCIdebug(mfilename));rethrow(err);
end
clear inputs dop tmp