# A Novel Wavelet-Based Algorithm for Detection of QRS Complex
## 3 Methodology
### Four-Level Dyadic Wavelet Transform  
The dyadic wavelet transform was applied in this study to decompose ECG signals into different frequency bands for detection of QRS peaks. The dyadic wavelet transform for a continuous signal \(x(t)\) is defined as follows:  
\[Wx(u,2^{j})=\int_{-\infty}^{+\infty}x(t)\frac{1}{\sqrt{2^{j}}}\psi(\frac{t-u}{ 2^{j}})dt \tag{1}\]  
Figure 3: Illustration of removing the low-frequency baseline drift.  
Figure 2: Illustration of segmentation of the electrocardiogram (ECG) recording.  
where \(u\) and \(2^{j}\) denote the translation and dyadic scaling parameters, respectively. The selected prototype wavelet \(\psi(t)\) is a biorthogonal spline which has been applied to ECG signals in a previous study [14]. Biorthogonal wavelets built with splines are especially attractive because of their short support and regularity [23]. The corresponding low-pass filter \(H(z)\) and high-pass filter \(G(z)\) of the biorthogonal spline wavelet are given as follows [14]:  
\[H(z)=(1+3z^{-1}+3z^{-2}+z^{-3})/4 \tag{2}\]  
\[G(z)=(-1-3z^{-1}+3z^{-2}+z^{-3})/4 \tag{3}\]  
which have the following impulse responses:  
\[h(n)=\frac{1}{4}+\frac{3}{4}\delta(n-1)+\frac{3}{4}\delta(n-2)+\frac{1}{4} \delta(n-3) \tag{4}\]  
\[g(n)=\frac{-1}{4}+\frac{-3}{4}\delta(n-1)+\frac{3}{4}\delta(n-2)+\frac{1}{4} \delta(n-3) \tag{5}\]  
The four-level dyadic wavelet transform in this study was implemented by the Mallat algorithm [24], as shown in Figure 4, which uses a two-channel filter bank to decompose ECG signals by the low-pass filter \(H(z)\) and high-pass filter \(G(z)\). a1, a2, a3, and a4 denote the low-frequency approximation signals of the first, second, third, and fourth levels, respectively, and d1, d2, d3, and d4 are the high-frequency detail signals of different levels. Figure 5 demonstrates several common QRS waves and their high-frequency detail signals d1, d2, d3, and d4, where N, V, L, and Q denote normal beat, ventricular premature contraction beat (VPC), left bundle branch block beat, and unclassifiable beat, respectively. Figure 6 further plots the extreme detail signals, including only the extreme values of the wavelet detail signals, named d1', d2', d3', and d4' according to d1, d2, d3, and d4 in Figure 5, respectively. It can be observed that the rising and falling segments of a QRS peak produce a negative and a positive extreme point, respectively, indicated by arrows. The pair of a negative and a positive extreme point is defined as an extremum pair in the study. The sharper the QRS peak, the larger the extreme value produced. Hence, we can detect the QRS peak by finding the largest extremum pair in the wavelet detail signals. The frequency ranges of the wavelet detail signals for d1, d2, d3, and d4 are from 90 Hz to 180 Hz, from 45 Hz to 90 Hz, from 22.5 Hz to 45 Hz, and from 11.25 Hz to 22.5 Hz, respectively. Usually, the frequency range of the QRS complex wave is from 10 to 45 Hz [14]. Hence, the detection of QRS peaks in this study is mainly based on the extreme detail signals of the third or fourth level, d3' or d4', according to the evaluation of noise amount. The d2' helps in identifying P- or T-peaks.  
Figure 4: A four-level dyadic wavelet transform of ECG signals using a two-channel filter bank.