Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

1 Introduction

Electrocardiogram (ECG or EKG) signals are due to ionic current flows which cause the cardiac fibers to contract and relax, subsequently generating a time variant periodic signal. The ECG is a diagnostic tool that measures and records the electrical activity of the heart in great detail. Interpretation of these details allows diagnosis of a wide range of heart conditions which can vary from minor to life threatening. The term electrocardiogram was introduced by the Dutch physiologist, Willem Einthoven, in the 1890s and early 1900s. In 1924, Einthoven received the Nobel Prize for his life’s work in developing the ECG [6]. By the 1950s, developments in ECG technology allowed medical professionals to observe electrical stimulated heart signals by placing electrodes in and around the heart muscle. More recently, the study of ECG signals in medical applications has become one of the fastest growing research topics. Proficiency in the interpretation of the ECGs is an essential skill for medical professionals. A single normal cycle of the ECG represents successive arterial depolarization and repolarization as well as ventricular depolarization and repolarization, which are due to cardiac contractions that occur with every heartbeat. These are approximated by the peaks and troughs of the ECG waveform. It consists of well-defined, successive waves denoted P, Q, R, S, and T waves (see Fig. 10.4). Much attention has been paid to the adequate and accurate analysis of the ECG signal that would lead to correct diagnoses of cardiac anomalies. However, the picked-up ECG signal is corrupted by several sources of noise. This corrupted noise considerably prevents accurate analysis of the ECG signal and thereby preventing the potential for useful information extraction. Problematically, errors in reading are common, and may lead to serious consequences. In an ECG system, the potential difference between two electrodes placed on the skin surface is considered as an input to the ECG plotter. Statistical data from past research reveals that there is approximately 20–50% discordance between the early ECG interpretation and the final interpretation by a senior cardiologist. The interpreted results from the ECG is evaluated by the doctor for the final diagnosis in deciding how to best administer urgent treatment for the ailing patients with life-threatening cardiovascular diseases. Unstable recording environment, spurious signals from nearby equipment, poor electrodes, and electromagnetic pollution are a few causes of unwanted noise contamination on the ECG signal. Results from laboratory and clinical studies suggest that the existence of abnormal ventricular conduction during sinus rhythm in regions surrounding a myocardial infraction, will generate delayed and fractionated micro potentials on the ECG signals. The morphology of ECG signal has been used for recognizing much variability in heart activity, so the establishment of parameters of an ECG signal clear of noise is of utmost importance. This gives a full picture complete with detailed information about the electrophysiology of the hearts diseases and any ischemic changes that may occur such as myocardial infarction, conduction defects, and arrhythmia. Different attempts have been made to design filtering algorithms aimed to improve the signal-to-noise ratio (SNR) values and recovering the ECG waves in noisy environments. ECG signal is considered as a non-stationary signal. An efficient technique for this nonstationary signal processing is the wavelet transform [14]. The wavelet transform can be used as a decomposition of a signal in the time-frequency scale plane. There are many applications of wavelet transform such as sub-band coding data compression, characteristic points detection, and noise reduction. In order to reduce the noise of ECG signals, many techniques including digital filters finite impulse response (FIR or IIR), adaptive method, and wavelet transform thresholding methods are available [7]. The goal of this chapter is to determine the optimal wavelet, order, level, and threshold for denoising and compressing an ECG while smoothing out and maintaining the integrity of the original signal. The wavelets used were: Daubechies, Biorthogonal Spline, Coiflet, and Symlet. Various thresholds were utilized: soft, hard, global, rigorous SURE, heuristic SURE, universal, and minimax. The SNR in combination with the percentage root mean square difference (PRD) helped determine the optimal conditions for wavelet denoising. Compression scores and L 2 norm recovery values determined the ideal conditions for wavelet compression. This report includes background information about wavelets and thresholding. The two processes and their results will be explained and analyzed.

2 Wavelet Analysis

Wavelets provide time and frequency analysis simultaneously and offer flexibility with many different properties and useful applications. In this section, we give a brief overview on wavelet analysis [3].

2.1 Convolution, Filters, and Filter Banks

Convolution is the process that if an input vector is processed through a filter, the result is an output vector. The output vector can be used for many applications, for example, to reconstruct the input vector. The output vector can be calculated as a series of shifting inner products:

$$\begin{array}{rcl} y& = h {_\ast} x,&\end{array}$$
(10.1)
$$\begin{array}{rcl}{ y}_{n}& = \sum \limits_{k=-\infty }^{\infty }{h}_{k}{x}_{n-k},&\end{array}$$
(10.2)

Where x is input data (signal), y is output data, h is filter, and * is convolution. A wide variety of filters can be used in the above equations. The filters used in this chapter were all FIR filters. An FIR filter is a casual filter with a finite number of elements that are nonzero [15]. FIR filters can further be classified as either high-pass filters or low-pass filters. A low-pass filter annihilates high oscillatory trends, or details, of a signal while maintaining low oscillatory trends, or approximations, of a signal. A high-pass filter maintains high oscillatory trends of a signal while eliminating the locally constant trends. The combination of a high-pass filter and low-pass filter is called a filter bank [13].

2.2 Multiresolution Analysis

Multiresolution analysis is based upon a sequence of approximation spaces (V j ) which must satisfy certain conditions. Let L 2 be the space of square-integrable functions. These conditions are [3]

$$\ldots \subset {V }_{2} \subset {V }_{1} \subset {V }_{0} \subset {V }_{-1} \subset {V }_{-2} \subset \ldots ,$$
(Cond. 1)
$$\overline{{\bigcup}_{j\in Z}{V }_{j}} = {L}^{2}(R),$$
(Cond. 2)
$${\bigcap}_{j\in Z}{V }_{j} = 0$$
(Cond. 3)

Multiresolution is the idea that each subspace (V J ) is a scaled representation of V 0:

$$f \in {V }_{j} \Leftrightarrow f({2}^{j}) \in {V }_{ 0} :$$
(Cond. 4)

The concept that an entire space can be represented using only scaled representations of a single function led to general expansion wavelet systems. In V 1, general expansion wavelet systems use a father function (ϕ(2t − n)) and its scaled and dilated representations to form a basis. The relationship between V 0 and V 1 can be described by the dilation equation [3]:

$$\phi (t) = \sum \limits_{n}^{}h(n)\sqrt{2}\phi (2t - n).$$
(Cond. 5)

2.3 Wavelet Systems

A wavelet system is comprised of a father function ϕ and a mother function ψ. In what follows, we will limit our discussion to discrete wavelet transforms and orthogonal wavelet systems with compact support. Wavelet systems, also called wavelet families, are rather unusual because their properties and conditions are not derived from an equation. Rather, a wavelet system derives its equation from a set of conditions and properties. One of the approaches in the design of a wavelet system is to determine the intended application of the system. The purpose of the system could be data compression, modeling, or denoising of signals. Once the purpose of the system has been determined, desirable conditions are set and the important properties are determined. These important properties can include:

  • Compact Support

  • Type of filter

  • Length of filter

  • Orthogonality

  • Support Width

  • Number of Vanishing Moments for ϕ and ψ

  • Regularity

These conditions and properties lead to a set of equations. These equations are used to determine the dilation equation. The dilation equation is

$$\phi (t) = \sum \limits_{n}^{}h(n)\sqrt{2}\phi (2t - n).$$
(10.3)

The dilation equation uses an FIR, low-pass filter (h(n)). A low-pass filter must be used in conjunction with a high-pass filter in order to have the most accurate representation of a signal. Therefore, a mother function (ψ(t)) must also be derived from the dilation equation [15]. This is done by using the relationship between the low-pass filter (h(n)) and high-pass filter (g(n)) [13]:

$$g(n) = {(-1)}^{n}h(1 - n).$$
(10.4)

This relationship leads to the mother function:

$$\psi (t) = \sum \limits_{n}^{}g(n)\sqrt{2}\phi (2t - n).$$
(10.5)

The dilation equation uses the father function, and the wavelet equation determines the mother function.

2.4 The Four Families

The Daubechies family (DBF) uses a general expansion wavelet system. A general expansion wavelet system is a system that is generated from a single scaling function ϕ(2t − n). This system forms an orthonormal basis with compact support. Daubechies set conditions for the number of zero moments (vanishing moments) for the mother function ψ(t). The desire was to have the maximum number of vanishing moments for ψ(t) in order to have increased smoothness for the mother function [3]:

$$\int dx{x}^{l}\psi (x) = 0,\ \ \ \ \ l = 0,\ldots ,L - 1.$$
(10.6)

A high number of vanishing moments results in more accurate detail coefficients because these coefficients can now be almost zero where a function is smooth. Coiflets based on the following conditions:

$$\int dx{x}^{l}\psi (x) = 0,\ \ \ \ \ l = 0,\ldots ,L - 1.$$
(10.7)

and

$$\int dx{x}^{l}\phi (x) = 0,\ \ \ \ \ l = 1,\ldots ,L - 1.$$
(10.8)

One shortcoming of orthonormal wavelet bases is that the one FIR filter is used for deconstruction and its transpose is used for reconstruction. When this occurs, one wants to recover the signal after it is processed, the exact reconstruction of the original signal and symmetry of the FIR filters are impossible. The Cohen − Daubechies − Feauveau Biorthogonal Spline Family (BSF) was designed to overcome this shortcoming. If one FIR filter is used for deconstruction and a different FIR filter for reconstruction, symmetry of the filters is possible [3]. Therefore, the BSF is defined as follows.

$$ \psi (t) = \sum \sqrt{2}{g}_{n}\phi (2t - n), $$
(10.9)
$$ \tilde{\psi }(t) = \sum \sqrt{2}\tilde{{g}}_{n}\phi (2t - n), $$
(10.10)
$$ \phi (t) = \sum \sqrt{2}{h}_{n}\phi (2t - n), $$
(10.11)
$$ \tilde{\phi }(t) = \sum \sqrt{2}\tilde{{h}}_{n}\phi (2t - n), $$
(10.12)

where ϕ(t) and ψ(t) are the functions used for deconstruction and \(\tilde{\phi (t)}\) and \(\tilde{\psi (t)}\) are used for reconstruction. The order of deconstruction and reconstruction does not have to be the same. The relationship between the fathers’ filter coefficients is

$$ \left (\sum {h}_{n}\right )\left (\sum \tilde{{h}}_{n}\right ) = 2. $$
(10.13)

The relationship between the low-pass and high-pass filters is maintained for reconstruction and deconstruction.

2.5 Key Properties

Table 10.1 shows some key properties of the wavelet families used in this chapter.

Table 10.1 Key properties of four wavelet families

2.6 Discrete Wavelet Transforms

2.6.1 Convolution Approach

Discrete wavelet transforms are defined by using the convolution of the highpass and low-pass filters with a signal to produce approximation coefficients and detail coefficients [15]:

$$\begin{array}{rcl} a& = h \ast x,&\end{array}$$
(10.14)
$$\begin{array}{rcl} d& = g \ast x.&\end{array}$$
(10.15)

where x is input data (signal), h is low-pass filter coefficient, a is approximation coefficient, g is high-pass filter coefficient, and d is detail coefficient. Since the approximation coefficients are obtained using a low-pass filter, which eliminates high oscillatory trends, they form a relatively close approximation of the signal. The combination of the approximation and the details of a signal are what make the signal unique. So, the signal must be convolved with a high-pass filter to obtain those important detail coefficients [13]. An example of the decomposition of a given signal into approximation and details is shown in Fig. 10.1.

Fig. 10.1
figure 1

Decomposition of a signal

2.6.2 Matrix Approach

Discrete wavelet transforms can also be represented as matrices. The wavelet transform matrix, shown below, changes from family to family since the filter coefficients of each family are different.

  • Wavelet transform matrix

    $${W}_{N} = \left [\frac{Lo\_D} {Hi\_D}\right ].$$
    (10.16)

The low-pass decomposition filter (Lo{ _}D) and high- pass decomposition filter (Hi{ _}D) represent the matrices formed by the filter coefficients (h(n),g(n)). These matrices are combined in a block matrix (W N ) and are convolved with a signal to form a matrix (Y ). Y represents the block matrix representation of the approximation and detail coefficients matrices.

  • Deconstruction

    $$Y = {W}_{N} \ast X.$$
    (10.17)

If W N is an orthogonal matrix, then the inverse is equivalent to the transpose of itself [15]. Thus, the reconstruction filters (Lo{ _}R,Hi{ _}R) are the transposed representations of the deconstruction filters:

$${W}_{N}^{-1} = {W}_{ N}^{T} = \left [\frac{Lo\_R} {Hi\_R}\right ].$$
(10.18)

By using the transpose of the filter coefficient matrix, the signal can be reconstructed by the combination of the approximation and detail coefficients.

  • Reconstruction

$$X = {W}_{N}^{T} \ast Y.$$
(10.19)

2.7 Analysis and Synthesis Filter Banks

The figures in this subsection show the process that is used to transform signals using wavelet systems in conjunction with discrete wavelet transform. The symbol in Fig. 10.2, comprised of a downward arrow and the number two, indicates downsampling to the second degree. Downsampling to the second degree is the removal of roughly half the detail and approximation coefficients. Downsampling is performed after a signal is processed through the filters because half the coefficients have become redundant. Downsampling eliminates the redundant coefficients. The symbol in Fig. 10.3, comprised of an upward arrow and the number two, indicates upsampling to the second degree. Upsampling is the inserting of zeros in the place of the coefficients that were removed during downsampling. Subsampling is one of the factors that help wavelets being good for data compression. We usually use the approximation coefficients from the last level of deconstruction, along with all detail coefficients, to reconstruct a signal.

Fig. 10.2
figure 2

Discrete wavelet transform deconstruction method

Fig. 10.3
figure 3

Discrete wavelet transform reconstruction method

3 Electrocardiograms and How They Relate to Wavelets

The heart has cardiac cells that pass electrical impulses through the heart. These impulses regulate the pumping of the chambers (see Fig. 10.4). An electrocardiogram strip shows these electrical impulses as a signal. There are 12 different leads that show various perspectives of the heart. These leads come from different placements of electrodes over the body. An electrocardiogram is used to detect abnormalities in the heart since each part of the signal corresponds to a part of the movement of the impulse through the heart [4]. Different diseases can be diagnosed by looking at the differences in the length, frequency, and amplitude of each part of the wave. These factors depend on the voltage, speed, and path of the impulse through the heart’s electrical system. Since each person is different, all of the previously mentioned things can vary from person to person (see Fig. 10.5) [4]. Electrocardiograms are biomedical signals, and like most of them, ECGs are non-stationary. Among different transform schemes, discrete wavelet transforms have shown promise because of their good localization properties in the time and frequency domain. Discrete wavelet transforms provide better performances than other transforms. Due to the compactness of supports and other properties described in Sect. 10.2.5, the local behavior of the highly nonstationary signals is expected to be well captured by wavelets than any other tools.

Fig. 10.4
figure 4

Heart and ECG signal

Fig. 10.5
figure 5

ECG signals of five different patients

4 Main Results

In the context of data (or signals) approximation by using wavelets, one connects the smoothing or denoising of signals with the measures of smoothness depending on the magnitudes of their wavelet coefficients. Wavelet approximation using thresholding allows an adaptive representation of signal discontinuities. Applying thresholding in wavelet domain to problems of signal processing were used by Donoho [5] and many others. In this chapter, we explored two separate processes. The first process strictly denoised ECG signals using term-by-term thresholding. The second process denoised and compressed ECGs using global thresholding (GBL). The goal of both of these processes was to determine which wavelet and thresholding combination removed the most noise while smoothing out and maintaining the integrity of the signal. The best denoising combination was determined by using the SNR and PRD. An additional goal of the second process was to determine the best wavelet for compressing ECGs. The compression scores and L 2 norm recovery values were used to determine this additional goal. Our project used real ECGs from the PhysioNet PTB Diagnostic ECG Database (http://www.physionet.org/cgi-bin/ATM) [8].

4.1 Process 1

A group of male patients ranging from ages 43–63 were selected. Eight patients were healthy controls, and eight had suffered myocardial infarctions (heart attacks). The following wavelet families were used for both part one and two: Daubechies, Biorthogonal Spline, Coiflet, and Symlet. Part one used soft thresholding in combination with rigorous SURE, heuristic SURE, universal, and minimax thresholding rules. We denoised each patients’ ECG signal varying the wavelet and thresholding. We evaluated each signal up to level 10 and varied the orders of the wavelet families.

4.1.1 Denoising

Signal interference (noise) can mask the true image of a signal. Denoising is performed to remove the unwanted and unnecessary noise. When deconstructing a signal using wavelets, the majority of the noise is isolated in the detail coefficients. The formula,

$${s}_{0}(n) = {s}_{r}(n) + e(n)$$
(10.20)

describes how an observed signal is a pure signal and the noise that interferes with it. To get rid of this noise, three steps are utilized:

  • Denoising via wavelet deconstruction

  • Thresholding

  • Inverse discrete wavelet transform (reconstruction)

The first and third steps are determined solely based on the wavelet family; the middle step is a procedure completely independent from the wavelet family and is the essential part of the denoising procedure [1].

Once a signal has been decomposed into its detail and approximation coefficients, it is now in a state where it can have thresholding imposed upon it. Two kinds of thresholding are used extensively: hard and soft. Hard thresholding is more rigid, whereas soft thresholding is smooth. For wavelet thresholding, there is a thresholding value, λ, which acts as a standard for the values of the detail coefficients. If the values do not meet the standards, that is, they are outside the λ, they are automatically set to zero [15]. Hard thresholding can be expressed as follows:

$$s^\prime(x) = \left \{\begin{array}{@{}l@{\quad }l@{}} {d}_{i,j}\ \ \ \ if\vert {d}_{i,j}\vert > \lambda \quad \\ 0\ \ \ \ \ \ \ if\vert {d}_{i,j}\vert \leq \lambda. \quad \end{array} \right.$$
(10.21)

It should be noted that hard thresholding creates discontinuities at any d i, j equal to or less than the defined λ. These discontinuities create a more jagged signal, which is undesirable when denoising ECGs. A more desirable method to use when denoising ECGs is soft thresholding. Soft thresholding can be described as follows [7]:

$${ d^\prime}_{i,j} = \left \{\begin{array}{@{}l@{\quad }l@{}} {d}_{i,j} - \lambda \ \ \ \ if\ \ {d}_{i,j} > \lambda \quad \\ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \vert {d}_{i,j}\vert \leq \lambda \quad \\ {d}_{i,j} + \lambda \ \ \ \ if\ {d}_{i,j} < -\lambda.\quad \\ \quad \end{array} \right.$$
(10.22)

As with hard thresholding, detail coefficients less than the threshold are scaled to zero. If the other conditions are met, then the corresponding coefficients are shrunk according to λ. Overall, this method creates a smooth signal which is the main reason soft thresholding is utilized in process one.

4.1.2 Term-by-Term Thresholding

To calculate λ, one must use thresholding rules. The rules described in the following methods are level dependent. They calculate a different λ from level to level. The first method is rigorous SURE (RIG), and it uses Stein’s Unbiased Risk Estimator to minimize the error [15]. Universal thresholding (UNI) is another known method which usually uses a higher thresholding value and often results in over smoothing. The universal threshold can be expressed as:

$${\lambda }_{\mathrm{univ}} = \sigma \sqrt{2\mathrm{log } (N)},$$
(10.23)

where σ is the standard deviation of the noise and N is the signal length [1]. Minimax thresholding realizes the minimum of set of functions for the mean squared error. The final method used is heuristic SURE, which is just a combination of universal and SURE [11]. Once the signal has been denoised, it is ready to be reconstructed. Reconstruction is accomplished via inverse discrete wavelet transform, using all detail coefficients and only the last level’s approximation coefficients [2]. The intention of denoising is to have a reconstructed signal which still depicts the important trends of the signal (i.e., accurately keeps the peaks and troughs of an ECG) [1].

4.1.3 Comparison Method 1

The SNR for each reconstructed signal was compared to the original SNR to see how much noise had been removed. The SNR was defined as:

$$\mathrm{SNR} = \frac{\mu } {\sigma }.$$
(10.24)

The mean is represented by μ and the standard deviation by σ. Using the above definition, the UNI rule was found to have removed the most noise. The Daubechies wavelets of orders 9 and 10, level 10 removed the most noise when used in conjunction with UNI; Biorthogonal Spline order 3.1, level 10 removed the least amount of noise. The above definition of SNR was not an appropriate comparison method for ECG denoising. When too much noise is removed, the shape of the ECG is changed. When this occurs, an abnormality may not be able to be detected anymore which defeats the purpose of an ECG. For example, Fig. 10.6 shows a denoised signal that had too much noise removed compared to the original signal. Figure 10.6 shows another denoised signal that maintains the shape of the signal better. In fact, the differences between normal and abnormal ECGs are determined by things such as the length, frequency, and amplitude of each part of the waves.

Fig. 10.6
figure 6

This level of denoising changes the signal shape too much

4.1.4 Comparison Method 2

In order to overcome the problem of removing too much noise and changing the shape of the ECG signal, a different comparison method was used. This second method used a different definition of the SNR in conjunction with the PRD. For every level at every order, an individual PRD and SNR value was computed for the four different thresholding rules.

The signal-to-noise ratio, or SNR, indicates how much noise has been removed. The equation for the SNR is [2]:

$$\begin{array}{rcl} \mathrm{SNR}& :={ \mathrm{log}}_{10}\left (\frac{\sum \limits_{n=0}^{k}{s}_{ r}^{2}(n)} {\sum \limits_{n=0}^{k}{e}^{2}(n)} \right ),&\end{array}$$
(10.25)
$$\begin{array}{rcl} e(n)& = {s}_{0}(n) - {s}_{r}(n)\!,&\end{array}$$
(10.26)
  • s 0: original signal

  • s r : reconstructed signal

  • e(n): noise

The percentage root mean square difference, or PRD, indicates how close the denoised signal is to the original. The equation for the PRD is [2]:

$$\mathrm{PRD} = \sqrt{\frac{\sum \limits_{n=0}^{N}{({s}_{0}(n) - {s}_{r}(n))}^{2}} {\sum \limits_{n=0}^{N}{({s}_{0}(n))}^{2}}} \times 100\,\%.$$
(10.27)

The optimal SNR and PRD need to be reasonably small so that the most noise is removed without distorting the shape of the signal. The denoised signal in Fig. 10.6 has a smaller SNR and bigger PRD than the denoised signal in Fig. 10.7. Notice in Table 10.2, as the level increases, more noise is removed.

Fig. 10.7
figure 7

Optimal denoising level maintains the shape of the signal

Table 10.2 The SNR and PRD values found for patient 252

4.1.5 Results for Process 1

In general, the ranking of the families’ ability to achieve the optimal result went: Coiflet, Symlet, Daubechies, and then Biorthogonal Spline. The best balance between the SNR and the PRD was at levels 4–6. At higher levels, a denoised signal starts to deviate too much from its original. An attempt to find an appropriate range for the optimal SNR and PRD was made and is explained in the next section.

4.1.6 Maximum PRD and Minimum SNR Selection

Recall, the denoised ECGs were analyzed using the SNR and PRD [2]. Plotting the PRD and SNR values on a scatter plot as x and y, respectively. Indeed, plotting a curve of best fit to PRD vs. SNR reveals an inverse relationship: while PRD increases, SNR decreases [2]. Since the relationship between PRD and SNR is an inverse one, it can be reasoned that there is a limit of maximum PRD and minimum SNR. This limit reflects the highest order one can go in denoising a signal before losing the characteristics of the true signal. We reasoned that there exists a function to reveal this limit, which intersects the PRD-SNR curve of best fit. The PRD-SNR curve is f, and the limiting curve of intersection is g. Intuitively, for g to intersect f, g needs to increase where f decreases. The point of intersection between f and g is the for mentioned limit. To create g, PRD was plotted as the independent variable and a function g of the ratio between PRD and SNR as the dependent variable on a scatter plot, which revealed a trend. Let I 1 = [1, ). The function g is:

$$\begin{array}{rcl} g& ={ \mathrm{e}}^{1+\frac{\mathrm{PRD}} {\mathrm{SNR}} },\quad \forall {\mathrm{SNR}}_{\mbox{ (rigrsure,heursure)}} \in {I}_{1},&\end{array}$$
(10.28)
$$\begin{array}{rcl} g& ={ \mathrm{e}}^{\frac{\mathrm{PRD}} {\mathrm{SNR}} },\quad \forall {\mathrm{SNR}}_{\mbox{ (universal,minimax)}} \in {I}_{1}.&\end{array}$$
(10.29)

One should note several conditions of the above statements. For each thresholding rule, there is a different intersecting function, with the only difference being an addition of one to the quotient of the first equation. This is because of the larger values of PRD and SNR produced by the universal and thresholding rules. Both functions are only defined for SNR values equal to or greater than 1. This can be reasoned by simply looking at the quotient in the natural exponent: the number created by SNR < 1 increases far too fast to create an accurate line of best fit. Therefore, a second set of functions for g was created to include SNR < 1, and dilute the larger numbers and yield similarly desired results. Let \({I}_{2} = (-\infty ,1)\)

$$\begin{array}{rcl} g& ={ \mathrm{e}}^{\frac{1} {2} + \frac{\mathrm{PRD}} {10(\mathrm{SNR})} },\quad \forall {\mathrm{SNR}}_{\mathrm{(rigrsure)}} \in {I}_{2},&\end{array}$$
(10.30)
$$\begin{array}{rcl} g& ={ \mathrm{e}}^{ \frac{\mathrm{PRD}} {10(\mathrm{SNR})} },\forall {\mathrm{SNR}}_{\mbox{ (heursure, universal)}} \in {I}_{2},&\end{array}$$
(10.31)
$$\begin{array}{rcl} g& ={ \mathrm{e}}^{1+ \frac{\mathrm{PRD}} {10(\mathrm{SNR})} },\forall {\mathrm{SNR}}_{\mathrm{(minimax)}} \in {I}_{2},&\end{array}$$
(10.32)

To find the point of intersection, the two scatter plots described above must be plotted on the same graph using their shared independent variable PRD. The point of intersection between f and g reveals the maximum PRD and minimum SNR (Fig. 10.8). As long as the level of deconstruction is within these limits, it can be used to accurately denoise a signal. Within each threshold and order, the level cap was determined to be six with the PRD exceeding the limit at level 7. Therefore, the limit is level 6, which can be observed by denoising a signal and noticing how level 7 actually starts to create peaks and deviates from the actual signal. We comment that the above functions g may be replaced by more accurate approximate functions by using advanced interpolation techniques.

Fig. 10.8
figure 8

The two scatter plots

4.2 Process 2

While exploring the available built-in wavelet functions in MATLAB, we found a second available method for denoising electrocardiograms. We designed an m file that utilized two built-in wavelet functions. These functions performed two major tasks in denoising and compressing ECGs using GBL. GBL, the MATLAB functions, and our process will all be discussed in the following sections.

Table 10.3 Data for the two scatter plots

4.2.1 Global Thresholding

GBL is different from the term-by-term thresholding rules used in process 1. GBL uses a single thresholding value to denoise or compress a signal. This method of thresholding is commonly referred to as block thresholding. The disadvantages to term-by-term thresholding are that, when using wavelets, the thresholding values are determined without taking into consideration the terms’ neighbors. This thresholding method is not optimal for wavelets because it requires a trade-off between variance and the mean squared error. These disadvantages led to the GBL method which is able to determine the best thresholding value for an entire neighborhood of coefficients. This type of thresholding method increases the adaptability of wavelet thresholding since the thresholding value is not dependent upon individual terms which can vary wildly in noisy signals. Since block thresholding takes into consideration a term’s neighboring coefficients, the threshold tends to be more receptive to the jumps and skips of the original, noisy signal. Not only does it maintain a signal’s properties better, this thresholding method preserves peaks better as well, even at the highest levels [9]. To select the threshold that minimizes error, the formula

$${\lambda }_{jb} = {[{n}^{-1}f({x}_{ jb})]}^{1/2}$$
(10.33)

depicts the global threshold, where x jb is such that 2j x jb lies in the middle of the block B b , j is the resolution, and b is the block index [9].

4.2.2 Steps of Process 2

Based on the descriptions from the above subsection, we have the following steps. To begin process 2, we created a first MATLAB function and used the patient’s ECG data to determine if soft or hard thresholding should be used, the number of approximation coefficients that should be kept, and determined the best thresholding value. We inputted the patient’s ECG data and whether or not we would be denoising or compressing the signal. The outputted values were then stored and transferred to a second function. Note, the only major difference between compression and denoising is the type of threshold; compression uses hard thresholding and denoising uses soft thresholding. In step 2, we used a second MATLAB function and the values obtained in step 1 to compress the ECG. The output was a compressed version of the ECG. The second MATLAB function used GBL and the thresholding value obtained in step 1. In step 3, the compressed ECG was entered into the first MATLAB function. This time, we indicated that we were denoising the compressed ECG. The output was then entered into the second MATLAB function which denoised the compressed ECG, once again using GBL. The denoised signal was then assessed using four values: SNR, PRD, compression score, and L2 norm recovery.

4.2.3 Comparison Method 3

The SNR and PRD, as defined in comparison method 2, were once again used to determine which wavelet, order, and level achieved the optimal results for denoising the ECGs. In order to compare how well the ECGs were compressed, two new values had to be introduced: compression score and L2 norm recovery. The compression score (PERF) represents the percentage of zero coefficients used during reconstruction. The significance of zero coefficients was discussed in Sect. 10.4.2. The closer the compression score is to 100% the better. It is defined as

$$\mathrm{PERF} = 100\,\% \times \frac{{Z}_{n}} {{C}_{n}}.$$
(10.34)
  • Z n  = number of zero coefficients at current level

  • C n  = number of coefficients

The L2 norm recovery value (PERFL2) shows how close a compressed signal is to the original signal. The closer the L2 norm recovery value is to 100%, the closer the signal is the original:

$$\mathrm{PERFL}2 = 100\,\% \times \frac{\mbox{ (vector-norm(coeffs of the current decomposition},2{)}^{2}} {\mbox{ (vector-norm(orginal signal},2){)}^{2}}.$$
(10.35)

4.2.4 Results

The results obtained in process 2 indicated only minor differences in the PRD and SNR values for each family. Overall, the results for each family were very good when comparing the denoising indicators: SNR and PRD. The rankings were:

  • Coiflet Family

  • Symlet Family

  • Daubechies Family

  • Biorthogonal Spline Family

A few exceptions obtained bad results, they were Biorthogonal Spline of orders 1.1, 1.3, and 1.5; Daubechies order 1; and Symlet of order 5. These wavelets did not obtain results as well as all other wavelets. All levels obtain good results in both denoising and compression, but levels 4 and 5 had the optimal SNR to PRD relationship. Biorthogonal Spline order 1.5 and level 5 consistently obtained the best PERF and PERFL2 for the different ECGs. It obtained PERF scores between 91% and 93%. Its PERFL2 were around 99% to almost 100%.

5 Process 1 vs. Process 2: The Result

The result of our study clearly showed that process 2 using GBL was far superior to process 1 which used four different term-by-term thresholdings. The table in this section shows the comparison data results for patient 268. The sample data set shown uses the Biorthogonal Spline order 2.4 (Bior2.4) with rigrsure thresholding, which obtained the worst results during process 1. The data set for the same wavelet using GBL is shown on the right. Coiflet order five (Coif5) with UNI, which obtained the best results in process 1 and its compliment using GBL, is also shown.

5.1 The Worst Case

The highlighted levels 4 and 10 are shown in the following figures (Fig. 10.9). For process 1, level 4 denoisings were found to be the best signal therefore, it is not surprising that Bior2.4 level 4 relatively meets our requirements. However, if you look at the boxed region, you can see how GBL is better able to smooth away the noisy regions while maintain, the integrity of the signal. The next figure shows the Bior2.4 level 10 denoising for process 1 and process 2. Level 10 denoisings obtained the worst results in process 1. The superiority of process 2, GBL, is clearly evident (Fig. 10.10).

Table 10.4 Comparison results of using different wavelets
Fig. 10.9
figure 9

The middle highlight of level 4 denoising

Fig. 10.10
figure 10

Denoising at level 10 by using Biorthogonal 2.4

5.2 The Best Case

Coiflet order 5 level 4 with rigrsure thresholding obtained the best results for process 1. This best case is compared to process 2 which obtained better results with GBL. Note the boxed region which contains one of the major peaks in an ECG. The amplitude and general shape of a peak can tell a cardiologist a lot about the condition of your heart, so it is important to maintain it. GBL clearly maintains this important region. The following figure of level 10 shows that GBL is able to maintain a clearer image of the ECGs at higher levels of decomposition which the thresholdings in process 1 were unable to do (Figs. 10.11 and 10.12).

Fig. 10.11
figure 11

The highlight of a singular part of the denoising at level 4

Fig. 10.12
figure 12

Denoising at level 10 by using Coiflet

6 Summary

For denoising ECG using term-by-term thresholds, Coiflet order five at level 4 decomposition is the best. When using any wavelet family or order, levels 4 and 5 are the best and levels 7 through 10 should not be used. When using GBL, any wavelet family can be used along with any level to denoise and compress an ECG. Levels 4 and 5 obtained the best, PRD and SNR relationship. In conclusion, we have determined GBL is the best thresholding to use when denoising electrocardiograms. There are other developed systematic and computationally efficient procedures for analyzing multivariate nonstationary signals such as the method developed in [12]. Wavelet techniques are capable of revealing aspects of data that other time-frequency analysis techniques miss, that is aspects like trends, breakdown points, discontinuities in higher derivatives, and self-similarities [10]. With the choices of wavelets studied in this chapter, one can further evaluate the wavelet coefficients of ECG signals to obtain some comparison results between healthy and unhealthy patients.