ECG Abnormality Detection Algorithm

The monitoring and early detection of abnormalities in the cardiac cycle morphology have significant impact on the prevention of heart diseases and their associated complications. Electrocardiogram (ECG) is very effective in detecting irregularities of the heart muscle functionality. In this work, we investigate the detection of possible abnormalities in ECG signal and the identification of the corresponding heart disease in real-time using an efficient algorithm. The algorithm relies on cross-correlation theory to detect abnormalities in ECG signal. The algorithm incorporates two cross-correlations steps. The first step detects abnormality in a real-time ECG signal trace while the second step identifies the corresponding disease. The optimization of search-time is the main advantage of this algorithm.


INTRODUCTION
The leading cause for death worldwide is cardiovascular diseases [1]. According to the World Health Organization (WHO), cardiovascular diseases took more than 17.5 million lives in 2012 [2]. Heart attack, hypertension and arrhythmia are among the many heart conditions that fall under the umbrella of cardiovascular diseases [1]. The massive prevalence of heart diseases worldwide urges for novel health solutions. Among the prominent emerging solutions are non-invasive heart rate monitoring technologies and remote health monitoring systems (eHealth systems) [3], [4].
In medicine, Electrocardiogram is a tool used to describe the heart medical condition [5]. Electrocardiogram (ECG) employs multiple electrodes on the chest skin's surface to record the electrical charge resulting from the contraction and expansion of the heart muscle [1], [5], [6]. The analysis of ECG signal can differentiate normal heart beat from irregular one [5]. ECG signal for normal heart beat is uniform and consistent whereas abnormal heart beats have various shapes and forms and each ECG deviation from the normal one is associated with a specific cardiovascular disease [5], [6]. The problem is that standard, 5 to 10 minutes, ECG recording taken at the hospital while the patient is resting may not help the physician identify patient heart problem [1]. Furthermore, the standard procedure is more prone to human error and delayed diagnosis. Thus, a solution to this problem might be realized through the continuous monitoring of patient ECG recording. However, for this solution to be viable, an automated, simple and efficient heart's abnormalities detection algorithms must be implemented [3]. Those algorithms can be used extensively in eHealth systems and applications and ported to mobiles or sensors processing units [3]. Many ECG classification algorithms were implemented recently [7]. Saritha et al. have used wavelet transform analysis to analyze various cardiac disorders [6]. Furthermore, Rai et al. used artificial neural network classification algorithm to classify ECG signals into two classes: normal, and abnormal [5]. They used two sets of features namely a discrete wavelet transform features and morphological features [5]. They used MIT-BIT arrhythmia database to test their extracted features [5]. The best accuracy they reached was 100% with Multilayer Perceptron (MLP) [5]. Maheshwari et al. developed a novel algorithm to detect the fragmentation of QRS complex in an ECG signal [3]. To verify the validity of their developed algorithm they used PTB database from physioNet [3]. A sample of 31 patients' ECG traces were chosen from the database and annotated by two cardiologists [3]. The algorithm sensitivity was found to be 0.897 and its specificity was found to be 0.899 [3]. Oresk et al. developed a lightweight, real-time cardiovascular disease detection platform for mobiles [1]. The platform they developed employs existing portable ECG monitoring systems and improves it by adding valuable ECG analysis features [1]. They verified the accuracy of their platform using MIT-BIH database. Specifically, they used MLP ANN pattern recognition algorithm to classify ECG signals. They reached a classification accuracy of more than 90% for three abnormal beats. They were also able to identify normal ECG beat with an accuracy of 99% [1]. Shahanaz et al. have proposed a method based on signal processing and correlation technique to find out whether ECG signal is normal or abnormal [8].
In this paper, the proposed algorithm incorporates two cross-correlation steps. The first step is conducted between the real-time ECG signal and the normal stored typical cycle. The role of the first step is to detect abnormality in the real-time ECG signal. In case of abnormality detection, the correlation coefficient value computed in the previous step will be used to reduce the search domain for the second step. Particularly, the second cross-correlation will be carried out between the realtime ECG trace and a small subset of the stored diseases ECG traces. This will reduce the time required for disease detection.
The rest of the paper is organized as follows. Section II describes the proposed algorithm. In Section III, selected cardiac disease and their effect on ECG trace is illustrated. Experiment and simulation results are presented in Section IV. Section V concludes the paper and discusses possible future research directions. www.ijacsa.thesai.org

II. PROPOSED ALGORITHM
The proposed algorithm is illustrated in Fig. 1. The algorithm requires a database that can be modified and updated. This database stores a set of ECG time domain cycles corresponding to different cardiac diseases. In addition, normal cycle ECG signal is also stored to be used as a reference. The correlation coefficients between the normal cycle and the other abnormal cycles are computed and stored as predefined values. The algorithm then computes the instant cross-correlation coefficient between the instant measured ECG cycle and the normal reference cycle stored in the database. If the value of this coefficient is larger than specific threshold (ζ) (in this work the value of ζ is 0.95), then the real-time ECG trace is normal. Otherwise, a mismatch is detected, because the instant coefficient is less than the predefined threshold value (ζ =0.95). This indicates the presence of abnormality in the instant ECG trace.
In case of an abnormality, a second cross-correlation is carried out between the instant ECG trace and a subset of stored diseases ECG traces. The subsets of stored diseases ECG traces have predefined corresponding correlation coefficients close to the instant computed coefficient value by ±5%. The resulting correlation coefficient in the second step will identify the cardiac disease.
In other words, the instantaneous ECG trace will corresponds to the disease with the largest cross-correlation coefficient value. This procedure reduces the search-time for the corresponding heart abnormality. Particularly, instead of performing the cross-correlation between the instant ECG signal and the whole set of stored abnormal ECG signals; the correlation will only be performed between the instant ECG cycle and a subset of signals corresponding to different cardiac diseases.

III. SELECTED ECG ABNORMALITY CASES
Fig. 2 depicts 7 ECG traces corresponding to well-known heart disease problems. In the following lines, a detailed description of each disease and its effect on the ECG signal will be outlined. The normal ECG signal typical cycle is denoted in Fig. 2(a). Normal ECG signal consists of 6 intervals namely P, Q, R, S, T and U. Each interval represents an electrical incidence during one cardiac cycle. Impulse P is the first short rising of the ECG signal. It implies that the atria are contracting, forcing blood to move into the ventricles. The QRS complex consists of the Q impulse which is downward wave followed by a huge upward wave, namely, R. Then followed by downward wave that is S. The ventricular depolarization and contraction correspond to the QRS complex in the ECG signal. The PR period denotes the transfer time required for the electrical wave to move from the sinus node to the ventricles. Wave T, a small rising of the ECG signal, is signifying ventricular repolarization. Theoretically, the U impulse appears as a result of the repolarization of the interventricular septum. This wave usually has small amplitude, and in most cases, it is entirely absent.
In Fig. 2(b), the ECG signal for a patient with Ischemia is presented. This disease is characterized by inadequate blood and oxygen supply to body organs or more specifically to the heart muscle [9]. The ECG signal for a patient with this disease is distinguished by ST interval disappearance and or downward T wave. The ECG signal for a patient with Injury is depicted in Fig. 2(c).This heart illness is the direct result of having ischemia for a long period of time, which results in the starvation of certain heart tissues for blood and oxygen [9]. The ECG signal for a patient with this disease is distinguished by ST rising. Shown in Fig. 2(d), the ECG signal for a patient with Infraction. Infraction is the death of certain heart tissues as a result of having prolonged Injury [9]. The ECG signal for a patient with this disease is distinguished by the deep Q wave or www.ijacsa.thesai.org the deformed QRS complex [3], [10]. Hypokalemia signifies a low level of potassium in the blood as a result of a certain deficiency [11]. The ECG signal for a patient with this disease (represented in Fig. 2(e)) is distinguished by ST interval disappearance, flat T wave, and appearance of U wave. The ECG signal for a patient with Hypocalcemia is depicted in Fig. 2(f). Hypocalcemia represents a low level of calcium in the blood as a result of deficiency [11]. The ECG signal for a patient with this disease is distinguished by a slender QRS complex, decreased PR segment, and extended ST segment, flattened T wave and noticeable U wave. In Fig. 2(g), the ECG signal for a patient with Hyperkalemia is presented. Hyperkalemia represents a high level of potassium in the blood as a result of deficiency [11]. The ECG signal for a patient with this disease is distinguished by widespread and short amplitude P wave, broad QRS wave, blending of QRS wave with T wave, disappearance of the ST section and elevated slanted T wave. Hypercalcemia ECG signal is presented in Fig. 2(h). Hypercalcemia signifies a high level of calcium in the blood as a result of a deficiency [11].The ECG signal for a patient with this disease is distinguished by T wave with a wide base and elevated peak.  Fig. 3(a) represents the computed correlation coefficients (ρ) between the normal ECG signal presented in Fig. 2(a) and the other abnormal ECG signals presented in Fig. 2(b) to (h). In Fig. 3(a), the first bar represents the correlation between the normal ECG signal and itself which is typically equals 1. The second bar in Fig. 3(a) represents the cross-correlation coefficient between the normal ECG signal and the ECG signal for a patient with Ischemia and so on. If the signals are identical to each other the coefficient of correlation is unity, and if they are different from each other the coefficient of correlation is a finite number whose value comes between +1 and −1 inclusive, where 1 represents the total positive correlation, 0 is no correlation and −1 represents total negative correlation [12]. The cross-correlation coefficients presented in Fig. 3 represents a very useful information. They will give us a primary indication of the disease the patient might have. Therefore, these cross-correlation coefficients are saved in the database.
The algorithm usually computes the instant crosscorrelation coefficient between the instant measured ECG cycle and the normal reference cycle stored in the database. If the instant coefficient value is greater than or equal 0.95, the real-time ECG trace is normal and the algorithm will continue monitoring the real-time ECG trace. Otherwise, abnormity is detected and the algorithm will fetch ECG trace for diseases with coefficient value 5%± the instant coefficient. For instance, if the instant coefficient= 0.52 then ECG trace for infarction (ρ = 0.56), hypokalemia (ρ = 0.54), and hyperkalemia (ρ = 0.51) will be fetched from the database. The second cross-correlation step will be performed between the real-time ECG trace and those three diseases only; this will reduce the search time considerably. The proposed second correlation process between the instant ECG cycle and these three signals at this stage will reveal the identity of the disease. In other words, the instant ECG trace corresponds to the disease whose second cross-correlation coefficient is the largest. In this example, the second cross-correlation coefficient (ρ2) between instant ECG trace and infarction, hypokalemia, and hyperkalemia equals ρ2= 0.31, ρ2= -0.08, and ρ2= 0.97, respectively. Consequently, the instant ECG trace corresponds to a patient with hyperkalemia.

IV. EXPERIMENTAL VALIDATION
To validate the proposed approach, the experimental setup shown in Fig. 4 has been utilized. An ECG synthesizer has been constructed. The synthesizer incorporates waveform generator that can be controlled through a software code. The ECG normal cycles were imported through the software code from excel files. Then, the software sends the ECG cycles to the function generator to be repeated continuously. An oscilloscope has been used to display and check the function generator output. The correlation process has been implemented in android tablet application to remotely display the signal and identify any abnormality. The transmission of the instant ECG signal has been carried out via Bluetooth connectivity.
The ECG signals for the seven selected diseases (described in Section IV) have been used for simulation; the detection accuracy was 100%. As expected, in the case of the three mentioned diseases (infarction, hypokalemia, and hyperkalemia) that have close correlation coefficient values, a second correlation process was requested. The second correlation process successfully discriminated each of them with 100% detection accuracy. The incorporation of the second correlation step has been expedited by 40% in each of the seven cases. Assuming the number of stored diseases is 1,000 and 20 out of them were having close predefined correlation values; the speed of the current detection algorithm will then be reduced by 98%. In summary, a modified correlation based method to detect abnormality in ECG trace has been presented and validated. The proposed algorithm for detecting abnormalities reduces the processing time greatly and the processing power considerably with 100% accuracy.

V. CONCLUSIONS
Naturally, the continuous monitoring of ECG signals will produce large amount of data. Handling this data will require high-performance hardware and software, which will lead to huge energy consumption. Thus, to deal with this issue efficiently, by minimizing resources usage such as the energy and the processing time, an innovative alternative solution should be employed. The deployment of our proposed algorithm will lead to huge reduction in processing time. This processing time reduction stems from the fact that our proposed algorithm compares between numeric values instead of comparing ECG waveforms using image-processing techniques.
This paper addressed the design and implementation of an efficient algorithm. The algorithm detects abnormalities in ECG signal on real-time by utilizing cross-correlation theory. The proposed algorithm for detecting abnormalities reduces the processing time hugely and the processing power considerably.