clc; %deletes content of command window clear all; %deletes workspace close all; %closes figures cd('C:\Users\farid\Desktop\Kinesio\MAT'); for Proband = 1:5 for Kinesio = 1:2 %Erst ohne dann mit Kinesio einlesen clear Start_End; [FileName,PathName] = uigetfile('*.mat','Select the MATLAB data file'); cd(PathName); load(FileName); Gonio1_abs=abs(Gonio1); %Butterworth Filter fc = 20; % Cut-off frequency (Hz) fs = 1000; % Sampling rate (Hz) order = 2; % Filter order [B,A] = butter(order,fc/(fs/2)); % Coefficients B and A are defined using the inputs Gonio1_abs_filt = filtfilt(B,A,Gonio1_abs); %EMG data is filtered %figure(1); %plot(Gonio1_abs_filt); %% Start Ende bestimmen Level=0.025; %Level of force where step should be detected i=1; %running variable that increases from 1 to the maximum number of frames of Fz pos=1; %running variable position for saving i values when contact happens while (i < length(Gonio1_abs_filt)) %as long i is smaller than length of Fz i=i+1; if Gonio1_abs_filt(i) > Level %if force of Fz higher than the detection level Start_End(pos,1)=i; %a value for Start_End is saved pos=pos+1; %to avoid overwriting of Start_End position to save is increased while Gonio1_abs_filt(i) > Level && i < length(Gonio1_abs_filt) %after finding a value higher than Level the system continious searching for a value smaller than the level %in addition the system should stop if the increasing variable i reaches the value of the length of Fz (to avoid error) i=i+1; end; Start_End(pos,1)=i; %if a smaller value is found the value of i (frame) is saved to Start_End pos=pos+1; %to avoid overwriting of Start_End position to save is increased end; end; if Proband == 3 Start_End(15:16)=''; end; %% EMG Daten bearbeiten %BICEPS Biceps_abs=abs(Biceps); %Butterworth Filter fc = 3; % Cut-off frequency (Hz) fs = 1000; % Sampling rate (Hz) order = 2; % Filter order [B,A] = butter(order,fc/(fs/2)); % Coefficients B and A are defined using the inputs Biceps_abs_filt = filtfilt(B,A,Biceps_abs); %EMG data is filtered % figure(2); % plot(Biceps,'k');hold on; % plot(Biceps_abs,'b','LineStyle','--');hold on; % plot(Biceps_abs_filt,'r','LineWidth',3); % legend('Measured','Absolute','Filtered Absolute'); %% Schritte ausschneiden Number_of_Steps=length(Start_End)/2; %number of steps should be defined for i=1:Number_of_Steps-1 data=Biceps_abs_filt(Start_End(i*2-1):Start_End(i*2+1)); %data is used from one starting point to the next starting point - whole gait cycle Biceps_100(:,i) = interp1(1 : length(data) , data , linspace(1, length(data),100)); %interp1(original structure, values , new structure ) end Mean_Biceps_100=mean(Biceps_100,2); Max_Mean_Biceps_100=max(Mean_Biceps_100); ALL_Biceps(Kinesio,Proband)=Max_Mean_Biceps_100; if Kinesio == 1 ALL_oK_Mean_Biceps_100(:,Proband)=Mean_Biceps_100; end; if Kinesio == 2 ALL_mK_Mean_Biceps_100(:,Proband)=Mean_Biceps_100; end; %************************************************ %TRICEPS %% EMG Daten bearbeiten Triceps_abs=abs(Triceps); %Butterworth Filter fc = 3; % Cut-off frequency (Hz) fs = 1000; % Sampling rate (Hz) order = 2; % Filter order [B,A] = butter(order,fc/(fs/2)); % Coefficients B and A are defined using the inputs Triceps_abs_filt = filtfilt(B,A,Triceps_abs); %EMG data is filtered % figure(2); % plot(Triceps,'k');hold on; % plot(Triceps_abs,'b','LineStyle','--');hold on; % plot(Triceps_abs_filt,'r','LineWidth',3); % legend('Measured','Absolute','Filtered Absolute'); %% Schritte ausschneiden Number_of_Steps=length(Start_End)/2; %number of steps should be defined for i=1:Number_of_Steps-1 data=Triceps_abs_filt(Start_End(i*2-1):Start_End(i*2+1)); %data is used from one starting point to the next starting point - whole gait cycle Triceps_100(:,i) = interp1(1 : length(data) , data , linspace(1, length(data),100)); %interp1(original structure, values , new structure ) end Mean_Triceps_100=mean(Triceps_100,2); Max_Mean_Triceps_100=max(Mean_Triceps_100); ALL_Triceps(Kinesio,Proband)=Max_Mean_Triceps_100; if Kinesio == 1 ALL_oK_Mean_Triceps_100(:,Proband)=Mean_Triceps_100; end; if Kinesio == 2 ALL_mK_Mean_Triceps_100(:,Proband)=Mean_Triceps_100; end; %****************************************** end; end; ALL_Faktor_Biceps=100./ALL_Biceps; for i=1:5 ALL_oK_Mean_Biceps_100_norm(:,i)=ALL_oK_Mean_Biceps_100(:,i).*ALL_Faktor_Biceps(1,i); end; for i=1:5 ALL_mK_Mean_Biceps_100_norm(:,i)=ALL_mK_Mean_Biceps_100(:,i).*ALL_Faktor_Biceps(2,i); end; ALL_Mean_oK_Mean_Biceps_100_norm=mean(ALL_oK_Mean_Biceps_100_norm,2); ALL_Mean_mK_Mean_Biceps_100_norm=mean(ALL_mK_Mean_Biceps_100_norm,2); ALL_Faktor_Triceps=100./ALL_Triceps; for i=1:5 ALL_oK_Mean_Triceps_100_norm(:,i)=ALL_oK_Mean_Triceps_100(:,i).*ALL_Faktor_Triceps(1,i); end; for i=1:5 ALL_mK_Mean_Triceps_100_norm(:,i)=ALL_mK_Mean_Triceps_100(:,i).*ALL_Faktor_Triceps(2,i); end; ALL_Mean_oK_Mean_Triceps_100_norm=mean(ALL_oK_Mean_Triceps_100_norm,2); ALL_Mean_mK_Mean_Triceps_100_norm=mean(ALL_mK_Mean_Triceps_100_norm,2); %Nachbearbeitung Messdaten Prozent_Biceps=100-(100./ALL_Biceps(1,:).*ALL_Biceps(2,:)); Mean_Prozent_Biceps=mean(Prozent_Biceps,2); Std_Prozent_Biceps=std(Prozent_Biceps); %Nachbearbeitung Messdaten Prozent_Triceps=100-(100./ALL_Triceps(1,:).*ALL_Triceps(2,:)); Mean_Prozent_Triceps=mean(Prozent_Triceps,2); Std_Prozent_Triceps=std(Prozent_Triceps); save('Save.mat'); % figure(1); % plot(ALL_mK_Mean_Biceps_100(:,1),'r');hold on; % plot(ALL_oK_Mean_Biceps_100(:,1),'k');hold on; % % figure(2); % plot(ALL_mK_Mean_Triceps_100(:,1),'r');hold on; % plot(ALL_oK_Mean_Triceps_100(:,1),'k');hold on; clc; %deletes content of command window clear all; %deletes workspace close all; %closes figures cd('C:\Users\farid\Desktop\Kinesio\MAT'); for Proband = 1:5 for Kinesio = 1:2 %Erst ohne dann mit Kinesio einlesen clear Start_End G*; clear B* M* N*; clear T* S* p* i*; [FileName,PathName] = uigetfile('*.mat','Select the MATLAB data file'); cd(PathName); load(FileName); Gonio1_abs=abs(Gonio1); %Butterworth Filter fc = 20; % Cut-off frequency (Hz) fs = 1000; % Sampling rate (Hz) order = 2; % Filter order [B,A] = butter(order,fc/(fs/2)); % Coefficients B and A are defined using the inputs Gonio1_abs_filt = filtfilt(B,A,Gonio1_abs); %EMG data is filtered %figure(1); %plot(Gonio1_abs_filt); %% Start Ende bestimmen Level=0.025; %Level of force where step should be detected i=1; %running variable that increases from 1 to the maximum number of frames of Fz pos=1; %running variable position for saving i values when contact happens while (i < length(Gonio1_abs_filt)) %as long i is smaller than length of Fz i=i+1; if Gonio1_abs_filt(i) > Level %if force of Fz higher than the detection level Start_End(pos,1)=i; %a value for Start_End is saved pos=pos+1; %to avoid overwriting of Start_End position to save is increased while Gonio1_abs_filt(i) > Level && i < length(Gonio1_abs_filt) %after finding a value higher than Level the system continious searching for a value smaller than the level %in addition the system should stop if the increasing variable i reaches the value of the length of Fz (to avoid error) i=i+1; end; Start_End(pos,1)=i; %if a smaller value is found the value of i (frame) is saved to Start_End pos=pos+1; %to avoid overwriting of Start_End position to save is increased end; end; if Proband == 3 Start_End(15:16)=''; end; % if Proband == 5 % Start_End(15:16)=''; % end; %% EMG Daten bearbeiten %BICEPS Biceps_abs=abs(Biceps); %Butterworth Filter fc = 3; % Cut-off frequency (Hz) fs = 1000; % Sampling rate (Hz) order = 2; % Filter order [B,A] = butter(order,fc/(fs/2)); % Coefficients B and A are defined using the inputs Biceps_abs_filt = filtfilt(B,A,Biceps_abs); %EMG data is filtered % figure(2); % plot(Biceps,'k');hold on; % plot(Biceps_abs,'b','LineStyle','--');hold on; % plot(Biceps_abs_filt,'r','LineWidth',3); % legend('Measured','Absolute','Filtered Absolute'); %% Schritte ausschneiden Number_of_Steps=7;%length(Start_End)/2; %number of steps should be defined for i=1:Number_of_Steps-1 data=Biceps_abs_filt(Start_End(i*2-1):Start_End(i*2+1)); %data is used from one starting point to the next starting point - whole gait cycle Biceps_100(:,i) = interp1(1 : length(data) , data , linspace(1, length(data),100)); %interp1(original structure, values , new structure ) end Mean_Biceps_100=mean(Biceps_100,2); Max_Mean_Biceps_100=max(Mean_Biceps_100); ALL_Biceps(Kinesio,Proband)=Max_Mean_Biceps_100; if Kinesio == 1 ALL_oK_Mean_Biceps_100(:,Proband)=Mean_Biceps_100; end; if Kinesio == 2 ALL_mK_Mean_Biceps_100(:,Proband)=Mean_Biceps_100; end; %************************************************ %TRICEPS %% EMG Daten bearbeiten Triceps_abs=abs(Triceps); %Butterworth Filter fc = 3; % Cut-off frequency (Hz) fs = 1000; % Sampling rate (Hz) order = 2; % Filter order [B,A] = butter(order,fc/(fs/2)); % Coefficients B and A are defined using the inputs Triceps_abs_filt = filtfilt(B,A,Triceps_abs); %EMG data is filtered % figure(2); % plot(Triceps,'k');hold on; % plot(Triceps_abs,'b','LineStyle','--');hold on; % plot(Triceps_abs_filt,'r','LineWidth',3); % legend('Measured','Absolute','Filtered Absolute'); %% Schritte ausschneiden Number_of_Steps=7;%length(Start_End)/2; %number of steps should be defined for i=1:Number_of_Steps-1 data=Triceps_abs_filt(Start_End(i*2-1):Start_End(i*2+1)); %data is used from one starting point to the next starting point - whole gait cycle Triceps_100(:,i) = interp1(1 : length(data) , data , linspace(1, length(data),100)); %interp1(original structure, values , new structure ) end %SPEZIELLE DATENKORREKTUR if Proband == 1 && Kinesio == 1 Triceps_100(63:68,2)=Triceps_100(63,2); end; Mean_Triceps_100=mean(Triceps_100,2); Max_Mean_Triceps_100=max(Mean_Triceps_100); ALL_Triceps(Kinesio,Proband)=Max_Mean_Triceps_100; if Kinesio == 1 ALL_oK_Mean_Triceps_100(:,Proband)=Mean_Triceps_100; end; if Kinesio == 2 ALL_mK_Mean_Triceps_100(:,Proband)=Mean_Triceps_100; end; %****************************************** end; end; ALL_Faktor_Biceps=100./ALL_Biceps; for i=1:5 ALL_oK_Mean_Biceps_100_norm(:,i)=ALL_oK_Mean_Biceps_100(:,i).*ALL_Faktor_Biceps(1,i); end; for i=1:5 ALL_mK_Mean_Biceps_100_norm(:,i)=ALL_mK_Mean_Biceps_100(:,i).*ALL_Faktor_Biceps(2,i); end; ALL_Mean_oK_Mean_Biceps_100_norm=mean(ALL_oK_Mean_Biceps_100_norm,2); ALL_Mean_mK_Mean_Biceps_100_norm=mean(ALL_mK_Mean_Biceps_100_norm,2); ALL_Faktor_Triceps=100./ALL_Triceps; for i=1:5 ALL_oK_Mean_Triceps_100_norm(:,i)=ALL_oK_Mean_Triceps_100(:,i).*ALL_Faktor_Triceps(1,i); end; for i=1:5 ALL_mK_Mean_Triceps_100_norm(:,i)=ALL_mK_Mean_Triceps_100(:,i).*ALL_Faktor_Triceps(2,i); end; ALL_Mean_oK_Mean_Triceps_100_norm=mean(ALL_oK_Mean_Triceps_100_norm,2); ALL_Mean_mK_Mean_Triceps_100_norm=mean(ALL_mK_Mean_Triceps_100_norm,2); %Nachbearbeitung Messdaten Prozent_Biceps=100-(100./ALL_Biceps(1,:).*ALL_Biceps(2,:)); Mean_Prozent_Biceps=mean(Prozent_Biceps,2); Std_Prozent_Biceps=std(Prozent_Biceps); %Nachbearbeitung Messdaten Prozent_Triceps=100-(100./ALL_Triceps(1,:).*ALL_Triceps(2,:)); Mean_Prozent_Triceps=mean(Prozent_Triceps,2); Std_Prozent_Triceps=std(Prozent_Triceps); save('Save.mat'); % figure(1); % plot(ALL_mK_Mean_Biceps_100(:,1),'r');hold on; % plot(ALL_oK_Mean_Biceps_100(:,1),'k');hold on; % % figure(2); % plot(ALL_mK_Mean_Triceps_100(:,1),'r');hold on; % plot(ALL_oK_Mean_Triceps_100(:,1),'k');hold on;