%% single file mode

clear all; close all;

data.fid = 'ex100916_2SpOT.7_DATA2'; %fid stand for file identification of the imported data
expdir = 'D:\mingfaifong\experiments\ex100916_2SpOT.7\analyses\';
cd(expdir);
analysis_2SpOT_xcorr;


%% batch mode
clear all; close all;
expdir = 'D:\mingfaifong\experiments';
expID = {'ex100902_2SpOT.1';'ex100902_2SpOT.2';
    'ex100908_2SpOT.1';'ex100908_2SpOT.4';
    'ex100903_2SpOT.1';'ex100903_2SpOT.2';'ex100903_2SpOT.3';
    'ex100906_2SpOT.1';'ex100906_2SpOT.2';'ex100906_2SpOT.3';
    'ex100907_2SpOT.1';'ex100907_2SpOT.2';'ex100907_2SpOT.3';'ex100907_2SpOT.4';'ex100910_2SpOT.1';'ex100910_2SpOT.2';'ex100910_2SpOT.4';
    'ex100916_2SpOT.2';'ex100916_2SpOT.3';'ex100916_2SpOT.5';'ex100916_2SpOT.6';'ex100916_2SpOT.7';
    };

for ii = 1:length(expID)
    cd(char(strcat(expdir,'\',expID(ii),'\analyses\')));
    triallist = dir('*.dat');
    fidlist = {triallist.name};
    for jj = 1:length(fidlist)
        data.fid = fidlist{jj}(1:22);
        analysis_2SpOT_xcorr;
        clearvars -except fidlist expdir expID triallist;
        close all;
    end
end