function [classification]=classifyAccordingToEMG(trainingDataEEG, trainingDataEMG, classes,shift,frequency,threshold)
% classifyAccordingToEMG data classified as -1 should be taken out
classification=zeros([size(trainingDataEEG,1),1]);
oldclass=0;
for i=1:size(trainingDataEEG,1)
if mean(trainingDataEMG(i,:)) > threshold % is movement
class=mode(classes(max(round(shift*frequency*i-frequency),1):min(round(i*shift*frequency-1),end)));
if class <= 5 % task is to move
if oldclass==0
for j=max(fix(i-1/shift),1):fix(i-0.5/shift) % Pause before beginning of movement
classification(j)=-1; %code for pause
end
for j=max(fix(i-0.5/shift),1):i % half a second before executed movement there should be activity (esp. EEG)
classification(j)=-1;
end
oldclass=class;
end
classification(i)=class;
else % task is to rest but movement not finished
classification(i)=oldclass;
end
else
oldclass=0;
end
end
end