![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/319306/image.png)
How to design a filter that removes multiple types of noise?
5 ビュー (過去 30 日間)
古いコメントを表示
Hi there,
I recently came across an ecg signal that I can't handle at all. My main goal is to get only R peaks from it so that I can continue to work with HRV and calculate other parameters, but I don't know how to filter this signal (attached). It occurs to me that there is both motion artifact and muscle noise and more but I don't know at all how to approach.
I also add my filtered result to the attachment, but I don't think it's quite good because the detected r peaks and the calculated hrv look unrealistic and it still contains some solid noise and artifacts. I also don't know if it is good to filter the ecg signal several times in a row.
Thank you for any advice!
0 件のコメント
採用された回答
Star Strider
2020 年 6 月 19 日
It would be more helpful to have your code rather than the result of your filtering efforts (that I did not download).
My approach:
T = load('timeVec.mat');
t = [0; T.t.'];
D = load('ecg.mat');
EKG = D.data;
EKGsgf = sgolayfilt(EKG, 3, 71);
EKGblc = EKG-EKGsgf;
figure
plot(t, EKG)
hold on
plot(t, EKG-EKGsgf, '-r')
hold off
grid
xlim([0 10]+135)
legend('Original','Corrected')
% L = numel(t);
% Fs = 1/mean(diff(t));
% Fn = Fs/2; % Nyquist Frequency
% FTEKG = fft(EKGblc)/L;
% Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
% Iv = 1:numel(Fv); % Index Vector
%
% figure
% plot(Fv, abs(FTEKG(Iv))*2)
% grid
producing this example:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/319306/image.png)
I used sgolayfilt to approximate the signal (with its considerable irregularities), since it’s much more adaptive than frequency-selective filters are, then subtracted the sgolayfilt output from the EKG signal. The result looks reasonably good to me. Experiment with the frame length (71 in my posted code, the frame lenghts must be odd) to get different results that may be better for your analysis.
One problem is that the motion artifact comes close to saturating the recorder, so that the complexes in those regions completely disappear. There’s likely nothing that can be done to recover them.
I include the fft code. It demonstrates the there is broadband noise that is impossible to eliminate with a frequency-selective filter. It would be necessary to experiment with wavelet denoising to see if that would improve the result.
Note that it’s only possible to do HRV analysis with QRS complexes that are each preceded by a normal P-wave. The problem with this signal is that I can’t see all of the P-waves, even after correction.
.
2 件のコメント
Star Strider
2020 年 6 月 20 日
My pleasure!
Since I was unable to solve your problem (although I thought I did), I will delete my Answer since it was not Accepted.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Single-Rate Filters についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!