diff --git a/usedMcode/callAllPos.m b/usedMcode/callAllPos.m index 3a8c296..feb153a 100644 --- a/usedMcode/callAllPos.m +++ b/usedMcode/callAllPos.m @@ -59,7 +59,7 @@ number=numbersMat(j); subject=subjectsForNumbers{j}; savePath=readAllPos(pathToFile, subject,number,windowEMG,windowEEG,shiftEMG,shiftEEG,maxFile,... - threshold,pburgOrder,minEEGFreq,maxEEGFreq,pause,noLFsamples,EMGChannels); + threshold,pburgOrder,minEEGFreq,maxEEGFreq,pause,noLFsamples,EMGChannels,noSynergies); % [correlationEMGpos(j,:),maxRidgeParamIndex(j,:,:)]=ridgeCV(savePath,'EMG','kin',k,ridgeParams,eegOffset); % [correlationEEGpos(j,:),maxRidgeParamIndex(j,:,:)]=ridgeCV(savePath,'EEG','kin',k,ridgeParams,eegOffset); % [correlationLFpos(j,:),maxRidgeParamIndex(j,:,:)]=ridgeCV(savePath,'LF','kin',k,ridgeParams,eegOffset); diff --git a/usedMcode/readAllPos.m b/usedMcode/readAllPos.m index ab1d427..d68bf85 100644 --- a/usedMcode/readAllPos.m +++ b/usedMcode/readAllPos.m @@ -1,10 +1,10 @@ function [savePath]=readAllPos(pathToFile, subject,number,windowEMG,windowEEG,shiftEMG,shiftEEG,maxFile,... - threshold,pburgOrder,minEEGFreq,maxEEGFreq,pause,noLFsamples,EMGChannels) + threshold,pburgOrder,minEEGFreq,maxEEGFreq,pause,noLFsamples,EMGChannels,noSynergies) %fprintf('start read %s%i %s\n',subject,number,datestr(datetime('now'))); savePath=strcat(pathToFile,... - sprintf('../matlabData/%s%i%imsWindowEMG%isWindowEEG%imsShiftEMG%imsShiftEEGFreq%ito%iPause%ipBurg%iPos.mat',... - subject,number,windowEMG*1000,windowEEG,shiftEMG*1000,shiftEEG*1000,minEEGFreq,maxEEGFreq,pause,pburgOrder)); + sprintf('../matlabData/%s%i%imsWindowEMG%isWindowEEG%imsShiftEMG%imsShiftEEGFreq%ito%iPause%ipBurg%inoSyn%iPos.mat',... + subject,number,windowEMG*1000,windowEEG,shiftEMG*1000,shiftEEG*1000,minEEGFreq,maxEEGFreq,pause,pburgOrder,noSynergies)); %only create file if it doesn't exist yet if exist(savePath, 'file') ~= 2 @@ -51,6 +51,7 @@ clear classificationWithPause + %adjust to length of EEG data smoothClassificationEEG=zeros([size(trainingDataEEG,1),1]); for i=1:size(smoothClassificationEEG,1) smoothClassificationEEG(i)=mode(smoothClassificationEMG(fix(... @@ -67,13 +68,21 @@ % all created matching the size of EMGdata, if necessary downsampling % has to be done when used kinematics=kinMat(smoothClassificationEMG~=-1,:); - + ae=trainAutoencoder(trainingDataEMG',noSynergies,'ShowProgressWindow',false); + synergiesAutoenc=encode(ae,trainingDataEMG')'; + COEFF=pca(trainingDataEMG,'Centered',false); + synergiesPCA=trainingDataEMG/COEFF(:,1:noSynergies)'; + [~,H]=nnmf(trainingDataEMG,noSynergies); + synergiesNNMF=trainingDataEMG*H'; clear smoothClassification i save(savePath,'trainingDataEEG','trainingDataEEGlf','trainingDataEMG',... - 'classificationEMG','classificationEEG','kinematics','-v7.3'); + 'classificationEMG','classificationEEG','kinematics','synergiesAutoenc',... + 'synergiesPCA','synergiesNNMF','-v7.3'); %fprintf('finished reading %s%i %s\n',subject,number,datestr(datetime('now'))); + else + fprintf(strcat(savePath,' yet existing; nothing to do\n')); end end