function [correlation]=ridgeCV(pathToFile,subject,number,EEG,k,ridgeParams)
    load(strcat(pathToFile,sprintf('../matlabData/%s%i200msWindowEMG1sWindowEEG200msShift1sPauseFreq0to200.mat',subject,number)));
    clear classification;
    if EEG
        trainingData=trainingDataEEG;
    else
        trainingData=trainingDataEMG;
    end
    clear trainingDataEEG;
    clear trainingDataEMG;
    
    randMap=randperm(size(trainingData,1));
    kin=kinematics;
    correlations=zeros([k,1]);
    
    parfor i=1:k
        leaveOut=trainingData(mod(randMap,k)==i-1,:,:);
        leaveKin=kin(mod(randMap,k)==i-1,:);
        remaining=trainingData(mod(randMap,k)~=i-1,:,:);
        remainingKin=kin(mod(randMap,k)~=i-1,:);
        %fprintf('%s create %ith model\n',datestr(datetime('now')),i)
        
        [coeffs]=kFoldRidge(remainingKin,remaining,k,ridgeParams);
        
        correlations(i)=ridgeCorrelation(leaveKin,leaveOut,coeffs);
    end
    
    correlation=mean(correlations);
end