function [meanAccurancy,maxC, cmScaled]= svmEciton(pathToFile,subject,number,EEG,k,maxExpC,maxPerClass,windowEMG,windowEEG,shift,minEEGFreq,maxEEGFreq,pause)
    load(strcat(pathToFile,sprintf('../matlabData/%s%i%imsWindowEMG%isWindowEEG%imsShift1sPauseFreq%ito%iPause%i.mat',subject,number,windowEMG*1000,windowEEG,shift*1000,minEEGFreq,maxEEGFreq,pause)));
%    fprintf('%i,%i,%i',size(trainingDataEMG,1),size(trainingDataEEG,1),size(classification,1))
    addpath('/nfs/wsi/ti/messor/hohlochj/libsvm/matlab');

    %choose to estimate based on EEG or EMG
    if EEG
        trainingData=trainingDataEEG;
    else
        trainingData=trainingDataEMG;
    end
    clear trainingDataEEG;
    clear trainingDataEMG;
    
    accurancy=zeros(k,3);
    maxC=zeros(k,1);
    noClasses=size(unique(classification),1);
    cm=zeros(noClasses);
    randMap=randperm(size(trainingData,1));
    %disp('startCV')
    classes=classification; %necessary since otherwise classes are not passed to workers
    clear classification;
    parfor i=1:k
        leaveOut=trainingData(mod(randMap,k)==i-1,:,:);
        leaveClasses=classes(mod(randMap,k)==i-1);
        remaining=trainingData(mod(randMap,k)~=i-1,:,:);
        remainingClasses=classes(mod(randMap,k)~=i-1);
        %fprintf('%s create %ith model\n',datestr(datetime('now')),i)
        
        [model,maxC(i)]=kfoldCV(remainingClasses,remaining,k,maxExpC,maxPerClass);

        [predictions,accurancy(i,:),~]=svmpredict(leaveClasses,leaveOut(:,:),model);
        cm=cm+confusionmat(leaveClasses,predictions); %confusion matrix
    end
    meanAccurancy=mean(accurancy(:,1));

    cmScaled=zeros(size(cm));
    for i=1:size(cm,1)
        cmScaled(i,:)=cm(i,:)/sum(cm(i,:));
    end
%     fig=figure;
%     imagesc(cmScaled)
%     colorbar();
    %saveas(fig,strcat(pathToFile,sprintf('../plots/%s%i%icm200ms1sPause.fig',subject,number,EEG)),'fig');
    %save(strcat(pathToFile,sprintf('../matlabData/%s%i%i200ms1sPause.mat',subject,number,EEG)),'meanAccurancy','maxC','cmScaled','-v7.3');
end
