function [trainingDataEEG,trainingDataEMG] = generateTrainingData(signal,windowEMG,windowEEG,shift,params,pburgOrder,minEEGFreq,maxEEGFreq)
    frequency=params.SamplingRate.NumericValue;
    signalWindowEMG=frequency*windowEMG;
    signalWindowEEG=frequency*windowEEG;
    tempEEG=zeros([32,fix(floor(size(signal,1)/signalWindowEEG-1)*windowEEG/shift+1),maxEEGFreq-minEEGFreq]);
    tempEMG=zeros(fix([size(signal,2)-3-32,fix(size(signal,1)/signalWindowEMG-1)*windowEMG/shift+1]));
    
    %Filter around 50Hz and below 2 Hz
    [A,B]= butter(2,[48 52]/(frequency/2),'stop');
    [C,D]= butter(2,1/(frequency/2),'high');

    parfor i=1:32 %filter single channel, w/o HEOG, Synchro and 0s
        tempEEG(i,:,:)=shiftingPburg(filter(C,D,filter(A,B,signal(:,i))),frequency,windowEEG,shift,pburgOrder,minEEGFreq,maxEEGFreq);
    end % TODO: 8-30Hz, pburg bei kurzen Fenstern (Ordnung: Je nach SamplingRate, bei 2500: 32-50, Alpha, Beta peaks sollten sichtbar sein)
    trainingDataEEG=permute(tempEEG,[2 1 3]);
    
    parfor i=33:size(signal,2)-3
        tempEMG(i-32,:,:)=waveformLength(filter(C,D,filter(A,B,signal(:,i))),frequency,windowEMG,shift);
    end
    trainingDataEMG=permute(tempEMG,[2 1 3]);
end