ECG analysis continues to play a vital role in the primary diagnosis and prognosis of cardiac ailments. This paper presents a new approach to classification of ECG signals based on feature extraction and Artificial Neural Network (ANN) using Discrete Wavelet Transform (DWT). Nineteen ECG signals from MIT-BIH database were used to test the performance of proposed method. A 97.12% of sensitivity and 94.37% of positive predictivity were reported in this test for QRS complex detection. Arrhythmias detected were bradycardia, tachycardia, premature ventricular contraction, supraventricular tachycardia, and myocardial infarction.
An Electrocardiogram (ECG) is basically a register of the heart's electrical activity, widely used as an important cardiac diagnostic tool. The frequency range of ECG is from 0.1-150 Hz [15]. A usual ECG waveform of normal heart beat consists of five basic waves P, Q, R, S, and T waves as shown in Figure 1. The P wave represents atrial depolarization, Q, R and S waves (QRS complex) represent the ventricular depolarization and T wave shows the repoalrization of ventricle [15]. Successive repetition of such “PQRST” waves in monotony forms an ECG. The characteristics of normal heart rhythm are called Normal Sinus Rhythm (NSR), any disorder in these parameters results in a pathological condition called Arrhythmia or dysrhythmia. Physicians analyze the shapes of those waves and complexes the height and the interval of each wave, such as RR interval, PP interval, QT interval, and ST segment and interpret whether the ECG shows signs of cardiac disease or not. Recognition of the fiducial points and calculations of the parameters is a tedious routine for the physician. Therefore, there is an urgent need for an automatic ECG recognition system to reduce the burden of interpreting the ECG.
Figure 1. Basic ECG Waveform with Intervals
Three common types of arrhythmias observed are Bradyarrhythmias, supraventricular arrhythmia, and ventricular arrhythmia. Bradyarrhythmia occurs as a result of slower heart rate. Supraventricular arrhythmias denote a condition of fast heart rates (tachycardia), which include atrial flutter, atrial fibrillation, Wolff-Parkinson-White (WPW) syndrome, and Paroxysmal Supraventricular Tachycardia (PSVT) [16]. Ventricular arrhythmias generally include ventricular fibrillation and ventricular tachycardia. ECG signals being non-stationary, it is difficult to visually analyse and may take a lot of time, hence we need computer based methods for its analysis. Several methods, such as Wavelet transform, Autoregressive modelling, and Neural networks [15, 16, 21] have been developed to analyse ECG signals and improve accuracy in detecting arrhythmias.
In this work, the authors have developed a simple and accurate algorithm using Discrete Wavelet Transform (DWT). Wavelets can provide a time versus frequency representation of the signal and work well on non-stationary data.
In Figure 1, a clear P wave before the QRS complex represents sinus rhythm. Absence of P waves may suggest atrial fibrillation, junction rhythm, or ventricular rhythm. The QRS complex shows the largest voltage deflection of approximately 10-20 mv, but depending on age and gender, may vary in size. The morphology of QRS complex may also indicate about the cardiac ailments.
The sources of ECGs were obtained from MIT-BIH (Massachusetts Institute of Technology-Beth Israel Hospital) and the database includes a set of over 4000 long-term recordings of which 60% were obtained from in-patients. The database contains 48 records chosen at random which include a variety of clinically important phenomena that would not be well-represented by a small sample of recordings. Each of the 48 records was recorded slightly above 30 minutes long as shown in Figure 2 [11]. The recordings were digitized at 360 samples per second per channel with 11-bit resolution over a 10 mV range. Each record was annotated by more than two cardiologists independently and the differences arose were resolved to obtain the computer-readable reference annotations for each beat included with the database.
Figure 2. A Signal of the MIT-BIH Database viewed using Online Tools provided by the Site [10]
In most records, the upper signal is a Modified Limb Lead II (MLII), obtained by placing the electrodes on the chest. The lower signal is usually a modified lead V1 and sometimes may be V2 or V5. Normal QRS complexes are usually prominent in the upper signal.
The proposed algorithm and the scheme are shown in the block diagram (Figure 3). It involves three steps, they are Pre-processing, feature extraction, and classification.
Figure 3. Block Diagram of the Proposed Algorithm
1. ECG Database.
2. Pre-processing of ECG signal .
3. QRS detection, R peak detection.
4. Feature extraction of complete ECG.
5. Arrhythmia classification using ANN.
6. Disease diagnosis.
Preprocessing is a necessary process to eliminate noises of ECG signal and it involves different strategies for various noise sources [12]. This pre-process of ECG signal is done before feature extraction and can result in better extracted features for improved system efficiency. Preprocessing of ECG signal includes de-noising of ECG signal and baseline wander removal using multiresolution wavelet transform.
Wavelet transform was used in this study for extracting parameters of ECG. In simple terms a wavelet is a small wave which has energy concentrated in time to give a tool for the analysis of transient, nonstationary, or time-varying phenomena [8]. Wavelet analysis breaks a signal down into its constituent parts for analysis. Mother wavelet transform used here is Daubechies of Db family; in case a signal is not sufficiently represented by one member of the Db family, it may be still efficiently represented by another. Daubechies wavelet family has more or less similar shape to QRS complex and their energy spectrum is concentrated around low frequencies. The wavelet transform is a convolution of the wavelet function ψ(t) with the signal x(t). Orthonormal dyadic discrete wavelets are usually associated with scaling functions Φ(t) [13]. The scaling function could be convolved with the signal to produce approximation coefficients. The Discrete Wavelet Transform (DWT) can be represented as,
By choosing an orthnormal wavelet basis, ψ (t)m,n, it is possible to reconstruct the original. The approximation coefficient of the signal at the scale m and location n can be presented by
In practice, the discrete input signal S0,n is of finite length N, which is an integer power of 2: N = 2m. Thus the range of scales that can be investigated is 0 < m < M. A discrete approximation of the signal can be written as,
Where the mean signal approximation at scale M is
and the detail signal approximation corresponding to scale m is defined for a finite length signal as,
Adding the approximation of the signal at scale index M to the sum of all the detailed signal components across scales gives the approximation of the original signal at scale index 0. The signal approximation at a specific scale was a combination of the approximation and detail at the next lower scale.
If scale m = 3 was chosen, it can be shown that the signal approximation is given by,
This can be referred to as multi resolution analysis of a signal using wavelet transform, and is used in this procedure 0 < m < M.
Input ECG signal is decomposed into approximate and detailed coefficients. Figure 4 gives all details and needed approximate coefficients of input ECG signal. Of all those only d3, d4, d5, d6 coefficients were used to reconstruct ECG signal. Now reconstructed signal was used for further processing. ECG signal was de-noised by removing wavelet coefficients at higher scales [10].
Filtered signal y[n] was obtained using the formula:
where x(n) are the ECG samples.
The signal y[n] from equation (1) was then differentiated twice to give z[n] using the following equations:
The differentiated signal was then squared to give w[n] using
Signal (4) denotes the squared QRS complex, from which the start point and end points of the QRS complex was determined. In order to confirm the detected signal in a QRS complex, this signal has to pass through threshold and peak and valley checker [9]. This was followed by the following threshold operation:
This threshold operation produced a series of pulses h[n] having durations equivalent to the width of the QRS complexes.
The presence of the peak and valley points of the QRS complex was confirmed through Peak and valley checker, which is a distinguished feature of QRS complex.
Online implementation of state machine logic was used in the present study to determine peaks, locations, and duration of P Q R S T wave in ECG signals. Further, RR interval, ST segment, PR interval, TT interval, and their durations were calculated using the basic logic to find distance between occurrences of the required parameter [19]. ECG analysis helps to detect and classify ECG waveform abnormalities. These durations were then compared with normal values to determine the degree and types of abnormalities [17] . Further, the processed ECG signal was given as input to the feature extraction algorithm, wherein the features related to time, such as the occurrence and duration of P, Q, R, S, and T waves are determined.
In the wavelet based algorithm, the ECG signal has been denoised by removing the corresponding wavelet coefficients at higher scales. Then QRS complexes are detected and each complex is used to find the peaks of the individual waves like P and T, and also their deviations [3]. The detection of the QRS complex particularly, the detection of the QRS complex peak, or R wave-in an ECG signal is a difficult problem because it has a time-varying morphology and is subject to physiological variations of the patient and extent of corruption due to noise. Since the QRS complexes have a time-varying morphology, they are not always the strongest signal component in an ECG signal. Therefore, P-waves or T-waves with characteristics similar to that of the QRS complex, as well as spikes from high frequency pacemakers can compromise the detection of the QRS complex. In addition, there are many sources of noise in a clinical environment that can degrade the ECG signal [14]. These include power line interference, muscle contraction noise, poor electrode contact, patient movement, and baseline wandering due to respiration. Therefore, QRS detectors must be invariant to different noise sources and should be able to detect QRS complexes even when the morphology of the ECG signal is varying with respect to time [5].
After the determination of the QRS durations, the fiducial points which show the location of R points were determined. The cardiac cycle (RR) intervals were obtained and hence the heart rate (HR) for each beat was calculated using the relationship:
The P-wave duration and the PR interval for each beat were also determined by scanning each beat waveform using a time window prior to each R point.
The current study's main objective is the extraction of primary features of the denoised and decomposed ECG signals. By extracting these primary features of ECG, it is feasible to obtain some fundamental parameters like the amplitudes of the waves and their durations, such as RR, QRS, and PR intervals which could be used for subsequent automatic analysis [7]. The proposed feature extraction algorithm was evaluated on MIT-BIH Arrhythmia database using Daubechies Wavelet Transform. Db4 wavelet was selected due to the similarity of its scaling function to the shape of the ECG signal. R peaks detection is the core of this algorithm's feature extraction because all other primary peaks are extracted with respect to the location of R peaks through creating windows proportional to their normal intervals [16]. Experimental results indicate that the algorithm can successfully detect and extract all the primary features with a deviation error of less than 10%. Table 1 lists the normal ECG wave amplitudes and durations.
Table 1. Normal ECG Wave Amplitudes and Durations
In simple terms, a neural network represents an interconnected group of artificial neurons. Artificial Neural Network (ANN) is generally called as neural network mathematically motivated by the biological neural network structures [1]. This paper describes the use of neural network in pattern recognition, uses the feature vector as the input units while the output units represent the pattern class which needs to be classified. For each input vector/feature vector given to the input layer, output of each unit is the corresponding element in the vector. Each unseen units calculates the weighted sum of its input to outline its scalar net activation. The product of input vector and weight matix at the unseen layer is generally called a net activation function based on features extracted (RR, PR intervals, and QRS duration) decision rules were formed [2]. In this algorithm, an average of 8 RR, PR intervals, and QRS width were taken. So intervals considered are averaged ones. Total of 6 decision rules are formed after profoundly studying many arrhythmias. Some of the arrhythmia classifying decision rules are given below.
Bradycardia is a condition in which the resting heart rate falls below 60 beats per minute. It is sometimes symptomatic to further fall in heart rate below 50 beats/min. Under this condition, enough oxygen is not pumped into heart and may sometimes results in fainting, shortness of breath, and if severe enough leads to mortality.
If heart rate computed is less than 60 beats per minute, then it is detected as bradycardia heart condition [20].
Tachycardia typically refers to a heart rate that exceeds the normal range for a resting heart rate (heart rate in an inactive or sleeping individual). In an adult if heart rate exceeds 110 beats/min, it is Tachycardia condition. It can be dangerous depending on the speed and type of rhythm.
If heart rate computed is more than 110, then it is detected tachycardia heart condition .
Using this decision rules, we can detect totally six Arrhythmias those are Bradycardia, Tachycardia, Ventricular Tachycardia, Asystole (Complete Heart Block), First Degree AV block, and Second Degree AV block.
Sixteen arrhythmia decision rules were developed after consultation with a group of cardiology specialists. The rules were applied to the features extracted from each ECG data files. There were two types of analysis applied, one is the beat analysis and second is the beat to beat analysis. In beat analysis, each beat was examined against standard values, whereas in the beat to beat analysis, the similarities in the beat morphology between adjacent beats were examined.
Some of the arrhythmia decision rules are explained in the equations (16) and (17).
Based on the decision rules, the arrhythmias were classified as Tachycardia (TA), Bradycardia (BR), Premature Ventricular contraction (PVC), Sick Sinus Syndrome (SSS), Premature Atrial Contraction (PAC), Wandering Pacemaker (WP), Complete Heart Block (CHB), First Degree Heart Block (FDHB), Bigeminy (BI), and Quadrigeminy (Q) [6].
The authors have evaluated the performance of the classification algorithms using six measures; specificity, sensitivity, classification accuracy, Positive Predictivity. These measures are defined using True Negative (TN), True Positive (TP), False Negative (FN), and False Positive (FP) [21] .
Both classifier and physician suggested the absence of arrhythmia.
Arrhythmia detection coincides with decision of physician
The system labels a healthy case as an arrhythmia one.
The system labels an arrhythmia as healthy.
Accuracy is the ratio of number of correctly classified cases, and is given by,
Total number of cases are N.
Sensitivity refers to the rate of correctly classified positive. Sensitivity may be referred as a True Positive Rate. Sensitivity should be high for a classifier.
Specificity refers to the rate of correctly classified negative and is equal to the ratio of TN to the sum of TN and FP. False Positive Rate equals (100-specificity).
Positive predictive shows probability that disease is present when test is positive, which is by how much amount disease is correctly predicted.
In this work, the original input signal (Actual Signal) taken from MIT-BIH database is shown in Figure 4, decomposed signal is shown in Figure 5, prepossessing stage using DWT and reconstructed signal is shown in Figure 6. Detection of R peaks shown in Figure 7. Figure 8 determines peaks and location of various ECG signal parameters in P Q R S T wave. Table 2 shows the types of Arrhythmia from MIT-BIH Database and Table 3 lists the QRS Detection Performance comparison for the proposed work. Further, RR interval, ST segment, PR interval, TT interval, etc., were calculated using the basic logic to find distance between occurrences of the required parameter. In Figure 9, detection of PQRS & T waves are depicted.
Table 2. Arrhythmia on MIT-BIH Database
Table 3. QRS Detection Performance Comparison on MIT-BIH Arrhythmia Database
By using DWT method, feature extraction and analysis of ECG signals was done. The ECG database helped to detect many arrhythmias and to increase accuracy of the algorithm. By using MATLAB based software, we could detect the above mentioned arrhythmias and at the same time analyse ECG signal in detail. The proposed algorithm achieved sensitivity of 97.12%, positive predicatively of 94.37%, and disease detection accuracy of 94.29%. The obtained results indicate that the proposed algorithm can support various types of arrhythmias detection in clinical tests.