How to design a filter that removes multiple types of noise?

12 views (last 30 days)
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!

Accepted Answer

Star Strider
Star Strider on 19 Jun 2020
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:
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 Comments
Spectro
Spectro on 19 Jun 2020
Thank you very much for the quick help and beautiful explanation. Previously, I mainly experimented with the solution from this post: How can i filter ECG signals with high motion artifact ? .
I'm used to an already filtered signals so I’m new to designing and working with filters. If you also have any tips on good sources or literature on this topic, I would be grateful.
Star Strider
Star Strider on 20 Jun 2020
My pleasure!
For resources on biomedical signal processing, search PubMed.
Since I was unable to solve your problem (although I thought I did), I will delete my Answer since it was not Accepted.

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!