Wavelet Based Non Linear Thresholding Techniques for Pre Processing ECG Signals

The human heart consists of two upper and two lower chambers. These upper and lower chambers are called atria and ventricles respectively. The activity of the heart is not a random process but beats in a synchronized manner. Thus the heart produces a regular rhythmic activity, called electrical wave. The depolarization cycle starts at the sinoatrial (SA) node and this wave propagates through through the atrium to atrioventricualr (AV) node and then to the bundle of His and rest of the ventricles [14][15].After depolarization phase the repolarisation state begins. This trace of electrical waves is called an electrocardiogram (ECG).The standard ECG waveform for one cardiac cycle is shown in figure 1.


Introduction To Ecg Signal
The human heart consists of two upper and two lower chambers. These upper and lower chambers are called atria and ventricles respectively. The activity of the heart is not a random process but beats in a synchronized manner. Thus the heart produces a regular rhythmic activity, called electrical wave. The depolarization cycle starts at the sinoatrial (SA) node and this wave propagates through through the atrium to atrioventricualr (AV) node and then to the bundle of His and rest of the ventricles [14] [15].After depolarization phase the repolarisation state begins. This trace of electrical waves is called an electrocardiogram (ECG).The standard ECG waveform for one cardiac cycle is shown in figure 1.

IJBAR (2013) 04 (08) www.ssjournals.com
The ECG is characterized by many peaks and valley denoted by P-QRS-T and U. The P wave is associated with the activation of the atrium, the QRS complex and the T wave with ventricular repolarization and depolarization respectively. But the U wave is not consistent and is invisible among 70% of the people. Clinically the U wave is not important. The human ECG signals are in the mV range and the frequency range is 0.05-100Hz and most of the useful information is contained in the range of 0.5-45Hz. Electrocardiography is the starting point to the diagnosis of many heart disorders.

Fundamentals of wavelet transform
The word wavelet means a "small wave", which is localized in time and frequency and extends from   to   for a finite duration of time 2,16,17 . The wavelet transform maps a 1-D function ) (t x into a two dimensional time-scale plane and is denoted by here ) (t h is called mother wavelet. This mother wavelet is a unscaled and untranslated function. A set of basis functions can be generated by translation and scaling the mother wavelet, called daughter wavelets and is given by The scaling parameter s is positive and varies from 0 to  for 1  s where c is unknown constant and has to be less than  for the wavelet transform to be valid.  is the time parameter and the parameter s is called scale, which is inversely proportional to the frequency. The wavelet transform itself varies with both s and .The inclusion of s and  allows the function to be scaled and translated for different values of s and t. The admissibility condition is given as The term 2 s ds in equation (5) represents differential change in frequency and is obtained from differentiating the relationship between frequency and scale 2 s ds dw   (6) A wavelet has to satisfy at least the following two conditions.  (7) i.e. the wavelet function has an equal area above and below zero. 2. The square of ) (t h has an integral equal to unity. (8) This function approaches zero at positive and negative infinite and decays away from origin unlike sinusoidal or other infinite waves.

2.1.The Continuous Wavelet Transforms (CWT)
The continuous wavelet transform and is defined by the equation where the kernel functions are constructed by following equation The subscrip * in the above equation refers to the complex conjugate. The square of the norm is given by This means that the dilated /compressed version of the signal has the same energy.

The Discrete wavelet transform (DWT)
In practice, when implemented on a computer, a continuous wavelet transform must be discrete. Therefore, it is necessary to discretize the continuous wavelet transform.
For DWT the scale parameter s and translation parameter  can be taken as In DWT 13,17 , the filters with different cut off frequency are used for the analysis of the signal at different scales. The low pass filter is denoted by G 0 and high pass is denoted by H 0.. At each level of decomposition the high pass filter gives detailed coefficients d[n], which generally represent the noise of the signal and output of the low pass filter gives approximation coefficients a[n], also called coarse approximation. The DWT of the original signal can be obtained by concatenating all the coefficients a[n] and d[n], starting from the last level of decomposition.
The decomposition and reconstruction of the signal using wavelet transform is shown in figure (2)

2.4.Daubechies wavelets p D
Daubechies wavelets are family of orthogonal discrete wavelet transform and characterized by maximal number of vanishing moments for a given support.Daubechies orthogonal wavelets from D2-d20 are commonly used and D4, D6, D8 are the most common. The index number refers to the number of moments. The number of vanishing moments is equal to the half of the number of coefficients. For example D2 has one vanishing moment and D2 has two vanishing moments. From the Daubeches wavelet family D4 is used because it is similar in shape of the real ECG signal.
DB4 scaling signal and wavelet have support of four points. The four values DS4 (i) for the scaling signal for daub4 are The associated daub4 wavelets are defined by where p is approximation order

Noise Removal Process From The Ecg Signal
Electrocardiography (ECG) is one of the main tools for observing the heart activity [3] [11]. The major challenge in using the ECG is that it has very small signal to noise ratio (SNR) and buried in wide variety of noise sources. Therefore it is essential to minimize these noises from the signal to obtain clinically related data to assess the condition of the heart. There are many methods available to remove (or minimize) these noises from the raw data. Since the traditional methods have their own limitations the advanced filtering technique called wavelet filtering for preprocessing an ECG signal are used.
The heart wave (ECG) is highly non-stationary and for the analysis of this kind of signal a wavelet transform technique is most suitable since it gives the information in both time and frequency, required for clinical IJBAR (2013) 04 (08) www.ssjournals.com assessment. The ECG signal is very weak whose amplitude varies in the range of 110V to 4mV.Hence, it is easily affected by different sources of noises. The various kind of noises that are present in the ECG signal are broadly classified into the following types [8] [9].
Detection and classification of signals in the presence of noise and interference is very critical in many areas of signal processing applications, especially signals which are non stationary in their characteristics such as ECG.The signal component to be detected is represented by ), (t y ) (t n be the noise component, then the observed signal ) (t x can be modeled by the following equation: The noise suppression techniques in signal processing are based on representing the signal ) (t x such that it is possible to separate the noise component from the signal component. To solve these difficult problems, the conventional method of signal filtering is often ineffective. Wavelet transform is a new signal processing tool, which is is suitable for processing non-stationary signals. e.g. separating the of signal from noise.

Denoising by wavelet shrinkage techniques
The information is mostly contained in few coefficients. By choosing a proper wavelet the one that correlates with the signal to be detected, large wavelet coefficients values are obtained when there is signal information and much smaller coefficients when there is mostly noise.This is the fundamental principle behind the idea of wavelet thresholding, in which the signal reconstruction is achieved by using wavelet coefficients whose magnitudes are above specified threshold values. In any wavelet analysis one should choose the wavelet to match the characteristics of the signal to be analyzed 1],6,5,12 .

4.1.Selection of wavelet shrinkage function
The two basic forms for selecting the shrinkage functions are soft shrinkage and hard shrinkage and they are defined by the following equations, which are developed by Donoho and Johnston 1,7 Soft shrinkage: Hard shrinkage: Soft threshold results in the reduction of wavelet coefficients by a value  and for this reason it is also known as wavelet shrinkage. By applying wavelet transform the noise contribution is estimated and proper threshold is chosen. The remaining wavelet coefficients are used to reconstruct the original information signal ) (t y . The decomposition and reconstruction procedure is shown in figure (2) and (3).By choosing a very large value of  the number of coefficients obtained will be very few, resulting in over smoothing of a signal. Thus there will be a possibility that some of the information may be lost. On the other hand, if the threshold is set to too low, IJBAR (2013) 04 (08) www.ssjournals.com then part of the noise may be maintained at the reconstructed signal. Thus, it is very crucial to select the optimum threshold value to achieve a very good noise rejection performance without major loss in the spatial resolution.
Soft shrinkage suffers from large bias while hard shrinkage has smaller bias but has bigger variance and very sensitive to small changes in the data. In the hard shrinkage function there is a discontinuity in the shrinkage function as shown in figure (5). The coefficient values which are above the threshold are untouched. On the other hand the soft thresholding function is continuous since it shrinks the values above the threshold λ. The soft shrinkage function is preferred for denoising since the noise affects all coefficients. 2. Apply thresholding to obtain the estimated wavelet coefficients for each level. It is possible to use different thresholding functions.
3. Reconstruct the denoised ECG signal from the estimated wavelet coefficients by inverse DWT.
In these three steps the most critical thing is how to select the threshold and quantify them.

Principle of wavelet threshold denoising
The method is based on taking the discrete wavelet transform (DWT) of a signal and passing this transform through a threshold, which removes the coefficients below a certain value, then taking the inverse discrete wavelet transform (IDWT).

Methods to choose threshold value
(1) Global threshold: In this method a same value of threshold  is to be applied globally to all wavelet coefficients for different decomposition levels m of the DWT.
(2) Level dependent threshold: In this method different threshold value j  is chosen for each resolution level j to shrink the wavelet coefficients at that level.
Most of the wavelet coefficients containing the signal information are in the lower resolution range. Thus the wavelet coefficients due to signal have a larger magnitude than the corresponding noise coefficients. Hence the proper choice of threshold takes into account at least the factors, the sample size N and noise level σ 2. . This threshold requires the estimation of noise level σ. The shrinkage function determines how the thresholds are applied to the data (i)Universal threshold method: This method is most popular in all kinds of threshold and can be expressed as follows

4.5.Rules for selecting the threshold i
If data is not normalized with respect to noise standard deviation, then the threshold is given by IJBAR (2013) 04 (08) www.ssjournals.com where N is the sampling length of the noisy ECG signal,  is the estimated standard deviation of zero mean of white Gaussian noise (WGN) and k w are the detail coefficients of wavelet transform at first scale. This method gives the largest threshold value and hence results in a relatively high degree of smoothness.
(ii) Minimaxi threshold (vishu shrink) method: The minimaxi threshold minimizes a theoretical upper bound on the asymptotic risk. They are always smaller than the universal threshold for given sample size and thus results in less smoothing. An empirical method to calculate the threshold based on the standard deviation of the noise σ, is given by the following equation (iv) SURE Shrink: This is the hybrid method combining the universal and SURE threshold, and also the best predict variable threshold selection. If SNR is small, SURE estimation will have lots of noise. If this occurs the fixed threshold can be used . This method is preferred where the wavelet coefficients decomposition is sparse. The default threshold denoising method code: [thr,sorh,keepapp]=ddencmp('den','wv',y); xd5=wdencmp('gbl',y,'db4',3,thr,sorh,keepapp); Where y is the signal through a low-pass filter.
xd1-xd4 are denoised results. The spectrum of the original signal is distributed in frequency range from 0 to 100Hz and the main component is distributed in 0.05  45Hz.
The results of the four threshold denoising are compared and shown in figure (10). The four threshold methods namely rigrsure, heursure, universal, and minimax, have removed considerable noise present in the signal. One can very easily visualize and see that the rigrsure and minimaxi threshold method can effectively remove noise while IJBAR (2013) 04 (08) www.ssjournals.com retain the characteristics of ECG, while the heursure and sqtwolog threshold denoising methods may remove some of the useful component from the signal.

Statistical Analysis
To evaluate the performances of various techniques the following equations are used in the literature. The important equations are given as below [2] [14] [10] 1. Standard deviation (σ), which gives the variation of the noise through the signal and is given by where Secg is the original ECG signal, Secg is the mean of all the samples in the signal and N is length of the filtered signal. 2. The root mean square error (RMSE) of original signal and denoised signal is given by the following equation 3. Signal to Noise Ratio (SNR), which gives the information about quality of the signal. Higher the SNR better is the performance of the system and the signal to noise ratio is given by the following equation

Results and Discussions
The four wavelet denoising algorithms on eight different ECG signals from MIT-BIH arrhythmia data base which is freely available on physionet were tested. The sampling frequency of the sampled signal is 360 Hz with ADC resolution of 11 bits and bit rate of 3960 bps and number of samples used is 650000.The initial value is 995 and base line wander is 1024.The MLII lead data is used in all the recordings. The insignificant data has been suppressed and the DC component is removed by subtracting the mean from the signal. This signal is treated as the original recorded signal. To this signal power line frequency of 60 Hz and Gaussian white noise is added as shown in figure (5). This signal is passed through an FIR filter of order 64 and cut off frequency of 70 Hz. The filtered response and the filtered signal and spectrum are shown in figure (6).An FIR filter is used since it is an all pole system and always stable. Most of the clinical information is contained in the frequency range of 0.5 Hz to 45 Hz, as shown in figure (15) and the results proved in table 3 from the graph. A band pass filter is designed to pass this frequency range. The command [b a]=butter (64, [0.5/ (Fs/2) 35/ (Fs/2]) provides the desired filter coefficients for 64 th order filter. These coefficients are used in the filter command to band pass the signal between 0.5Hz to 45Hz, sampled at 360 Hz. An adaptive filter has been used for attenuating the 60 Hz signal and moving average filter for removing base line wander.The db4 wavelet which resembles the standard ECG signal characteristics is used in the analysis process. The performances of the methods have been evaluated in terms of SNR and RMSE. From the table 1, it can be observed that the SNR of the rigrsure is slightly higher than the heursure and universal and almost equal to the minimaxi threshold.SNR values of universal threshold are high due to over smoothing effect.

Conclusions
In this work we have analyzed a very important signal, the electrocardiography by applying an advanced filtering tool called discrete wavelet transform. A new threshold and shrinkage functions are used to denoise the noisy ECG signal efficiently to keep it distortion free and smooth. In signal denoising applications, soft thresholding method gives better results than hard thresholding method. From simulation results we can observe that the wavelet transform can remove the noise effectively and improve the SNR .By using rigrsure threshold and minimaxi threshold we can effectively reduce the noise and retain the useful information of the ECG signal. Use of heursure and sqtwlog threshold techniques will remove a useful component of ECG signal .These methods are more harm than good. Use of default threshold methods cannot effectively remove the noise and unable to obtain the signal characteristics of the ECG signal.