%params
NFFT=2048;
window=0.2;
shift=0.2;
k=10;
maxExpC=7;
maxFile=5;
threshold=7500;

trainingDataEEGcell=cell(maxFile,1);
trainingDataEMGcell=cell(maxFile,1);
classesCell=cell(maxFile,1);

for i=1:maxFile
    [sig, stat, params] = load_bcidat(sprintf('/home/jph/Uni/masterarbeit/Block1_ReachingMovements/AO/AO_B1001/AO_B1S001R0%i.dat',i));
    [trainingDataEEGcell{i},trainingDataEMGcell{i}]=generateTrainingData(sig,NFFT,window,shift,params);
    classesCell{i}=stat.StimulusCode;
    fprintf('%ith file processed\n',i)
end

trainingDataEEG=cell2mat(trainingDataEEGcell);
trainingDataEMG=cell2mat(trainingDataEMGcell);
classes=cell2mat(classesCell);

classification=classifyAccordingToEMG(trainingDataEEG, trainingDataEMG,classes,shift,params.SamplingRate.NumericValue,threshold);

smoothClassification=zeros(size(classification));
for i=1:size(classification,1)
    smoothClassification(i)=round(mean(classification(max(i-round(1/window),1):min(i+round(1/window),end))));        
end