Robust R Peak and Qrs Detection in Electrocardiogram Using Wavelet Transform

— In this paper a robust R Peak and QRS detection using Wavelet Transform has been developed. Wavelet Transform provides efficient localization in both time and frequency. Discrete Wavelet Transform (DWT) has been used to extract relevant information from the ECG signal in order to perform classification. Electrocardiogram (ECG) signal feature parameters are the basis for signal Analysis, Diagnosis, Authentication and Identification performance. These parameters can be extracted from the intervals and amplitudes of the signal. The first step in extracting ECG features starts from the exact detection of R Peak in the QRS Complex. The accuracy of the determined temporal locations of R Peak and QRS complex is essential for the performance of other ECG processing stages. Individuals can be identified once ECG signature is formulated. This is an initial work towards establishing that the ECG signal is a signature like fingerprint, retinal signature for any individual Identification. Analysis is carried out using MATLAB Software. The correct detection rate of the Peaks is up to 99% based on MIT-BIH ECG database.


INTRODUCTION
The Electrocardiogram is the electrical manifestation of the contractile activity of the heart.It is a graphical record of the direction and magnitude of the electrical activity that is generated by depolarization and repolarization of the atria and ventricles.It provides information about the heart rate, rhythm, and morphology.The importance of the Electrocardiography is remarkable since heart diseases constitute one of the major causes of mortality in the world.ECG varies from person to person due to the difference in position, size, anatomy of the heart, age, relatively body weight, chest configuration and various other factors.There is strong evidence that heart"s electrical activity embeds highly distinctive characteristics, suitable for various applications and diagnosis.
The ECG is characterized by a recurrent wave sequence of P, QRS, T and U wave associated with each beat.The QRS complex is the most striking waveform, caused by ventricular depolarization of the human heart.A typical ECG wave of a normal heartbeat consists of a P wave, a QRS complex, and a T wave.Fig. 1 depicts the basic shape of a healthy ECG heartbeat signal with P, Q, R, S, J, T and U characteristics and the standard ECG intervals QT interval, ST interval and PR interval.QRS detection is one of the fundamental issue in the analysis of Electrocardiographic signal.The QRS complex consists of three characteristic points within one cardiac cycle denoted as Q, R and S. The QRS complex is considered as the most striking waveform of the electrocardiogram and hence used as a starting point for further analysis or compression schemes.The detection of a QRS complex seems not to be a very difficult problem.However, in case of noisy or pathological signals or in case of strong amplitude level variations, the detection quality and accuracy may decrease significantly.
Numerous QRS detection algorithms such as derivative based algorithms [1][2][3][4], wavelet transform [5], Filtering Techniques [6] artificial neural networks [7][8][9], genetic algorithms [10], syntactic methods [11], Hilbert transform [12], Markov models [13] etc. are reported in literature.Kohler et al [14] described and compared the performance of all these QRS detectors.Recently few other methods based on pattern recognition [15], moving-averaging [16] etc are proposed for the detection of QRS complex.Once the position of the QRS complex is obtained, the location of other components of ECG like P, T waves and ST segment etc. are found relative to the position of QRS, in order to analyze the complete cardiac period.http://ijacsa.thesai.org/Recently Wavelet Transform has been proven to be useful tool for non-stationary signal analysis.Among the existing wavelet approaches, (continuous, dyadic, orthogonal, biorthogonal), we use real dyadic wavelet transform because of its good temporal localization properties and its fast calculations.Discrete Wavelet Transform can be used as a good tool for non-stationary ECG signal detection.DWT is a sampled version of the Continuous Wavelet Transform (CWT) in a dyadic grid.

II. WAVELET TRANSFORM
The Wavelet Transform is a time-scale representation that has been used successfully in a broad range of applications, in particular signal compression.Recently, Wavelets have been applied to several problems in Electrocardiology, including data compression, analysis of ventricular late potentials, and the detection of ECG characteristic points.The Wavelet transformation is a linear operation that decomposes the signal into a number of scales related to frequency components and analyses each scale with a certain resolution [17][18][19][20][21].
The WT uses a short time interval for evaluating higher frequencies and a long time interval for lower frequencies.Due to this property, high frequency components of short duration can be observed successfully by Wavelet Transform.One of the advantage of the Wavelet Transform is that it is able to decompose signals at various resolutions, which allows accurate feature extraction from non-stationary signals like ECG.A family of analyzing wavelets in the time frequency domain is obtained by applying a scaling factor and a translation factor to the basic mother wavelet.
Wavelet Transform of a signal f (t) is defined as the sum of over all time of the signal multiplied by scaled, shifted versions of the wavelet function ψ and is given by, , and scaled version of a mother wavelet which is used as bases for wavelet decomposition of the input signal.One of the key criteria of a good mother wavelet is its ability to fully reconstruct the signal from the wavelet decompositions.
The DWT is sufficient for most practical applications and for the reconstruction of the signal [22].The DWT provides enough information, and offers a significant reduction in the computation time.Here, we have discrete function () fnand the definition of DWT is given by: , ( , ) ( , ) ( ) ( ) where , () jk n  is a discrete wavelet defined as 2 , ( ) 2 (2 ) The parameters a, b are defined in such a way that 2 j a  , 2 j bk  .In the DWT analyses, the signal at different frequency bands and at different resolutions is decomposed into a 'coarse approximation' and 'detailed information'.Two sets of functions are employed by the DWT, the scaling functions (associated with the low pass filter) and the wavelet functions (associated with the high pass filter).The signal is filtered by passing it through successive high pass and low pass filters to obtain versions of the signal in different frequency bands.

The original signal ()
xn is passed through a half band low pass and high pass filter.With the signal highest frequency being π/2, half of the samples are eliminated adhering to the Nyquist criterion.Thus, the signal can be sub-sampled by 2 as shown in Equation ( 5).Thus mathematically, this can be written as: The decomposition perform halves the time resolution and at the same time doubles the frequency resolution.Thus, at every level, the filtering and sub-sampling will result in half the time resolution and double the frequency resolution.The successive Low Pass Filter (LPF) and High Pass Filter (HPF) of the discrete time-domain signal are called the Mallat algorithm or Mallat Tree Decomposition (MTD).The sequence () xn is passed through several levels made up of low pass () gn and high pass () hn analysis filters.At each level, "detail information"   j dn is produced by the high pass filter while the "coarse approximations"   j an is produced by the low pass filter.
The maximum number of levels of decomposition depends upon the length of the signal as shown in Fig. 2. The Discrete Wavelet Transform of the original signal is obtained by concatenating all the coefficients, a j [n] and d j [n].http://ijacsa.thesai.org/

Three level wavelet decomposition tree
The reconstruction process is the reverse of decomposition, where the approximation and detail coefficients at every level are up-sampled by 2 and passed through low-pass () gnand high pass () hn synthesis filters and finally added as shown in Fig. 3.The same number of levels is taken as in the case of decomposition.
Figure 3. Three level wavelet reconstruction tree Wavelet Transform is popular because it satisfies energy conservation law and original signal can be reconstructed.It is obvious that Wavelet Transform at scale "a' is proportional to the derivative of the filtered signal with a smoothing impulse response at scale "a'.Therefore, local maxima or minima of the smoothed signal will occur on the zero crossings of the Wavelet Transform at different scales.Maximum absolute values of the Wavelet Transform will show the maximum slopes in the filtered signal.

A. Wavelet Selection
The use of the Wavelet Transform has gained popularity in time-frequency analysis because of the flexibility it offers in analyzing basis functions.The selection of relevant wavelet is an important task before starting the detection procedure.The choice of wavelet depends upon the type of signal to be analyzed.The wavelet similar to the signal is usually selected.The are several wavelet families like Harr, Daubechies, Biorthogonal, Coiflets, Symlets, Morlet, Mexican Hat, Meyer etc. and several other Real and Complex wavelets.However, Daubechies (Db4) Wavelet has been found to give details more accurately than others [23].Moreover, this Wavelet shows similarity with QRS complexes and energy spectrum is concentrated around low frequencies.Therefore, we have chosen Daubechies (Db4) Wavelet for extracting ECG features in our application [22].The Daubechies Wavelet is shown in Fig. 4. Header file consists of detailed information such as number of samples, sampling frequency, format of ECG signal, type of ECG leads and number of ECG leads, patient"s history and the detailed clinical information.In binary data signal file, the signal is stored in 212 format which means each sample requires number of leads times 12 bits to be stored and the binary annotation file consists of beat annotations.Signals were sampled using a 12-bit analog-to-digital converter board (National Instruments, PCI-6071E).Matlab and its wavelet toolbox were used for ECG Signal processing and Analysis.Analysis was performed on the PQRST waveform.

IV. METHODOLOGY
In order to extract useful information from the ECG signal, the raw ECG signal should be processed.ECG signal processing can be roughly divided into two stages by functionality: Preprocessing and Feature Extraction as shown in Fig. 5. http://ijacsa.thesai.org/Feature Extraction is performed to form distinctive personalized signatures for every subject.The purpose of the feature extraction process is to select and retain relevant information from original signal.The Feature Extraction stage extracts diagnostic information from the ECG signal.The preprocessing stage removes or suppresses noise from the raw ECG signal.A Feature Extraction method using Discrete Wavelet Transform was proposed by Emran et al [22].

A. Preprocessing
ECG signal mainly contains noises of different types, namely frequency interference, baseline drift, electrode contact noise, polarization noise, muscle noise, the internal amplifier noise and motor artifacts.Artifacts are the noise induced to ECG signals that result from movements of electrodes.One of the common problems in ECG signal processing is baseline wander removal and noise suppression.

1) Removal of the baseline drift
Baseline wandering is one of the noise artifacts that affect ECG signals.Removal of baseline wander is therefore required in the analysis of the ECG signal to minimize the changes in beat morphology with no physiological counterpart.Respiration and electrode impedance changes due to perspiration are important sources of baseline wander in most types of ECG recordings.The frequency content of the baseline wander is usually in a range well below 0.5Hz.This baseline drift can be eliminated without changing or disturbing the characteristics of the waveform.
We use the median filters (200-ms and 600-ms) [24] to eliminate baseline drift of ECG signal.The process is as follows a) The original ECG signal is processed with a median filter of 200-ms width to remove QRS complexes and P waves.b) The resulting signal is then processed with a median filter of 600-ms width to remove T waves.The signal resulting from the second filter operation contains the baseline of the ECG signal.c) By subtracting the filtered signal from the original signal, a signal with baseline drift elimination can be obtained.

2) Removal of the NOISE
After removing baseline wander, the resulting ECG signal is more stationary and explicit than the original signal.However, some other types of noise might still affect feature extraction of the ECG signal.In order to reduce the noise many techniques are available like Digital filters, Adaptive method and Wavelet Transform thresholding methods.Digital filters and Adaptive methods can be applied to signal whose statistical characteristics are stationary in many cases.However, for nonstationary signals it is not adequate to use Digital filters or Adaptive method because of loss of information.To remove the noise, we use Discrete Wavelet transform.This first decomposes the ECG signal into several subbands by applying the Wavelet Transform, and then modifies each wavelet coefficient by applying a threshold function, and finally reconstructs the denoised signal.The high frequency components of the ECG signal decreases as lower details are removed from the original signal.As the lower details are removed, the signal becomes smoother and the noise disappears since noises are marked by high frequency components picked up along the ways of transmission.This is the contribution of the discrete Wavelet Transform where noise filtration is performed implicitly.The preprocessed signal using DWT is shown in Fig. 6.

B. Detection of R peak and QRS
In order to detect the peaks, specific details of the signal are selected.The detection of R peak is the first step of feature extraction.The R peak in the signal from the Modified Lead II (MLII) lead has the largest amplitude among all the waves compared to other leads.The QRS complex detection consists of determining the R point of the heartbeat, which is in general the point where the heartbeat has the highest amplitude.A normal QRS complex indicates that the electrical impulse has progressed normally from the bundle of His to the Purkinje network through the right and left bundle branches and that normal depolarization of the right and left ventricles has occurred.
Most of the energy of the QRS complex lies between 3 Hz and 40 Hz [25].The 3-dB frequencies of the Fourier Transform of the wavelets indicate that most of the energy of the QRS complex lies between scales of 2 3 and 2 4 , with the largest at 2 4 .The energy decreases if the scale is larger then 2 4 .The energy of motion artifacts and baseline wander (i.e., noise) increases for scales greater then 2 5 .Therefore, we choose to use characteristic scales of 2 1 to 2 4 for the wavelet.
The detection of the QRS complex is based on modulus maxima of the Wavelet Transform.This is because modulus maxima and zero crossings of the Wavelet Transform correspond to the sharp edges in the signal.The QRS complex produces two modulus maxima with opposite signs, with a zero crossing between them shown in Fig.  QRS width is calculated from the onset and the offset of the QRS complex.The onset is the beginning of the Q wave and the offset is the ending of the S wave.Normally, the onset of the QRS complex contains the high-frequency components, which are detected at finer scales.To identify the onset and offset of the wave, the wave is made to zero base.The onset is the beginning and the offset is the ending of the first modulus maxima pair.Once this QRS complex is located the next step is to determine the onset and offset points for each QRS complex and to identify the component waves of the QRS complex.The R peak and QRS complex is shown in Fig. 8.The information about the R Peak and QRS complex obtained is very useful for ECG Classification, Analysis, Diagnosis, Authentication and Identification performance.The QRS complex is also used for beat detection and the determination of heart rate through R-R interval estimation.This information can also serve as an input to a system that allows automatic cardiac diagnosis.The overall sensitivity of the detector improves.The main advantage of this kind of detection is less time consuming for long time ECG signal.http://ijacsa.thesai.org/Further, ECG signal is a life indicator, and can be used as a tool for liveness detection.The physiological and geometrical differences of the heart in different individuals display certain uniqueness in their ECG signals.Hence ECG can be used as a Biometric tool for Identification and Verification of Individuals.The advantage of ECGs in biometric systems is their robust nature against the application of falsified credentials.Amplitude of P wave remains constant throughout the life and other amplitude features are changes on small scale.Future work is to calculate the amplitude distance between ECG features and comparison will be made for Identification.Further verification of individuals can be done by using statistical theory of Sequential Probability procedures.

Figure 1 .
Figure 1.An ECG waveform with the standard ECG intervals

Figure 4
Figure 4. Daubechies4 Wavelet III.DATA ECG signals required for analysis are collected from Physionet MIT-BIH arrhythmia database where annotated ECG signals are described by a text header file (.hea), a binary file (.dat) and a binary annotation file (.atr).The database contains 48 records, each containing two-channel ECG signals for 30 min duration selected from 24-hr recordings of 47 different individuals.Header file consists of detailed information such as number of samples, sampling frequency, format of ECG signal, type of ECG leads and number of ECG leads, patient"s history and the detailed clinical information.In binary data signal file, the signal is stored in 212 format which means each sample requires number of leads times 12 bits to be stored and the binary annotation file consists of beat annotations.Signals were sampled using a 12-bit analog-to-digital converter board (National Instruments, PCI-6071E).Matlab and its wavelet toolbox were used for ECG Signal processing and Analysis.Analysis was performed on the PQRST waveform.

Figure 6 .
Figure 6.Baseline removed and Denoised Signal 7. Therefore, detection rules (thresholds) are applied to the Wavelet Transform of the ECG signal.The Q and S point occurs about the R Peak with in 0.1second.The left point denoted the Q point and the right one denotes the S point.Calculating the distance from zero point or close to zero of left side of R Peak within the threshold limit denotes Q point.Similarly the right side denotes the S point.

Figure 8 .
Figure 8. a) R-Peak b) QRS Complex V. CONCLUSION An algorithm for R Peak and QRS complex detection using Wavelet Transform technique has been developed.Table -1 shows the detection results on the whole database.The information about the R Peak and QRS complex obtained is very useful for ECG Classification, Analysis, Diagnosis, Authentication and Identification performance.The QRS complex is also used for beat detection and the determination of heart rate through R-R interval estimation.This information can also serve as an input to a system that allows automatic cardiac diagnosis.The overall sensitivity of the detector improves.The main advantage of this kind of detection is less time consuming for long time ECG signal. *

TABLE - 1
: TEST RESULTS SHOW THE DETECTION RESULTS.