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

    parfor i=1:32 %filter single channel, w/o HEOG, Synchro and 0s
        tempEEG(i,:,:)=shiftingPwelch(filter(C,D,filter(A,B,signal(:,i))),frequency,window,shift,NFFT);
    end
    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,window,shift);
    end
    trainingDataEMG=permute(tempEMG,[2 1 3]);
end