diff --git a/usedMcode/callAll.m b/usedMcode/callAll.m index 76a725d..d25121e 100644 --- a/usedMcode/callAll.m +++ b/usedMcode/callAll.m @@ -44,11 +44,11 @@ parfor j=1:size(numbersMat,2) number=numbersMat(j); subject=subjectsForNumbers{j}; - readEEG(pathToFile,subject,number,windowEMG,windowEEG,shift,maxFile,threshold,pburgOrder,minEEGFreq,maxEEGFreq,pause); - [meanAccurancysEMG(j),maxCEMG(j,:),cmScaledEMG(j,:,:)]=svmEciton(pathToFile,subject,number,~EEG,k,maxExpC,maxPerClass,windowEMG,windowEEG,shift,minEEGFreq,maxEEGFreq,pause,pburgOrder); - [meanAccurancysEEG(j),maxCEEG(j,:),cmScaledEEG(j,:,:)]=svmEciton(pathToFile,subject,number,EEG,k,maxExpC,maxPerClass,windowEMG,windowEEG,shift,minEEGFreq,maxEEGFreq,pause,pburgOrder); - [correlationEMG(j,:)]=ridgeCV(pathToFile,subject,number,false,k,ridgeParams,windowEMG,windowEEG,shift,minEEGFreq,maxEEGFreq,pause,pburgOrder); - [correlationEEG(j,:)]=ridgeCV(pathToFile,subject,number,EEG,k,ridgeParams,windowEMG,windowEEG,shift,minEEGFreq,maxEEGFreq,pause,pburgOrder); + savePath=readEEG(pathToFile,subject,number,windowEMG,windowEEG,shift,maxFile,threshold,pburgOrder,minEEGFreq,maxEEGFreq,pause); + [meanAccurancysEMG(j),maxCEMG(j,:),cmScaledEMG(j,:,:)]=svmEciton(savePath,~EEG,k,maxExpC,maxPerClass); + [meanAccurancysEEG(j),maxCEEG(j,:),cmScaledEEG(j,:,:)]=svmEciton(savePath,EEG,k,maxExpC,maxPerClass); + [correlationEMG(j,:)]=ridgeCV(savePath,false,k,ridgeParams); + [correlationEEG(j,:)]=ridgeCV(savePath,EEG,k,ridgeParams); fprintf('%s%i finished %s\n',subject,number,datestr(datetime('now'))) end diff --git a/usedMcode/readEEG.m b/usedMcode/readEEG.m index a60b41f..ca13e5a 100644 --- a/usedMcode/readEEG.m +++ b/usedMcode/readEEG.m @@ -1,10 +1,11 @@ -function readEEG(pathToFile, subject,number,windowEMG,windowEEG,shift,maxFile,threshold,pburgOrder,minEEGFreq,maxEEGFreq,pause) +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(strcat(pathToFile,sprintf('../matlabData/%s%i%imsWindowEMG%isWindowEEG%imsShift1sPauseFreq%ito%iPause%i.mat',subject,number,windowEMG*1000,windowEEG,shift*1000,minEEGFreq,maxEEGFreq,pause)), 'file') ~= 2 - fprintf(strcat(pathToFile,sprintf('../matlabData/%s%i%imsWindowEMG%isWindowEEG%imsShift1sPauseFreq%ito%iPause%i.mat',subject,number,windowEMG*1000,windowEEG,shift*1000,minEEGFreq,maxEEGFreq,pause)),' not existanat; creating\n'); + if exist(savePath, 'file') ~= 2 + fprintf(strcat(savePath,' not existing; creating\n')); trainingDataEEGcell=cell(maxFile,1); trainingDataEMGcell=cell(maxFile,1); classesCell=cell(maxFile,1); @@ -43,7 +44,7 @@ kinematics=kinMat(smoothClassification~=-1,:); clear smoothClassification i - save(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)),'trainingDataEEG','trainingDataEMG','classification','kinematics','-v7.3'); + save(savePath,'trainingDataEEG','trainingDataEMG','classification','kinematics','-v7.3'); %fprintf('finished reading %s%i %s\n',subject,number,datestr(datetime('now'))); diff --git a/usedMcode/ridgeCV.m b/usedMcode/ridgeCV.m index fa5f021..bb686a3 100644 --- a/usedMcode/ridgeCV.m +++ b/usedMcode/ridgeCV.m @@ -1,5 +1,5 @@ -function [correlation]=ridgeCV(pathToFile,subject,number,EEG,k,ridgeParams,windowEMG,windowEEG,shift,minEEGFreq,maxEEGFreq,pause,pBurgOrder) - load(strcat(pathToFile,sprintf('../matlabData/%s%i%imsWindowEMG%isWindowEEG%imsShiftFreq%ito%iPause%i.mat',subject,number,windowEMG*1000,windowEEG,shift*1000,minEEGFreq,maxEEGFreq,pause,pBurgOrder))); +function [correlation]=ridgeCV(savePath,EEG,k,ridgeParams) + load(savePath); clear classification; if EEG trainingData=trainingDataEEG; diff --git a/usedMcode/svmEciton.m b/usedMcode/svmEciton.m index 268f704..0295064 100644 --- a/usedMcode/svmEciton.m +++ b/usedMcode/svmEciton.m @@ -1,6 +1,6 @@ -function [meanAccurancy,maxC, cmScaled]= svmEciton(pathToFile,subject,number,EEG,k,maxExpC,maxPerClass,windowEMG,windowEEG,shift,minEEGFreq,maxEEGFreq,pause,pBurgOrder) - load(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))); -% fprintf('%i,%i,%i',size(trainingDataEMG,1),size(trainingDataEEG,1),size(classification,1)) +function [meanAccurancy,maxC, cmScaled]= svmEciton(savePath,EEG,k,maxExpC,maxPerClass) + load(savePath) + % 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