Classification of Cardiovascular Disease Using Feature Extraction and Artificial Neural Networks


Electrocardiogram (ECG) signals are used to identify cardiovascular disease. The availability of signal processing and neural networks techniques for processing ECG signals has inspired us to do research that consists of extracting features of an ECG signals to identify types of cardiovascular diseases. We distinguish between normal and abnormal ECG data using signal processing and neural networks toolboxes in Matlab. Data, which are downloaded from an ECG database, Physiobank, are used for training and testing the neural network. To distinguish normal and abnormal ECG with the significant accuracy, pattern recognition tools with NN is used. Feature Extraction method is also used to identify specific heart diseases. The diseases that were identified include Tachycardia, Bradycardia, first-degree Atrioventricular (AV), and second-degree Atrioventricular. Since ECG signals are very noisy, signal processing techniques are applied to remove the noise contamination. The heart rate of each signal is calculated by finding the distance between R-R intervals of the signal. The QRS complex is also used to detect Atrioventricular blocks. The algorithm successfully distinguished between normal and abnormal data as well as identifying the type of disease.

Share and Cite:

Savalia, S. , Acosta, E. and Emamian, V. (2017) Classification of Cardiovascular Disease Using Feature Extraction and Artificial Neural Networks. Journal of Biosciences and Medicines, 5, 64-79. doi: 10.4236/jbm.2017.511008.

1. Introduction

An electrocardiogram (ECG) is a measure of how the electrical activity of the heart varies with respect to time as action potentials propagate throughout the heart during cardiovascular cycles [1] . As heart beats, membrane polarity variations in the electrical conduction system throughout the heart result in the depolarization and repolarization of the ventricular and atrial cardiovascular cells, triggering them to contract and relax. This causes the chambers to pump blood throughout the body [2] . The contraction (depolarization) and relaxation (repolarization) can be monitored using electrodes placed in different combinations and configurations on the chest and limbs to collect a series of ECG complexes. An ECG complex is comprised of various components, or waves, that represent the electrical activity in specific regions of the heart [2] .

By studying ECG signals, doctors can find out whether a patient has a heart condition. ECG signals are made up of several segment and intervals (Figure 1). We use these segments to find abnormalities to detect heart diseases. Abnormal ECG signals are also called arrhythmia and it occurs when segments and intervals of ECG signals have irregularities. Every ECG signal is made up of QRS complex, P waves, and T waves. These are important in identifying heart diseases [3] . If they are present in the ECG signal, then it should be within certain minimum and maximum range. Failure in reaching the minimum value and exceeding the maximum value as well as absence of any waves will yield the type of heart disease [4] . Feature extraction through accurate wave detection is crucial in measuring the heart rate and finding any suspicion of diseases related to arrhythmias such as Tachycardia and Bradycardia. Even though ECG signals are not easy to classify due to its time varying nature, this research implements an effective algorithm to detect R peaks and extract the most important features of an ECG signal [3] .

Arrhythmia refers to any change from the normal sequence of electrical impulses. The electrical impulses may happen too fast, too slowly, or erratically― causing an abnormal heartbeat. When the heart doesn’t beat properly, it can’t pump blood effectively which causes the lungs, brain and all other organs to shut down or be damaged. Two types of Arrhythmia are Tachycardia (Figure 2) and Bradycardia (Figure 3). Tachycardia means the heart rate is above 100 beats per

Figure 1. Detailed normal ECG signal.

Figure 2. Tachycardia.

Figure 3. Bradycardia.

minute (BPM) in adults. This occurs when the electric signals in the heart’s upper chambers fire abnormally [4] .

The rapid heartbeat causes the body to be compromised because it does not allow enough time for the blood to flow to the rest of the body. Bradycardia means that the heart rate is less than 60 beats per minute. Athletes often have a resting heart rate slower than 60 BPM but that is normal for them. Elderly people are more prone to problems with a slow heart rate. A slow heart beat may cause insufficient blood flow to the brain with symptoms such as dizziness or lightheadedness [4] .

Atrioventricular block (AV block, Figure 4 and Figure 5) is a partial or complete interruption of impulse transmission from the atria to the ventricles. A first-degree AV block has a PR interval longer than normal, typically greater than 0.20 sec. A second-degree AV block has the PR interval progressively lengthen with each beat until the atrial impulse is conducted and the QRS complex is dropped [4] .

This paper describes a robust and an effective algorithm, that is used to extracts all main features of ECG signal and based on that features our algorithm provides an effective way to detects the cardiovascular diseases like tachycardia, bradycardia, First Degree AV Block, Second Degree AV Block.

2. Methodology

The signals that we used for feature extraction is obtained from Physiobank ATM are named as MIT-BIH Arrythmia database which has sampling frequency of 360 Hz and other is MIT-BIH normal sinus database has a sampling frequency of 128 Hz [4] . The raw signals were obtained in the database is consisting of noises, which may cause problem while extracting the different features of ECG [5] . Therefore, the signals are filtered before feature extraction to eliminate the possibility of wrong feature extraction of signal. Neural network is used to classify whether the ECG signal is normal or abnormal, where we used 70% of data for the training and rest 30% data was used for the validation and

Figure 4. First degree AV block.

Figure 5. Second degree AV block.

training purpose [5] . If arrhythmia is detected, signal processing is applied to remove the noisy components such as Baseline noise and power interference noise of ECG signals. After effectively removing all types of noises, the signals are ready to be processed for feature extraction. We used state-machine algorithm to detect the R peaks, where windowed size filter and threshold filter was used to find the R peaks of signal. Based on R peaks, all other features have been extracted using buffer values with different sizes for every wave. In next step, results of those feature extraction are used to calculate the heart-beats per minute and then we move on to find the duration of QRS complex [5] . After detection of different features of algorithm, our algorithm progress to identify what type of disease the signal represents. The system runs on Matlab and consists of components shown in Figure 6.

3. ECG Data

Normal and abnormal ECG data is acquired from Physiobank database. Data is downloaded from the Normal Sinus Rhythm database (NSR-DB) and MIT/BIH Arrhythmia database [6] . The NSR-DB contains 18 records of subjects without diagnosed cardiovascular abnormalities. Each record is 24 hours in length. The sampling rate is 128 Hz. The Arrhythmia database has 48 records with each record being 24 hours in length. The sampling rate is 360 Hz. For our research, we used 10 seconds of each record for both normal and abnormal datasets [6] .

4. Neural Networks

The classification process includes using artificial neural network (ANN), a paradigm that is related to biological networks and tries to mimic the structure of the human brain. One of the most important properties of neural networks is their ability to learn from examples (training sets). ANN can learn to produce a certain output when presented with a certain input [7] . The learning process involves modification of the parameters in the net, the connection weights, to make its overall behavior correspond to a desired behavior defined by a set of training examples. Each example in the training set consists of an input pattern

Figure 6. System process flow chart.

and a desired output pattern. To train the network, an example from the training set is fed into the network to see the output it produces [7] . If the output is not what is expected, the weights of the network are adjusted according to the training algorithm to minimize the difference between the desired and actual output. The training is then continued with another example until the network has reached steady state and there were no more changes to the weights are made and the system produces correct outputs.

ANN is organized in layers as seen in Figure 7. Each connection represents a weight which refers to the strength of a connection between two nodes. There is another input in the hidden layer known as a bias. The bias is much like a weight, except that it has a constant input of 1 [7] . Layers are made up of many interconnected nodes which contain an activation function. Within the hidden layer node is a sigmoidal function which polarizes network activity and helps it to stabilize. The softmax function is implemented in the final layer of the network used for classification. The node at the output produces a value of 0 and 1 which correspond to the normal and abnormal heartbeat. The learning rule used in the ANN is backpropagation (BP) [8] . The BP algorithm is used for the training procedure in two phases. First, the inputs are presented to the network, which propagate forward to produce the output for each neuron, y j ( t ) , in the output layer. The activity of each neuron is determined, y j = f ( z j ) , where is the sigmoid activation function and α, β are constants. Then the error signal is generated:

e j ( t ) = f j ( t ) y j (t)

where d j ( t ) is the desired output for neuron j at the iteration. The BP algorithm changes the weight vector, ω, of ANN to minimize the error function, ζ, defined by

Figure 7. Twelve layer neural network.

ζ t = 1 2 C j e 2 (t)

where the C includes all neurons in the output layer. The correction Ñω applied to ω is defined by,

ω = β ξ ω

Training of the ANN is based on an adaptive algorithm with the parameter β changing. If in ξ ω = 0 , a minimum has been reached.

5. Automatic Classification

As described in previous section, we used ANN to classify whether the ECG signal was normal or abnormal. The normal and abnormal ECG signals are fed to the input of the ANN [9] . The output is defined by 0’s and 1’s so the network understands that the normal data corresponds with 0 while the abnormal data with 1. The data used for classification is divided into 70% training, 15% validation, and 15% testing. Learning takes place during the training [9] [10] . Validation is used to measure network generalization and to halt training when it stops improving. Testing is when the neural network is presented with a dataset that it has not seen before and produces an output. The results obtained correspond to the testing portion of the neural network to see its predictive power (Figure 8).

Figure 8. Confusion matrix of neural network.

In Figure 8, the confusion matrix gives us combined data for training, validation, and testing. The network outputs are very accurate, as you can see by the high number of correct responses in the green squares and the low number of incorrect responses in the red square [10] . The lower right blue squares illustrate the overall accuracies. This means the accuracy for predicting normal and abnormal data is at 82.5%.

In Figure 9, the colored lines in each axis represent the ROC curves. The ROC curve is a plot of the true positive rate versus the false positive rate as the threshold is varied [10] . A good test would show points in the upper-left corner, with 82.5% sensitivity and 82.5% specificity. In the above Figure 9 we have a good test due to the points being in the upper left corner.

6. Signal Processing

The Fast Fourier Transform (FFT) computes the discrete Fourier transform (DFT) of a sequence. It has many applications in signal processing because it can convert a signal from its time domain to the frequency domain and vice versa [10] .

The FFT and inverse Fourier transform (IFFT) equations implemented are as follows:

Y ( k ) = j = 1 n X ( j ) W n ( j 1 ) ( k 1 )

X ( j ) = 1 n k = 1 n Y ( k ) W n ( j 1 ) ( k 1 )

where W n = e 2 π i n is one of n roots of unity.

The signal is represented by X ( j ) , so the first equation is used to compute the sequence Y ( k ) of complex-valued numbers given another sequence of

Figure 9. Receiver Operating Characteristic (ROC).

data X ( j ) of length n. FFT is used in the algorithm to filter ECG signal [10] . FFT converts time domain vector signal to the frequency domain vector signal; while, IFFT converts frequency domain vector signal to time domain vector signal.

To find what specific disease the abnormal data contained, we used signal processing to identify certain features in the ECG signal. These features consisted of the different types of peaks in the signal such as QRS, P, and T peaks [10] . The first step is to remove the lower frequency components. We apply FFT to ECG signal to change from time domain, to the frequency domain. To remove the lower frequency components from Fourier transform values of ECG data, we set frequency components from beginning and end of data to zero [10] . We then apply the Inverse Fourier transform [IFFT] to signal to reconstruct ECG signal with removed lower frequency components.

Once lower frequency components are removed from ECG signal, the algorithm detects all different types of peaks which include R-peaks and QRS complex. Once we detect all the peaks, we find the duration of QRS segment and duration of R-R interval [10] . Duration of those intervals helps us to detect the heart rate and certain heart diseases like Bradycardia, Tachycardia, First and Second Degree Atrioventricular [AV] Blocks. Figure 10 and Figure 11 show the raw ECG signal and the signal with lower frequency components removed.

Figure 10. Raw ECG signal.

Figure 11. Lower frequency components removed.

Figure 10 contains the noise in form of lower frequency components which makes signal to vary by large amplitude at the bottom part of the signal. On the other hand, Figure 11 shows the signal after removal of all types of noises, mainly lower frequency components by applying the FFT and IFFT to the signal. Once the noise is removed, the algorithm will detect the main features of the ECG signal accurately.

7. R-Peak Detection

To find the R-peak, we used a threshold filter and window size filter tool of Matlab. After removing noise by FFT, our second step is to find the local maxima to detect the R-peaks of the data [11] . We use a window filter that detects only maximum values in the window size, and ignores all other values which are not important in detecting peaks. Next, we remove small values and keep significant values of data which helps us to detect R-peaks. To do that we used threshold filter in our algorithm [11] .

We defined the conditions that if the value of the peak is greater than 4, peak was detected. If it is less than 4, a peak was not detected. This helps us detect the peaks in the ECG signal. To ensure that R-peaks are detected for any ECG signal, we adjusted the size of the window filter for optimization and repeated the filtering process. This method was applied on 66 ECG signals obtained from Physiobank and it could detect all the peaks [11] . Figure 12 shows the filtered ECG signal and Figure 13 shows the R-peaks detected on the signal.

8. Heart-Beat Calculation

After detecting R-peaks of the ECG signal, the next step was to find the heart rate by using the distance between R-R interval of signal. First, we find the total

Figure 12. Raw ECG signal.

Figure 13. R-Peak detection of ECG signal.

distance between the first and last peaks of the signal. We then find the average distance between the peaks by dividing total distance between the first and last peaks by total number of R-Peaks of ECG signal. The heart rate can be calculated by dividing the product of 60 (Number of seconds in 1 minute) and sampling frequency by the average distance between the peaks [11] . The heart rate helps us define certain conditions for detecting diseases such as Bradycardia and Tachycardia.

9. Various Feature Extraction of ECG Signal

To detect the Q, S and T points we used the state-machine logic algorithm to determine different peaks in ECG based on averaging and adaptive thresholds which has fluctuating characteristics in respect to the noise and the signal. For finding these points, first we define the two buffers, one is to find the threshold mean of the ECG signal and the other is to detect the T points of the signal [11] . As we progress further in the algorithm we start the online interference in which it saves the upcoming new samples and baseline samples. It will renew the value of the mean in the buffer and adapt it to the main signal after 1 second of processing, and it will smooth the signal by taking the average of 15 samples and add the new upcoming samples in it. The algorithm will progress to state 1 where we detect the R-peaks of signals, for that we find the highest local maxima of the stored buffer values [11] .

The algorithm will move to state 2 where it will detect the Q point of the ECG signal. In addition, we have used the buffer value to check when the slope of the ECG signal changes before the R-peak to find the Q-points. In state 3, the S-point is detected using the same method as detecting the Q point but the buffer values check when the ECG signal changes in slope after the R-peak [12] . The point is saved in another buffer. That’s the point where our S-point of ECG signal lies. To verify both Q and S points locations we set the counter in our algorithm to verify if it’s a change in slope or if just due to the noise in the signal.

After detecting the main features of ECG, the algorithm will progress to state 4 to find if the T points are present in the ECG signal. We define one counter that will exit the state if no T wave is detected after 0.3 seconds of the signal. If a T wave is present in the signal, then a double threshold is set based on the last detected S wave and baseline of the signal. A T wave is detected in between these two thresholds. To verify it again, the counter is set to distinguish if the signal has a change in slope or it is due to noise in the signal [12] . At the end of the algorithm, we set another state to 5 which helps avoid the detection of highly variable noise or another peak of the signal. We used all the values of Q, R, S and T points and its amplitude to plot those on the main ECG signal. Figure 14 shows the result of all Q, R, S and T points detected successfully on ECG signal.

10. Detection of Various Diseases from ECG Signal

In this research, we could detect the four types of diseases Tachycardia, Bradycardia, first-degree Atrioventricular (AV), and second-degree Atrioventricular. If the person has bradycardia, which means the person’s heart beat is slower than normal which would be below 60 BPM [12] . For most people, a normal heart rate is in the range of 60 to 100 BPM while at rest. For some people, a slow heart rate does not cause any problems. It can be a sign of being physically fit. Healthy young adults and athletes often have heart rates of less than 60 beats a minute.

Figure 14. Q, R, S and T detection.

When electrical signals in the heart’s upper chambers fire abnormally, which interferes with electrical signals coming from the sinoatrial (SA) node [the heart’s natural pacemaker], a series of early beats in the atria speeds up the heart rate [12] .

The rapid heartbeat does not allow enough time for the heart to fill before it contracts so blood flow to the rest of the body is compromised, that is how the tachycardia occurs in the heart. First-degree atrioventricular block or PR prolongation, is a disease of the electrical conduction system of the heart in which the QRS complex interval falls below 0.1 seconds. If first degree AV block occurs, it means that conducting from atria to ventricles through the atrioventricular node is delayed and flows much slower than the normal one. The drugs that most commonly cause first-degree heart block are those that increase the refractory time of the AV node, thereby slowing AV conduction. The presence of second-degree AV block is diagnosed when one or more of the atrial impulses fail to conduct to the ventricles due to impaired conduction [12] . Second degree atrioventricular block, is a disease of the electrical conduction system of the heart in which the QRS complex interval falls between 0.1 and 0.2 seconds. Table 1 shows the Characteristics features of different cardiovascular diseases like Bradycardia, Tachycardia, First and Second degree of AV block [13] .

For detecting Tachycardia and Bradycardia, the heart rate is used to identify them. When detecting first-degree Atrioventricular and second-degree Atrioventricular we used the duration of QRS complex. For detecting the duration of QRS complex, first we detect the Q and S points of ECG signal, then by using those points we detects distance between all QS points which gives us the duration of QRS complex of ECG signal. Table 2 shows the result of features extracted for different patient’s ECG and the diseases detected.

11. Conclusion

This algorithm proposed here was tested on MIT/BIH Normal Sinus Database and MIT/BIH Arrythmia Database obtained from ATM. In total, we tested our algorithm on a total of 66 ECG signals obtained from patients for medical research purpose. The algorithm could distinguish 86% of Normal and Arrhythmia data successfully by using neural networks to classify the signals. The algorithm succeeded in detecting important peaks and waves, including the duration of QRS complex, R-R interval, and S-T interval. The duration of the QRS complex is used to detect first degree and second degree Atrioventricular

Table 1. Disease characteristics.

Table 2. Results of features extracted for different patient’s ECG and the diseases detected.

block. In addition, the heart rate was calculated to detect diseases like Tachycardia and Bradycardia. The only ECG signal that the algorithm failed to detect features in was Abnormal 5’s ECG. Our algorithm was unable to detect Q and S points on that signal, however, in this case the signal was extremely distorted.

Conflicts of Interest

The authors declare no conflicts of interest.


[1] Gilat, A. (2005) MATLAB—An Introduction with Applications. Wiley and Sons Publications INC, Hoboken.
[2] Resources for Types of Arrythmia Diseases.
[3] Ayub, S. and Saini, J.P. (2011) ECG Classification and Abnormality Detection Using Cascade Forward Neural Network. International Journal of Engineering, Science and Technology, 3, 41-46.
[4] Online Resources for ECG Signals.
[5] Massachusetts Institute of Technology, MIT-BIH Normal Sinus and Ar-rhythmia Database.
[6] Jen, K.-K. and Hwang, Y.-R. (2008) ECG Feature Extraction and Classification using Capstrum and Neural Networks. Journal of Medical and Bioligical Engineering, 28, 31-37.
[7] Coast, A.D., Stern, R.M., Cano, G.G. and Briller, S.A. (1990) An Approach to Cardiovascular Arrhythmia Analysis Using Hidden Markov Models. IEEE Transactions on Biomedical Engineering, 37, 826-835.
[8] Sultana, N., Kamatham, Y. and Kinnara, B. (2016) Performance Analysis of Artificial Neural Networks for Cardiac Arrhythmia Detection. IEEE 6th International Conference on Advance Computing (IACC), 27-28 February 2016, 421-425.
[9] Sadaphule, M.M., Mule, S.B. and Rajankar, S.O. (2012) ECG Analysis Using Wavelet Transform and Neural Network. International Journal of Engineering Inventions, 1, No. 12.
[10] Sedghamiz, H. (2014) Matlab Implementation of a Simple Real Time QRS and T Wave Detector. September.
[11] Singh, G.K., Sharma, A. and Velusami, S. (2009) A Research Review on Analysis and Interpretation of Arrhythmias Using ECG Signals. IJMST, 2, 37-55.
[12] Talmon, J.L. (1983) Pattern Recognition of the ECG. Akademisch Proefscrift, Berlin.
[13] Stamkopulos, T., Strintzis, M., Pappas, C. and Maglaveras, N. (1992) One Lead Ischemia Detection Using a New Backpropagation Algorithm and the European ST-T Database. IEEE Proceedings of Computers in Cardiology, 11-14 October 1992, 663-666.

Copyright © 2024 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.