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.


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 erraticallycausing 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   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.

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 Physio.netdatabase 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  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.

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].

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

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  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.

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: ( ) ( ) ( )( ) 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.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.

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.

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  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.

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

S. Savalia et al. Journal of Biosciences and Medicines
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.

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.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.

Conclusion
This algorithm proposed here was tested on MIT/BIH Normal Sinus Database and MIT/BIH Arrythmia Database obtained from Physio.netATM.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
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 S. Savalia et al.DOI: 10.4236/jbm.2017.51100868 Journal of Biosciences and Medicines
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.

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 (Figure8).

Figure 8 .
Figure 8. Confusion matrix of neural network.

Figure 10
Figure10contains 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, Figure11shows the signal after removal of all types of noises,

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

Table 2 .
Results of features extracted for different patient's ECG and the diseases detected.In addition, the heart rate was calculated to detect diseases like Tachycardia and Bradycardia.The only ECG signal that the algorithm failed to detect