我目前正在处理在不同情况下在二头肌卷曲运动中获得的肌电信号。在我的代码末尾,我替换了每种情况的规范化信号,这是时间的函数。我的问题是,在这个叠加峰喷出的时间从一条曲线移到另一条曲线,因为参与者没有同时开始它的练习,我想“重新校准”(我不确定这是这个镜头的正确词)曲线在每一次收缩开始和结束的同时(在蓝色曲线上有一个更多的收缩结束)。
这就是我的代码现在的样子
%% Process EMG dynamique
clc, clear all, close all
%% Haltère 10 Kg
%% Filtrage, centrage et rectication du signal
data_EMG = load([''10kg_haltere-Philippe.txt'']); % Load file EMG
fe_EMG = 1000; % sampling frequency Acceleration Hz
timeEMG_10 = (0:1/fe_EMG:(length(data_EMG)-1)*(1/fe_EMG))'; % Time vector
for m = 1 : 2
[B,A] = butter(8/2,[15*1.247 400*1.247]/(fe_EMG/2),'bandpass'); % filter butterworth band pass 20 à 400 Hz d'ordre 4
data_EMG_filt = filtfilt(B,A,data_EMG(:,m)); % filtring pass band
data_EMG_filt_1 = data_EMG_filt - ones(length(data_EMG_filt),1)*mean(data_EMG_filt); %Centering of the EMG signal around the individual mean of each muscle
data_EMG_filt_rectified = abs(data_EMG_filt_1); % Rectification of the EMG signal = Full wave rectification
%% courbe RMS/EMG
rms_window = 1300;
for i = (rms_window/2)+1 : length(data_EMG)-(rms_window/2)
rms_data_EMG(i) = rms(data_EMG_filt_rectified([i-(rms_window/2):i+(rms_window/2)]));
end
[B,A] = butter(4/2,[5*1.247]/(fe_EMG/2),'low'); % filter butterworth band pass 20 à 400 Hz d'ordre 4
data_EMG_filt_rectified_filtbutter = filtfilt(B,A,data_EMG_filt_rectified); % filtring pass band
EMG_max = max(data_EMG_filt_rectified_filtbutter);
data_EMG_filt_rectified_filtbutter_norm_10 = (data_EMG_filt_rectified_filtbutter.*100)./EMG_max;
% Stockage
RMS(:,m) = rms_data_EMG;
EMG_filt(:,m) = data_EMG_filt_rectified;
EMG_filtbutter(:,m) = data_EMG_filt_rectified_filtbutter;
EMG_filtbutter_norm(:,m) = data_EMG_filt_rectified_filtbutter_norm_10;
end
%% Haltère 5 kg
%% Filtrage, centrage et rectication du signal
data_EMG = load(['5kg_haltere-Philippe.txt']); % Load file EMG
fe_EMG = 1000; % sampling frequency Acceleration Hz
timeEMG_5 = (0:1/fe_EMG:(length(data_EMG)-1)*(1/fe_EMG))'; % Time vector
for m = 1 : 2
[B,A] = butter(4/2,[15*1.247 400*1.247]/(fe_EMG/2),'bandpass'); % filter butterworth band pass 20 à 400 Hz d'ordre 4
data_EMG_filt = filtfilt(B,A,data_EMG(:,m)); % filtring pass band
data_EMG_filt_1 = data_EMG_filt - ones(length(data_EMG_filt),1)*mean(data_EMG_filt); %Centering of the EMG signal around the individual mean of each muscle
data_EMG_filt_rectified = abs(data_EMG_filt_1); % Rectification of the EMG signal = Full wave rectification
%% courbe RMS/EMG
rms_window = 1300;
for i = (rms_window/2)+1 : length(data_EMG)-(rms_window/2)
rms_data_EMG(i) = rms(data_EMG_filt_rectified([i-(rms_window/2):i+(rms_window/2)]));
end
% Application d'un deuxième filtre (pour analyser les bouffé EMG) à la place de lp filter
[B,A] = butter(8/2,[5*1.247]/(fe_EMG/2),'low');
data_EMG_filt_rectified_filtbutter = filtfilt(B,A,data_EMG_filt_rectified);
EMG_max = max(data_EMG_filt_rectified_filtbutter);
data_EMG_filt_rectified_filtbutter_norm_5 = (data_EMG_filt_rectified_filtbutter.*100)./EMG_max;
% Stockage
RMS(:,m) = rms_data_EMG;
EMG_filt(:,m) = data_EMG_filt_rectified;
EMG_filtbutter(:,m) = data_EMG_filt_rectified_filtbutter;
EMG_filtbutter_norm_5(:,m) = data_EMG_filt_rectified_filtbutter_norm_5;
end
figure
plot(timeEMG_10,EMG_filtbutter_norm(:,1))
hold on
plot(timeEMG_5,data_EMG_filt_rectified_filtbutter_norm_5)
hold off
发布于 2018-02-06 19:11:31
我为类似的事情设计了我自己的功能。我相信,也许有更好的方法来做到这一点,然而,它大部分时间起作用。基本思想是每次移动一行1(限制为+/-范围),并在2之间检查RMSE。记录最低的RMSE发生的位置,这是您应该移动的距离。
时间对齐函数:
function [time2] = dataSync(data1, data2, time2, maxShift)
minError = inf;
shiftPoint = NaN;
for ii = -maxShift:maxShift
if ii <= 0 %Shift data 2 to the left
RMSE = sqrt(mean((data1(1:end+ii) - data2(1-ii:end)).^2));
else %Shift data 2 to the right (...or data 1 left)
RMSE = sqrt(mean((data1(1+ii:end) - data2(1:end-ii)).^2));
end
if RMSE < minError
minError = RMSE;
shiftPoint = ii;
end
end
if shiftPoint ~= 0
time2 = time2 + time2(abs(shiftPoint))*sign(shiftPoint);
end
将其放入您的代码:注意,我将转换限制为+/- 5000示例。
figure
plot(timeEMG_10,EMG_filtbutter_norm(:,1))
hold on
%% Try to line up the times.
[timeSync] = dataSync(EMG_filtbutter_norm(:,1), data_EMG_filt_rectified_filtbutter_norm_5, timeEMG_5, 5000);
% plot(timeEMG_5,data_EMG_filt_rectified_filtbutter_norm_5)
% hold off
plot(timeSync,data_EMG_filt_rectified_filtbutter_norm_5,'g')
hold off
给出了一个曾经是的排列起来的地块:
现在是:
请注意,您没有相同数量的峰值,但这可能是您所能做的最好的。此外,假设两个数据数组具有相同的元素数、相同的原始时间向量等,这可能并不总是正确的。
https://stackoverflow.com/questions/48648890
复制相似问题