function dop=dopSaveDirSetup(dop)
% dopOSCCI Mark II: dopSaveDirSetup ~ 1-11-2010 (last edit)
%
% creates a series of save directories for various processing options that
% are available in dopOSCCI:
% - Group membership (see dopGrpSetup)
% - number of marker channels (setting)
% - number of sessions (see dopSesSetup)
% - number of behavioural conditions (see dopBehSetup)
%
try
    fprintf('%s\n',['Running ',mfilename]);
%     dop=dopSaveDirBase(dop); % create original base directory dop.data.saveDirBase
% now (1-11-10) runs in dopTaskDef
    % now create a series based upon the above considerations
    dop.sav.saveDir=dop.def.saveDir;
    if ~exist(dop.sav.saveDir,'dir')
        mkdir(dop.sav.saveDir);
    end
catch err
    %% catch dopOSCCI error
    % 
    commandwindow; % bring command window to front
    cl=[fileparts(which('dopOSCCI')),'Data\dopOSCCIdebug\']; % caught location
    cfn=['caught_',mfilename,'_',datestr(now,30)]; % caught file name
    cfnl=[cl,cfn]; % caught file name location
    save(cfnl); % save all variables to a mat file
    fprintf('\t%s\n\n\t%s\n\t%s\n\n\n\t%s\n\t\t%s\n',...
            'Error: Saving caught variables:',...
            ['Dir: ',cl],['File: ',cfn],...
            'Access by typing:',['load(''',cfnl,''')']);
    rethrow(err); 
%     dopOSCCIcrash(err,dop,mfilename);
end