I need to locate R-peaks in an ECG signal. I'm using wavelets to extract QRS complexes:
First, I decompose the signal using a maximal overlap discrete wavelet transform with the Symlet 4 wavelet. This wavelet resembles the QRS complexes I want to detect. I then copy scales 4 and 5, because this band maximizes QRS energy. The wavelet coefficients on scales 1-3, and the level 5 approximation coefficients are set to zero. Then I perform an inverse wavelet transform on these modified coefficients. The result is a signal in the time domain that contains mostly QRS complexes, and has very high amplitude at the R-peaks.
I just use a peak detector on this signal to locate the R-peaks.
Everything is well-explained here: https://mathworks.com/help/wavelet/ug/r-wave-detection-in-the-ecg.html
This is the code I use:
wt = modwt(rawECGsignal_buffer,5);
wtrec = zeros(size(wt));
wtrec(4:5,:) = wt(4:5,:);
filtered = imodwt(wtrec,'sym4');
From what I understand, the Symlet 4 is a biorthogonal wavelet, which means that the decomposition and reconstruction can be implemented as a bank of high- and low-pass FIR filters.
Right now, I read the live ECG data into a 5 second buffer, and then perform the wavelet filter on the buffer (as described above). This seems rather inefficient, because I have to filter the entire buffer again when new data comes in.
Is it possible to implement this in a way that allows for real-time filtering of an ECG signal without buffering?
(I.e. single value in → wavelet 'filter' → single filtered/reconstructed value out)