**2. Wavelet transform**

Wavelet transforms at different scales describe the time characteristics of a signal in different frequency bands, but the analysis is restricted to scales that are powers of two [19]. The use of *B*-splines as base functions permits the evaluation of the CWT in any integer scale [20], which enables to use a wider range of scales and to reduce noise and artifacts more efficiently. This feature can allow the direct application of the algorithm over the raw ECG signal without any preprocessing stage because frequency filtering is performed when the CWT is computed.

The CWT of a time-continuous signal *x*(*t*) is defined as:

$$\text{CWT}\{\mathbf{x}(\mathbf{t});\mathbf{a},\mathbf{b}\} = \frac{1}{\sqrt{\mathbf{a}}} \int\_{\mathbf{s}} \mathbf{x}(\mathbf{t}) \,\psi^\*(\frac{\mathbf{t}-\mathbf{b}}{\mathbf{a}}) \,\text{d}\mathbf{t} \tag{1}$$

where *ψ*<sup>∗</sup>(*t*) is the complex conjugate of the analyzing wavelet function *ψ*(*t*), and *a* and *b* are the scale and translation parameters, respectively. The function *ψ*(*t*) compresses or dilates depending on *a*, which enables the CWT to extract the low- and high-frequency components of *x*(*t*). To implement the CWT, *a* and *b* are usually discretized. If *a* is discretized over a sequence 2*j* (*j* = 1, 2, …), the analysis is restricted to scales that are powers of two, and the result is the dyadic wavelet transform that can be computed with Mallat's algorithm [19].

In this chapter, *B*-splines have been used which allow the evaluation of the CWT in any integer scale [20]. In this formulation, the input signal *x*(*t*) and the analyzing wavelet *ψ*(*t*) are both polynomial splines of degree *n*<sup>1</sup> and *n*<sup>2</sup> , respectively. The splines considered are constructed from polynomial segments of degree *n* of unit length that are smoothly connected together at joining points called knots in such a way that guarantees the continuity of the function and its derivatives up to order (*n*−1) [21]

Assuming that the input signal *x*(*t*) is characterized in terms of its *B*-spline expansion of degree *n*1 and the sequence of *B*-spline coefficients *c*(*k*)

$$\mathbf{x}(\mathbf{t}) = \sum\_{\mathbf{k} \neq \mathbf{Z}} \mathbf{c}(\mathbf{k}) \, \boldsymbol{\beta}^{n} \cdot (\mathbf{t} - \mathbf{k}) \tag{2}$$

Likewise, the wavelet *ψ*(*t*) is a spline of degree *n*<sup>2</sup> with its *B*-spline expansion

$$
\psi(t) = \sum\_{k \in \mathbb{Z}} p(k) \,\beta^{\mu}(t - k) \tag{3}
$$

*B*-splines satisfy a two-scale equation for any integer *m*, where *m* is not restricted to a power of two; thus, the wavelet expanded by a factor *m* can be expressed as:

 *ψ*(*<sup>t</sup>* ⁄*m*) = ∑*<sup>k</sup>*∈*<sup>Z</sup>*([*p*]↑*<sup>m</sup>* ∗ *um n*2 )(*k*) *β<sup>n</sup>*2(*t* − *k*) (4)

where the sequence *um <sup>n</sup>*2(*k*), when *n*<sup>2</sup> and *m* are not both even, is given by *z* transform,

$$u\_{n}^{\mu}(\mathbf{z}) = \frac{\mathbf{z}^{\mu\_{i}}}{m^{n}} \left(\sum\_{k=0}^{m-1} \mathbf{z}^{-k}\right)^{n\_{1}+1} \tag{5}$$

with

generation of malignant ventricular arrhythmias, the interlead variation of QT interval duration was proposed as an index of arrhythmia susceptibility [10]. This measure was termed QT dispersion (QTd), and it was defined as the difference between the maximum and minimum

Increased QTd has been associated with an increased risk for ventricular arrhythmias and sudden death in the general population and in various clinical conditions, among them, CKD is common. Several studies have reported that QTd increased in patients with ESRD, particularly after the end of HD [6, 12], so that it may be useful to identify patients at high risk for overall and cardiovascular mortality [13]. However, this index is affected by: an inaccurate measurement of the QT interval because of different definitions for the T wave end (with and without fusion with U or P waves), influence of HR, no simultaneous ECG leads recordings

As beat-by-beat manual measurement of QTd on three orthogonal ECG leads is impractical in routine clinical practice, the development of accurate and robust methods for automatic detection of characteristic points of QRS and T waves is important in electrocardiographic diagnosis, in particular for the analysis of long recordings [15]. Wavelet transform is a suitable tool that has been used to determine peaks and limits of ECG waves because of its ability to detect transients and of its robustness in front of noise and artifacts [16–18]. This chapter presents the development of an algorithm based on the continuous wavelet transform (CWT) with splines for the automatic measurement of QTd in the quasi-orthogonal leads DI, aVF and V2, and its application for the analysis of QTd

Wavelet transforms at different scales describe the time characteristics of a signal in different frequency bands, but the analysis is restricted to scales that are powers of two [19]. The use of *B*-splines as base functions permits the evaluation of the CWT in any integer scale [20], which enables to use a wider range of scales and to reduce noise and artifacts more efficiently. This feature can allow the direct application of the algorithm over the raw ECG signal without any preprocessing stage because frequency filtering is performed when the

> √ \_\_ <sup>a</sup> ∫ −∞ ∞ x(t) ψ<sup>∗</sup>

where *ψ*<sup>∗</sup>(*t*) is the complex conjugate of the analyzing wavelet function *ψ*(*t*), and *a* and *b* are the scale and translation parameters, respectively. The function *ψ*(*t*) compresses or dilates depending on *a*, which enables the CWT to extract the low- and high-frequency components of *x*(*t*). To implement the CWT, *a* and *b* are usually discretized. If *a* is discretized over a sequence

(*j* = 1, 2, …), the analysis is restricted to scales that are powers of two, and the result is the

dyadic wavelet transform that can be computed with Mallat's algorithm [19].

(\_\_\_ <sup>t</sup> <sup>−</sup> <sup>b</sup>

<sup>a</sup> )dt (1)

QT interval on the standard 12-lead ECG [11].

26 Topics in Splines and Applications

in patients with CKD.

**2. Wavelet transform**

CWT is computed.

2*j*

The CWT of a time-continuous signal *x*(*t*) is defined as:

CWT{x(t); a, b} <sup>=</sup> \_\_1

and number of ECG leads and of the ECG lead system used [14].

$$k\_{\mathbf{u}} = (n\_{\mathbf{u}} + 1)(m - 1)/2\tag{6}$$

Therefore, the resulting CWT at scale *m* evaluated at integer time samples is a polynomial spline function given by:

$$\text{CWT} \{ \mathbf{x}(t), m, k \} = \{ \left( \left[ p \right] \uparrow\_{m} \* \mu\_{\stackrel{\circ}{m}}^{\*} \* b^{\imath\_{i} \* \imath\_{i} + 1} \* c \right) \} \tag{7}$$

where the notation ([*p*] <sup>↑</sup>*<sup>m</sup>* <sup>∗</sup> *um n*2 )represents the upsampling of the sequence *p* by a factor of *m*, the filter *um n*2 is equivalent to a cascade of (*n*<sup>2</sup> <sup>+</sup> 1) filters of moving average of order (*<sup>m</sup>* <sup>−</sup> 1) with an offset *k* 0 that ensures its symmetry, *b<sup>n</sup>*<sup>1</sup> +*n*2 +1 is the *B*-spline representation of a spline of order *n*<sup>1</sup> <sup>+</sup> *<sup>n</sup>*<sup>2</sup> <sup>+</sup> <sup>1</sup> and *<sup>c</sup>* (*k*)′ *s* are the *B*-spline coefficients.

The program *<sup>w</sup>* <sup>=</sup> *spwav* (*x*, *<sup>m</sup>*, *<sup>p</sup>*, *<sup>n</sup>*<sup>2</sup> , *<sup>n</sup>*1) developed by Arregui (written in MATLAB®, The MathWorks Inc.) [22] calculates the CWT of the discrete signal *x*(*t*) at the integer scale *m* of the cubic spline wavelet (*<sup>n</sup>* <sup>2</sup> <sup>=</sup> <sup>3</sup>) with expansion coefficients spline *<sup>p</sup>*, where *x*(*t*) is considered a spline of order *<sup>n</sup>*<sup>1</sup> <sup>=</sup> 1. Implementation of the program *spwav* is based on the fast algorithm proposed by Unser et al. [20], which is done in the following three steps:

**1.** Initialization: calculus of the *B*-spline coefficients *c*(*k*) that interpolate the signal *x*(*t*) and the convolution with the *B*-spline of order *n*<sup>2</sup> .

yields a minimum and the falling slope yields a maximum [16]. According to the spectrum of the ECG waves [29], most of the energy of the ECG signal lies within the scales 2–10 (**Figure 3**). P and T waves have their major component at scales 8 and 10, but higher scales can be affected

An Algorithm Based on the Continuous Wavelet Transform with Splines for the Automatic…

http://dx.doi.org/10.5772/intechopen.74864

29

**Figure 3.** Amplitude-frequency responses of equivalent filters at five scales for 500 Hz sampling rate.

**Table 1.** Frequency response of equivalent filters at five scales for 500 Hz sampling rate.

250 Hz 1000 Hz

w1 1 29–95 2 59–194 w2 2 16–49 5 25–79 w3 5 7–20 8 16–49 w4 10 4–11 20 7–20

**Scale −3 dB bandwidth (Hz) Scale −3 dB bandwidth (Hz)**

**Table 2.** Frequency response of equivalent filters at four scales for sampling rates of 250 and 1000 Hz.

**Scale (e) – 3 dB bandwidth (Hz)**

1 56–186 2 30–97 3 19–64 8 7–24 10 6–19

**Name Sampling frequency**


The selected wavelet function *ψ*(*t*) is the first derivative of a fourth-order cubic *B*-spline expanded by two, which leads to the sequence *p* = (−1, −4, −5, 0, 5, 4, 1) given in Table 1 of [20]. This wavelet is similar to the first derivative of a Gaussian function so that it yields good time and frequency resolution (**Figure 2**).

The Fourier transform of the wavelet at five scales (e = 1, 2, 3, 8 and 10) at a sampling frequency of 500 Hz is shown in **Figure 3**, and their −3 db bandwidths are listed in **Table 1**.

In **Table 2**, the −3 dB bandwidths of the Fourier transform of the wavelet at four scales for the sampling rates of 250–1000 Hz are listed, which correspond to three ECG databases used in this study. MIT-BIH Arrhythmia database (MITDB) [23], QT database (QTDB) [24] and CSE multilead measurement database (CSEDB) [25] used for the validation of the algorithm have sampling rates of 360, 250 and 500 Hz, respectively. The PTB Diagnostic ECG Database (PTBDB) [26, 27] and the E-HOL-12-0051-016 database of the Telemetric and Holter ECG Warehouse of the University of Rochester (THEWDB) [28] used for the application have a sampling rate of 1000 Hz.

**Figure 4** shows the relation between the characteristic points of ECG and its CWT at four scales. Because of the form of the wavelet function selected, each distinct wave of the ECG corresponds to a pair of local maxima of the modulus (Pmm) of the CTW at each different scale with a zero crossing between them that corresponds to its peak. The rising slope of each wave

**Figure 2.** First derivate of a fourth-order B-spline expanded by a factor of two.

yields a minimum and the falling slope yields a maximum [16]. According to the spectrum of the ECG waves [29], most of the energy of the ECG signal lies within the scales 2–10 (**Figure 3**). P and T waves have their major component at scales 8 and 10, but higher scales can be affected

**1.** Initialization: calculus of the *B*-spline coefficients *c*(*k*) that interpolate the signal *x*(*t*) and the

**2.** Iterated moving sum: calculus of the scalar products of the signal *x*(*t*) with the *B*-splines of

**3.** Zero-padded filter: filtering with the expansion coefficients, spline of the basis wavelet *p*

The selected wavelet function *ψ*(*t*) is the first derivative of a fourth-order cubic *B*-spline expanded by two, which leads to the sequence *p* = (−1, −4, −5, 0, 5, 4, 1) given in Table 1 of [20]. This wavelet is similar to the first derivative of a Gaussian function so that it yields good time

The Fourier transform of the wavelet at five scales (e = 1, 2, 3, 8 and 10) at a sampling frequency of 500 Hz is shown in **Figure 3**, and their −3 db bandwidths are listed in **Table 1**.

In **Table 2**, the −3 dB bandwidths of the Fourier transform of the wavelet at four scales for the sampling rates of 250–1000 Hz are listed, which correspond to three ECG databases used in this study. MIT-BIH Arrhythmia database (MITDB) [23], QT database (QTDB) [24] and CSE multilead measurement database (CSEDB) [25] used for the validation of the algorithm have sampling rates of 360, 250 and 500 Hz, respectively. The PTB Diagnostic ECG Database (PTBDB) [26, 27] and the E-HOL-12-0051-016 database of the Telemetric and Holter ECG Warehouse of the University of Rochester (THEWDB) [28] used for the application have a

**Figure 4** shows the relation between the characteristic points of ECG and its CWT at four scales. Because of the form of the wavelet function selected, each distinct wave of the ECG corresponds to a pair of local maxima of the modulus (Pmm) of the CTW at each different scale with a zero crossing between them that corresponds to its peak. The rising slope of each wave

.

convolution with the *B*-spline of order *n*<sup>2</sup>

28 Topics in Splines and Applications

and frequency resolution (**Figure 2**).

sampling rate of 1000 Hz.

order *n*<sup>2</sup> dilated by a factor *m* and divided by the root of *m*.

**Figure 2.** First derivate of a fourth-order B-spline expanded by a factor of two.

upsampling (with zeros) by a factor of *m* to obtain wavelet coefficients.

**Figure 3.** Amplitude-frequency responses of equivalent filters at five scales for 500 Hz sampling rate.


**Table 1.** Frequency response of equivalent filters at five scales for 500 Hz sampling rate.


**Table 2.** Frequency response of equivalent filters at four scales for sampling rates of 250 and 1000 Hz.

**Figure 4.** ECG and its CWT at scales 2, 3, 8 and 10.

by baseline wandering. If the ECG is contaminated with high-frequency noise, scales 2 and 3 are the most affected.
