How to use wavelet filters for peak finding ECG data

12 views (last 30 days)
I have a 170 datasets of ECG data that im looking to process for RR peaks and average Waveform shaping. Each dataset is approximatley 2 minutes long, and it all is very noisy and varied. I am interested in finding the peaks but using "findpeaks()" alone is proving insufficient since there are significant noise artificats and human subject variability. I've heard others have used wavelet filters, but im a little stuck with how to use them. Is there an ECG example I can follow to learn which functions are useful for this type of denoising?
As an example when I plot a specific case I see several siginifant large amplitude noise artifacts. The usable ECG data is between ~70 to 75 sec and from 90 seconds to about 120 seconds. Several good peaks have been missed, and several noise peaks have been incorrectly labeled. Furthermore the findpeaks function requires hard coded .6 and .3 values that I wouldnt know apriori. My hope is that wavelet filtering can reduce the number of false positive and false negatives.
Any advice would be appreciated.
ss = 6; ee = 10;
t = dataset{ss,ee}(:,1); %Time Vector
v = dataset{ss,ee}(:,2); %Voltage Vector
[rpk,tpk] = findpeaks(v,t,'MinPeakDistance',.6,'MinPeakHeight',.3);
plot(t,v)
hold on; grid on;
xlabel('Time (sec)');
ylabel('Amplitude (mV)');

Accepted Answer

Star Strider
Star Strider on 2 Jun 2022
There are several options depending on what the noise is. The best way to determine that is to take the Fourier transform of the signal using fft or pspectrum. If the noise is band-limited, use a lowpass filter to remove it (choosing 'ImpulseResponse','iir' for best results). If it is broadband, either use wavelet denoising or the sgolayfilt function (I usually choose a 3-degree polynomial and then adjust the framelen value to get the result I want).
  6 Comments
Peter Brehm
Peter Brehm on 6 Jun 2022
haha, please dont, I accepted the answer! I havent submitted many matlab questions, so i just forgot accept!
Star Strider
Star Strider on 6 Jun 2022
Thank you!
I usually delete my answers if they don’t solve the problem (or if they aren’t accepted), so I am pleased that this one appears to have helped.
Wavelets can be good at denoising, however they are not always successful in my experience, and for that reason I usually do either frequuency-based filtering or use sgolayfilt for broadband noise.
There are many wavelet families that would be worth experimenting with. For a discrete signal, Haar wavelets could be worth trying as well. See Discrete Multiresolution Analysis for a relevant discussion.
Another option might be independent component analysis using the rica function or relevant File Exchange contributions. I have used ICA for EKG analysis, however I do not have any recent experience with it.

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!