diff --git a/text/collection.txt b/text/collection.txt index 77dfff3..d96f829 100644 --- a/text/collection.txt +++ b/text/collection.txt @@ -12,6 +12,6 @@ Move/Rest EMG : 99.9535% Bewegungen EMG: 77.7352% bzw. 55.8440% wenn 0.5s vorher einbezogen EMG bei 1s Pause vor Bewegungsbeginn 70.4908% +allSubjectsAllDays: +EMG: 56.11%, EEG: 42.2% (pburgOrder 50, EMGwindow 0.2, 1s Pause, c=1 fest) - -Vergleich mit/ohne grid Search diff --git a/usedMcode/callAll.m b/usedMcode/callAll.m index d0d6af9..5e100be 100644 --- a/usedMcode/callAll.m +++ b/usedMcode/callAll.m @@ -1,6 +1,6 @@ addpath('/home/hohlochj/masterarbeit/usedMcode') pathToFile='/nfs/wsi/ti/messor/hohlochj/origData/'; -% pathToFile='/home/jph/Uni/masterarbeit/Block1_ReachingMovements/'; +%pathToFile='/home/jph/Uni/masterarbeit/Block1_ReachingMovements/'; windowEMG=0.2; %try 1s windowEEG=1; @@ -25,6 +25,10 @@ meanAccurancysEMG=zeros([j,1]); meanAccurancysEEG=zeros([j,1]); +maxCEMG=zeros([j,k,1]); +maxCEEG=zeros([j,k,1]); +cmScaledEMG=zeros([j,5,5]); +cmScaledEEG=zeros([j,5,5]); j=1; for i=1:size(subjects,2) @@ -32,15 +36,13 @@ for number=numbers{i} % fprintf('%s%i\n',subject,number); readEEG(pathToFile,subject,number,windowEMG,windowEEG,shift,5,7500,pburgOrder,minEEGFreq,maxEEGFreq); - meanAccurancysEMG(j)=svmEciton(subject,number,false,k,maxExpC,maxPerClass); - meanAccurancysEEG(j)=svmEciton(subject,number,EEG,k,maxExpC,maxPerClass); + [meanAccurancysEMG(j),maxCEMG(j,:),cmScaledEMG(j,:,:)]=svmEciton(pathToFile,subject,number,false,k,maxExpC,maxPerClass); + [meanAccurancysEEG(j),maxCEEG(j,:),cmScaledEEG(j,:,:)]=svmEciton(pathToFile,subject,number,EEG,k,maxExpC,maxPerClass); j=j+1; end end -[ accEEG, accEMG, cmEEG, cmEMG ] = collectAccurancys( pathToFile, subjects, numbers ); - -save(sprintf('/nfs/wsi/ti/messor/hohlochj/matlabData/%s_callAll.mat',datestr(datetime('now')))); +save(strcat(pathToFile,sprintf('../matlabData/%s_callAll.mat',datestr(datetime('now'))))); delete(poolObj) diff --git a/usedMcode/readEEG.m b/usedMcode/readEEG.m index 2c4b875..148c4c3 100644 --- a/usedMcode/readEEG.m +++ b/usedMcode/readEEG.m @@ -15,30 +15,30 @@ %fprintf('%ith file processed\n',i) end - %clear sig + clear sig trainingDataEEG=cell2mat(trainingDataEEGcell); trainingDataEMG=cell2mat(trainingDataEMGcell); classesMat=cell2mat(classesCell); kinMat=cell2mat(kin); - %clear trainingDataEEGcell trainingDataEMGcell classesCell kin + clear trainingDataEEGcell trainingDataEMGcell classesCell kin classificationWithPause=classifyAccordingToEMG(trainingDataEEG, trainingDataEMG,classesMat,shift,params.SamplingRate.NumericValue,threshold); - %clear classesMat + clear classesMat smoothClassification=zeros(size(classificationWithPause)); for i=1:size(classificationWithPause,1) smoothClassification(i)=round(mode(classificationWithPause(max(i-2,1):min(i+2,end)))); end - %clear classificationWithPause + clear classificationWithPause trainingDataEEG=trainingDataEEG(smoothClassification~=-1,:,:); trainingDataEMG=trainingDataEMG(smoothClassification~=-1,:); classification=smoothClassification(smoothClassification~=-1); kinematics=kinMat(smoothClassification~=-1,:); - %clear smoothClassification i + clear smoothClassification i save(strcat(pathToFile,sprintf('../matlabData/%s%i200msWindowEMG1sWindowEEG200msShift1sPauseFreq0to200.mat',subject,number)),'trainingDataEEG','trainingDataEMG','classification','kinematics','-v7.3'); diff --git a/usedMcode/svmEciton.m b/usedMcode/svmEciton.m index c91d139..86c0611 100644 --- a/usedMcode/svmEciton.m +++ b/usedMcode/svmEciton.m @@ -1,5 +1,5 @@ -function [meanAccurancy]= svmEciton(subject,number,EEG,k,maxExpC,maxPerClass) - load(sprintf('/nfs/wsi/ti/messor/hohlochj/matlabData/%s%i200msWindowEMG1sWindowEEG200msShift1sPauseFreq0to200.mat',subject,number)); +function [meanAccurancy,maxC, cmScaled]= svmEciton(pathToFile,subject,number,EEG,k,maxExpC,maxPerClass) + load(strcat(pathToFile,sprintf('../matlabData/%s%i200msWindowEMG1sWindowEEG200msShift1sPauseFreq0to200.mat',subject,number))); % fprintf('%i,%i,%i',size(trainingDataEMG,1),size(trainingDataEEG,1),size(classification,1)) addpath('/nfs/wsi/ti/messor/hohlochj/libsvm/matlab'); @@ -32,7 +32,7 @@ [predictions,accurancy(i,:),~]=svmpredict(leaveClasses,leaveOut(:,:),model); cm=cm+confusionmat(leaveClasses,predictions); %confusion matrix end - meanAccurancy=mean(accurancy(:,1)) + meanAccurancy=mean(accurancy(:,1)); fig=figure; cmScaled=zeros(size(cm)); @@ -41,7 +41,7 @@ end imagesc(cmScaled) colorbar(); - saveas(fig,sprintf('/nfs/wsi/ti/messor/hohlochj/plots/%s%i%icm200ms1sPause.fig',subject,number,EEG),'fig'); - save(sprintf('/nfs/wsi/ti/messor/hohlochj/matlabData/%s%i%i200ms1sPause.mat',subject,number,EEG),'meanAccurancy','maxC','cmScaled','-v7.3'); + 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'); fprintf('%s%i%i finished %s\n',subject,number,EEG,datestr(datetime('now'))) end