function [trainingDataEEG,trainingDataEMG] = generateTrainingData(splitSignals,NFFT,window,shift,params,secs)
    frequency=params.SamplingRate.NumericValue;
    tempEEG2=zeros([32,size(splitSignals,3),NFFT/2+1]);
    tempEMG2=zeros(fix([size(splitSignals,2)-3-32,size(splitSignals,3),fix(floor(size(splitSignals,1)/(frequency*window))-1)*window/shift+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=zeros(size(splitSignals,3),NFFT/2+1);
        for j=1:size(splitSignals,3) %filter single trial
            tempEEG(j,:)=pwelch(filter(C,D,filter(A,B,splitSignals(1:secs*frequency,i,j))),[],[],NFFT,frequency);
        end
        tempEEG2(i,:,:)=tempEEG;
    end
    trainingDataEEG=permute(tempEEG2,[2 1 3]);
    
    parfor i=33:size(splitSignals,2)-3
        tempEMG=zeros(fix([size(splitSignals,3),(floor(size(splitSignals,1)/(frequency*window))-1)*window/shift+1]));
        for j=1:size(splitSignals,3) %filter single trial
            tempEMG(j,:)=waveformLength(filter(C,D,filter(A,B,splitSignals(:,i,j))),frequency,window,shift);
        end
        tempEMG2(i,:,:)=tempEMG;
    end
    trainingDataEMG=permute(tempEMG2,[2 1 3]);
end