function [savePath]=readEEG(pathToFile, subject,number,windowEMG,windowEEG,shift,maxFile,threshold,pburgOrder,minEEGFreq,maxEEGFreq,pause)

    %fprintf('start read %s%i %s\n',subject,number,datestr(datetime('now')));
    savePath=strcat(pathToFile,sprintf('../matlabData/%s%i%imsWindowEMG%isWindowEEG%imsShiftFreq%ito%iPause%ipBurg%i.mat',subject,number,windowEMG*1000,windowEEG,shift*1000,minEEGFreq,maxEEGFreq,pause,pburgOrder));
    
    %only create file if it doesn't exist yet
    if exist(savePath, 'file') ~= 2
        fprintf(strcat(savePath,' not existing; creating\n'));
        trainingDataEEGcell=cell(maxFile,1);
        trainingDataEMGcell=cell(maxFile,1);
        classesCell=cell(maxFile,1);
        kin=cell([maxFile,1]);

        for i=1:maxFile
            [sig, stat, params] = load_bcidat(strcat(pathToFile,sprintf('%s/%s_B100%i/%s_B1S00%iR0%i.dat',subject,subject,number,subject,number,i)));
            tmpKin=csvread(strcat(pathToFile,sprintf('kin/%s_B1S00%iR0%i.txt',subject,number,i)),1,0);
            [trainingDataEEGcell{i},trainingDataEMGcell{i},kin{i}]=generateTrainingData(sig,tmpKin(:,1:4),windowEMG,windowEEG,shift,params,pburgOrder,minEEGFreq,maxEEGFreq);
            classesCell{i}=stat.StimulusCode;
            %fprintf('%ith file processed\n',i)
        end
        bci_sf=params.SamplingRate.NumericValue;

        clear sig

        trainingDataEEG=cell2mat(trainingDataEEGcell);
        trainingDataEMG=cell2mat(trainingDataEMGcell);
        classesMat=cell2mat(classesCell);
        kinMat=cell2mat(kin);
        clear trainingDataEEGcell trainingDataEMGcell classesCell kin

        classificationWithPause=classifyAccordingToEMG(trainingDataEEG, trainingDataEMG,classesMat,shift,bci_sf,threshold,pause);
        clear classesMat

        smoothClassification=zeros(size(classificationWithPause));
        for i=1:size(classificationWithPause,1)
            smoothClassification(i)=round(mode(classificationWithPause(max(i-fix(bci_sf/1000),1):min(i+fix(bci_sf/1000),end))));       
        end

        clear classificationWithPause

        trainingDataEEG=trainingDataEEG(smoothClassification~=-1,:,:);
        trainingDataEMG=trainingDataEMG(smoothClassification~=-1,:);
        classification=smoothClassification(smoothClassification~=-1);
        kinematics=kinMat(smoothClassification~=-1,:);

        clear smoothClassification i
        save(savePath,'trainingDataEEG','trainingDataEMG','classification','kinematics','-v7.3');


        %fprintf('finished reading %s%i %s\n',subject,number,datestr(datetime('now')));
    end
end
