function [classification]=classifyAccordingToEMG(trainingDataEEG, trainingDataEMG, classes,shift,frequency,threshold)
    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
                classification(i)=class;
                oldclass=class;
            else % task is to rest but movement not finished
                classification(i)=oldclass;
            end
        end
    end
end