sbj = 'sbj19';
subjectName = {[sbj '_L_A_preprocessed.set'],[sbj '_L_A_preprocessed.set'],[sbj '_R_A_preprocessed.set'],[sbj '_R_A_preprocessed.set'],};
mypath = './0418/';
for s = 1:size(subjectName,2)
    EEG = pop_loadset('filename',subjectName{s},'filepath',mypath);
    [Lsap,Rsap] = getSAP(subjectName{1}(1:5),'nGoggle3');
    s1 = [30];%[21,30,31];
    s2 = [40];%[40,41,49];
    s3 = [39];%[38,39,48];
    s4 = [29];%[28,29,20];
    s5 = [13,14,21,22];
    s6 = [22,23,31,32];
    s7 = [41,42,50,51];
    s8 = [49,50,57,58];
    s9 = [47,48,55,56];
    s10 =[37,38,46,47];
    s11 =[18,19,27,28];
    s12 =[11,12,19,20];
    s13 =[2,6:8,15];
    s14 =[15,16,24,33,34];
    s15 =[43,44,52,59,60];
    s16 =[59,64:66,68];
    s17 =[54,61:63,67];
    s18 =[35,36,45,53,54];
    s19 =[9,10,17,25,26];
    s20 =[1,3,4,5,10];
    %left
    EEG.sap(1,1) = mean(Lsap(s1));
    EEG.sap(2,1) = mean(Lsap(s2));
    EEG.sap(3,1) = mean(Lsap(s3));
    EEG.sap(4,1) = mean(Lsap(s4));
    EEG.sap(5,1) = mean(Lsap(s5));
    EEG.sap(6,1) = mean(Lsap(s6));
    EEG.sap(7,1) = mean(Lsap(s7));
    EEG.sap(8,1) = mean(Lsap(s8));
    EEG.sap(9,1) = mean(Lsap(s9));
    EEG.sap(10,1) = mean(Lsap(s10));
    EEG.sap(11,1) = mean(Lsap(s11));
    EEG.sap(12,1) = mean(Lsap(s12));
    EEG.sap(13,1) = mean(Lsap(s13));
    EEG.sap(14,1) = mean(Lsap(s14));
    EEG.sap(15,1) = mean(Lsap(s15));
    EEG.sap(16,1) = mean(Lsap(s16));
    EEG.sap(17,1) = mean(Lsap(s17));
    EEG.sap(18,1) = mean(Lsap(s18));
    EEG.sap(19,1) = mean(Lsap(s19));
    EEG.sap(20,1) = mean(Lsap(s20));
    %right
    EEG.sap(1,2) = mean(Rsap(s1));
    EEG.sap(2,2) = mean(Rsap(s2));
    EEG.sap(3,2) = mean(Rsap(s3));
    EEG.sap(4,2) = mean(Rsap(s4));
    EEG.sap(5,2) = mean(Rsap(s5));
    EEG.sap(6,2) = mean(Rsap(s6));
    EEG.sap(7,2) = mean(Rsap(s7));
    EEG.sap(8,2) = mean(Rsap(s8));
    EEG.sap(9,2) = mean(Rsap(s9));
    EEG.sap(10,2) = mean(Rsap(s10));
    EEG.sap(11,2) = mean(Rsap(s11));
    EEG.sap(12,2) = mean(Rsap(s12));
    EEG.sap(13,2) = mean(Rsap(s13));
    EEG.sap(14,2) = mean(Rsap(s14));
    EEG.sap(15,2) = mean(Rsap(s15));
    EEG.sap(16,2) = mean(Rsap(s16));
    EEG.sap(17,2) = mean(Rsap(s17));
    EEG.sap(18,2) = mean(Rsap(s18));
    EEG.sap(19,2) = mean(Rsap(s19));
    EEG.sap(20,2) = mean(Rsap(s20));
    EEG = pop_saveset( EEG, 'filename',subjectName{s},'filepath',mypath);
end