addpath('/home/hohlochj/masterarbeit/usedMcode')
pathToFile='/nfs/wsi/ti/messor/hohlochj/origData/';
%pathToFile='/home/jph/Uni/masterarbeit/Block1_ReachingMovements/';

maxFile=5;
threshold=10000; %EMG is classified as movement

windowEMG=0.2; %try 1s
windowEEG=1;
shift=0.2;
pburgOrder=50;
minEEGFreq=0; %try 8-30
maxEEGFreq=200;
k=10;
maxExpC=0;
maxPerClass=250;
EEG=true;
poolObj=parpool(32);

[subjects,numbers]=namesAndNumbers(pathToFile);
j=0;
for i=1:size(subjects,2)
    subject=subjects{i};
    for number=numbers{i}        
        j=j+1;
    end
end

meanAccurancysEMG=zeros([j,1]);
meanAccurancysEEG=zeros([j,1]);
maxCEMG=zeros([j,k,1]);
maxCEEG=zeros([j,k,1]);
cmScaledEMG=zeros([j,5,5]);
cmScaledEEG=zeros([j,5,5]);

j=1;
for i=1:size(subjects,2)
    subject=subjects{i};
    for number=numbers{i}
%         fprintf('%s%i\n',subject,number);
        readEEG(pathToFile,subject,number,windowEMG,windowEEG,shift,maxFile,threshold,pburgOrder,minEEGFreq,maxEEGFreq);
        [meanAccurancysEMG(j),maxCEMG(j,:),cmScaledEMG(j,:,:)]=svmEciton(pathToFile,subject,number,false,k,maxExpC,maxPerClass);
        [meanAccurancysEEG(j),maxCEEG(j,:),cmScaledEEG(j,:,:)]=svmEciton(pathToFile,subject,number,EEG,k,maxExpC,maxPerClass);
        [correlationEMG(j)]=ridgeCorrelation(pathToFile,subject,number,false,k);
        [correlationEEG(j)]=ridgeCorrelation(pathToFile,subject,number,EEG,k);
        j=j+1;
    end
end

save(strcat(pathToFile,sprintf('../matlabData/%s_callAll.mat',datestr(datetime('now')))));
delete(poolObj)


