diff --git a/usedMcode/callAll.m b/usedMcode/callAll.m index 4e0e3f4..8982846 100644 --- a/usedMcode/callAll.m +++ b/usedMcode/callAll.m @@ -81,18 +81,18 @@ [meanAccurancysEMG(j),maxCEMG(j,:),cmScaledEMG(j,:,:)]=svmEciton(savePath,'EMG',k,maxExpC,maxPerClass,eegOffset); [meanAccurancysEEG(j),maxCEEG(j,:),cmScaledEEG(j,:,:)]=svmEciton(savePath,'EEG',k,maxExpC,maxPerClass,eegOffset); [meanAccurancysLF(j),maxCLF(j,:),cmScaledLF(j,:,:)]=svmEciton(savePath,'LF',k,maxExpC,maxPerClass,eegOffset); - [correlationEMGkin(j,:),maxRidgeParamIndexEMGkin(j,:,:)]=ridgeCV(savePath,'EMG','kin',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEEGkin(j,:),maxRidgeParamIndexEEGkin(j,:,:)]=ridgeCV(savePath,'EEG','kin',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationLFkin(j,:),maxRidgeParamIndexLFkin(j,:,:)]=ridgeCV(savePath,'LF','kin',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEMGautoenc(j,:),maxRidgeParamIndexEMGautoenc(j,:,:)]=ridgeCV(savePath,'EMG','Autoenc',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEEGautoenc(j,:),maxRidgeParamIndexEEGautoenc(j,:,:)]=ridgeCV(savePath,'EEG','Autoenc',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationLFautoenc(j,:),maxRidgeParamIndexLFautoenc(j,:,:)]=ridgeCV(savePath,'LF','Autoenc',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEMGpca(j,:),maxRidgeParamIndexEMGpca(j,:,:)]=ridgeCV(savePath,'EMG','PCA',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEEGpca(j,:),maxRidgeParamIndexEEGpca(j,:,:)]=ridgeCV(savePath,'EEG','PCA',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationLFpca(j,:),maxRidgeParamIndexLFpca(j,:,:)]=ridgeCV(savePath,'LF','PCA',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEMGnnmf(j,:),maxRidgeParamIndexEMGnnmf(j,:,:)]=ridgeCV(savePath,'EMG','NNMF',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEEGnnmf(j,:),maxRidgeParamIndexEEGnnmf(j,:,:)]=ridgeCV(savePath,'EEG','NNMF',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationLFnnmf(j,:),maxRidgeParamIndexLFnnmf(j,:,:)]=ridgeCV(savePath,'LF','NNMF',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); + [correlationEMGkin(j,:),maxRidgeParamIndexEMGkin(j,:,:)]=ridgeCV(savePath,'EMG','kin',k,ridgeParams,eegOffset); + [correlationEEGkin(j,:),maxRidgeParamIndexEEGkin(j,:,:)]=ridgeCV(savePath,'EEG','kin',k,ridgeParams,eegOffset); + [correlationLFkin(j,:),maxRidgeParamIndexLFkin(j,:,:)]=ridgeCV(savePath,'LF','kin',k,ridgeParams,eegOffset); + [correlationEMGautoenc(j,:),maxRidgeParamIndexEMGautoenc(j,:,:)]=ridgeCV(savePath,'EMG','Autoenc',k,ridgeParams,eegOffset); + [correlationEEGautoenc(j,:),maxRidgeParamIndexEEGautoenc(j,:,:)]=ridgeCV(savePath,'EEG','Autoenc',k,ridgeParams,eegOffset); + [correlationLFautoenc(j,:),maxRidgeParamIndexLFautoenc(j,:,:)]=ridgeCV(savePath,'LF','Autoenc',k,ridgeParams,eegOffset); + [correlationEMGpca(j,:),maxRidgeParamIndexEMGpca(j,:,:)]=ridgeCV(savePath,'EMG','PCA',k,ridgeParams,eegOffset); + [correlationEEGpca(j,:),maxRidgeParamIndexEEGpca(j,:,:)]=ridgeCV(savePath,'EEG','PCA',k,ridgeParams,eegOffset); + [correlationLFpca(j,:),maxRidgeParamIndexLFpca(j,:,:)]=ridgeCV(savePath,'LF','PCA',k,ridgeParams,eegOffset); + [correlationEMGnnmf(j,:),maxRidgeParamIndexEMGnnmf(j,:,:)]=ridgeCV(savePath,'EMG','NNMF',k,ridgeParams,eegOffset); + [correlationEEGnnmf(j,:),maxRidgeParamIndexEEGnnmf(j,:,:)]=ridgeCV(savePath,'EEG','NNMF',k,ridgeParams,eegOffset); + [correlationLFnnmf(j,:),maxRidgeParamIndexLFnnmf(j,:,:)]=ridgeCV(savePath,'LF','NNMF',k,ridgeParams,eegOffset); fprintf('%s%i finished %s\n',subject,number,datestr(datetime('now'))) end @@ -106,18 +106,18 @@ [meanAccurancysEMG,maxCEMG,cmScaledEMG(:,:)]=svmEciton(savePath,'EMG',k,maxExpC,maxPerClass,eegOffset); [meanAccurancysEEG,maxCEEG,cmScaledEEG(:,:)]=svmEciton(savePath,'EEG',k,maxExpC,maxPerClass,eegOffset); [meanAccurancysLF,maxCLF,cmScaledLF(:,:)]=svmEciton(savePath,'LF',k,maxExpC,maxPerClass,eegOffset); - [correlationEMGkin,maxRidgeParamIndexEMGkin(:,:)]=ridgeCV(savePath,'EMG','kin',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEEGkin,maxRidgeParamIndexEEGkin(:,:)]=ridgeCV(savePath,'EEG','kin',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationLFkin,maxRidgeParamIndexLFkin(:,:)]=ridgeCV(savePath,'LF','kin',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEMGautoenc,maxRidgeParamIndexEMGautoenc(:,:)]=ridgeCV(savePath,'EMG','Autoenc',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEEGautoenc,maxRidgeParamIndexEEGautoenc(:,:)]=ridgeCV(savePath,'EEG','Autoenc',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationLFautoenc,maxRidgeParamIndexLFautoenc(:,:)]=ridgeCV(savePath,'LF','Autoenc',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEMGpca,maxRidgeParamIndexEMGpca(:,:)]=ridgeCV(savePath,'EMG','PCA',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEEGpca,maxRidgeParamIndexEEGpca(:,:)]=ridgeCV(savePath,'EEG','PCA',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationLFpca,maxRidgeParamIndexLFpca(:,:)]=ridgeCV(savePath,'LF','PCA',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEMGnnmf,maxRidgeParamIndexEMGnnmf(:,:)]=ridgeCV(savePath,'EMG','NNMF',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationEEGnnmf,maxRidgeParamIndexEEGnnmf(:,:)]=ridgeCV(savePath,'EEG','NNMF',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); - [correlationLFnnmf,maxRidgeParamIndexLFnnmf(:,:)]=ridgeCV(savePath,'LF','NNMF',k,ridgeParams,shiftEMG,shiftEEG,eegOffset); + [correlationEMGkin,maxRidgeParamIndexEMGkin(:,:)]=ridgeCV(savePath,'EMG','kin',k,ridgeParams,eegOffset); + [correlationEEGkin,maxRidgeParamIndexEEGkin(:,:)]=ridgeCV(savePath,'EEG','kin',k,ridgeParams,eegOffset); + [correlationLFkin,maxRidgeParamIndexLFkin(:,:)]=ridgeCV(savePath,'LF','kin',k,ridgeParams,eegOffset); + [correlationEMGautoenc,maxRidgeParamIndexEMGautoenc(:,:)]=ridgeCV(savePath,'EMG','Autoenc',k,ridgeParams,eegOffset); + [correlationEEGautoenc,maxRidgeParamIndexEEGautoenc(:,:)]=ridgeCV(savePath,'EEG','Autoenc',k,ridgeParams,eegOffset); + [correlationLFautoenc,maxRidgeParamIndexLFautoenc(:,:)]=ridgeCV(savePath,'LF','Autoenc',k,ridgeParams,eegOffset); + [correlationEMGpca,maxRidgeParamIndexEMGpca(:,:)]=ridgeCV(savePath,'EMG','PCA',k,ridgeParams,eegOffset); + [correlationEEGpca,maxRidgeParamIndexEEGpca(:,:)]=ridgeCV(savePath,'EEG','PCA',k,ridgeParams,eegOffset); + [correlationLFpca,maxRidgeParamIndexLFpca(:,:)]=ridgeCV(savePath,'LF','PCA',k,ridgeParams,eegOffset); + [correlationEMGnnmf,maxRidgeParamIndexEMGnnmf(:,:)]=ridgeCV(savePath,'EMG','NNMF',k,ridgeParams,eegOffset); + [correlationEEGnnmf,maxRidgeParamIndexEEGnnmf(:,:)]=ridgeCV(savePath,'EEG','NNMF',k,ridgeParams,eegOffset); + [correlationLFnnmf,maxRidgeParamIndexLFnnmf(:,:)]=ridgeCV(savePath,'LF','NNMF',k,ridgeParams,eegOffset); fprintf('%s%i finished %s\n',subject,number,datestr(datetime('now'))) save(strcat(pathToFile,sprintf('../matlabData/%s_call%s%i-%s.mat',datestr(datetime('now')),subject,number,name))); diff --git a/usedMcode/ridgeCV.m b/usedMcode/ridgeCV.m index f481f03..a4a1ff4 100644 --- a/usedMcode/ridgeCV.m +++ b/usedMcode/ridgeCV.m @@ -1,21 +1,20 @@ -function [correlation,maxRidgeParamIndex]=ridgeCV(savePath,data,goal,k,ridgeParams,shiftEMG,shiftEEG,eegOffset) +function [correlation,maxRidgeParamIndex]=ridgeCV(savePath,data,goal,k,ridgeParams,eegOffset) load(savePath); clear classification; eeg=false; if strcmp(data,'EEG') eeg=true; trainingData=trainingDataEEG(eegOffset+1:end,:); - factor=shiftEEG/shiftEMG; elseif strcmp(data,'EMG') trainingData=trainingDataEMG; - factor=1; elseif strcmp(data,'LF') eeg=true; trainingData=trainingDataEEGlf(eegOffset+1:end,:); - factor=shiftEEG/shiftEMG; else error('only EEG, EMG and LF are valid inputs for data'); end + + factor=size(trainingDataEMG,1)/(size(trainingData,1)+eegOffset); clear trainingDataEEG; clear trainingDataEEGlf; diff --git a/usedMcode/shiftingMean.m b/usedMcode/shiftingMean.m index 91c119b..7c417ae 100644 --- a/usedMcode/shiftingMean.m +++ b/usedMcode/shiftingMean.m @@ -4,7 +4,7 @@ dataSize=size(data); output=zeros([fix(ceil(dataSize(1)/factor)),dataSize(2:end)]); for i=1:size(output,1) - output(i,:)=mean(data((i-1)*factor+1:min(i*factor,dataSize(1)),:),1); + output(i,:)=mean(data(fix(round((i-1)*factor))+1:min(fix(round(i*factor)),dataSize(1)),:),1); end end