Identification of Premature Ventricular Contraction ( PVC ) Caused by Disturbances in Calcium and Potassium Ion Concentrations Using Artificial Neural Networks

Abnormalities in the concentrations of metallic ions such as calcium and potassium can, in principle, lead to cardiac arrhythmias. Unbalance of these ions can alter the electrocardiogram (ECG) signal. Changes in the morphology of the ECG signal can occur due to changes in potassium concentration, and shortening or extension of this signal can occur due to calcium excess or deficiency, respectively. The diagnosis of these disorders can be complicated, making the modeling of such a system complex. In the present work an artificial neural network (ANN) is proposed as a model for pattern recognition of the ECG signal. The procedure can be, in principle, used to identify changes in the morphology of the ECG signal due to alterations in calcium and potassium concentrations. An arrhythmia database of a widely used experimental data was considered to simulate different ECG signals and also for training and validation of the methodology. The proposed approach can recognize premature ventricular contractions (PVC) arrhythmias, and tests were performed in a group of 47 individuals, showing significant quantitative results, on average, with 94% of confidence. The model was also able to detect ions changes and showed qualitative indications of what ion is affecting the ECG. These results indicate that the method can be efficiently applied to detect arrhythmias as well as to identify ions that may contribute to the development of cardiac arrhythmias. Accordingly, the actual approach might be used as an alternative tool for complex studies involving modifications in the morphology of the ECG signal associated with ionic changes. Corresponding author. J. C. D. Conway et al.


Introduction
Cardiovascular diseases (CVD) can be considered as one of the most important causes of death in many countries.Recent statistics estimate that about 80 million Americans age 20 and older (1 in 3) have 1 or more types of CVD.Although there was a decrease in heart disease and stroke mortality, the burden of disease remains high [1].Cardiac arrhythmias are a common type of CVD that can affect the heart rate causing irregular rhythms.In general, arrhythmias can be originated by abnormal rhythm of the heart pacemaker, displacement of the pacemaker from the sinus node for other areas of the heart and obstruction of the electric impulse from the sinus node.Similarly, arrhythmias can be also originated from unbalances in concentrations of major ions, such as calcium and potassium [2].In general, these types of arrhythmias may not have serious consequences but in some circumstances can, in principle, lead to stroke or death [3].A common form of arrhythmia in adults is premature ventricular contractions (PVC) that are ectopic heart beats originated in the ventricles.In association with other cardiac diseases, PVC can contribute to increased mortality [3].Thus, the electrocardiogram (ECG) monitoring is one of the most important apparatus of cardiologists in detection of heart diseases and specifically in the arrhythmia detection.In this sense, ECG beat classification is an essential tool for diagnosis [4].
Arrhythmia detection and classification can be performed by analyzing the ECG.Normally, this analysis does not provide information about ionic activities of the heart.However, abnormalities in concentrations of some ions, such as calcium and potassium, can lead to severe symptoms and life-threatening arrhythmia [2].Therefore, the development of reliable methodologies capable of detecting and classifying arrhythmias and furthermore providing indications of the influence of disturbances in the ions concentrations such as calcium and potassium seems to be important.All these contributions for rapid analysis can help cardiologists in the formulation of more accurate diagnosis and can save lives.
Several studies and methodologies addressing the problem of modeling, detecting and classifying arrhythmias have been developed across the years [5]- [9].Cabello, Barro, Salceda, Ruiz and Mira [6] studied classifiers in the detection of ventricular arrhythmias in ECG traces using principal component analysis (PCA).Chen, Clarkson and Fan [9] described a robust algorithm that provides a measure of the variability of the heart rate with respect to the blanking interval of the ECG, for the discrimination of ventricular fibrillation from ventricular tachycardia.Igel and Wilkoff [5] developed an algorithm that helps classify arrhythmias without marking individual ECG events, improving arrhythmia detection and accuracy.Owis et al. [8] proposed a methodology based on nonlinear dynamics of the ECG signals for arrhythmia characterization, using correlation dimension and Lyapunov exponent to model five different classes of ECG signals.Polat and Günes [7] used PCA to extract the main features of the ECG and least square support vector machine (LS-SVM) to classify arrhythmias from ECG recordings.
In recent years, intelligent systems have been applied in science and engineering, especially in the diagnosis of diseases.Among these intelligent systems, artificial neural networks (ANN) have been widely used.Khare et al. [10] investigated the performance of ANN methods for classification of five mental tasks.In [11] a study was conducted to determine the accuracy of using Ultrasound (US) estimation of twin fetuses by use of an ANN.A study investigating the use of forearm surface electromyography (sEMG) signals for classification of several movements of the arm was carried out using an ANN to process signal features to recognize performed movements [12].Particularly, artificial neural networks (ANNs) have also been used in ECG beat classification and arrhythmia detection.For example, Engin [13] used fuzzy-hybrid neural network for ECG beat classification.Zhou [14] addressed the problem of automatically detects PVC arrhythmia using quantum neural network and also has presented, along with Li [15], a learning approach based on an ANN applied to heart arrhythmia classification.Similarly, Übeyli [16] used the ANN approach for classification of ECG beats.Lin et al. [17] proposed a methodology for ECG beat detection and recognition using adaptive wavelet network (AWN).In the latter methodology, wavelets were used to enhance the features from each beat and a probabilistic neural network (PNN) was applied to carry out recognition tasks.Gothwal et al. [18] presented a method to analyze the electro-cardiogram (ECG) signal, extract its features, for the classification of heart beats according to different arrhythmias.
The studies mentioned above have applied different techniques, such as time and frequency domain analysis, PCA, sequential detection algorithm, wavelet analysis and non-linear dynamical modeling to extract ECG features used for arrhythmia detection and/or classification.However, they did not identify ECG changes caused by abnormalities due to ions concentrations.In order to fill this gap, in this paper we developed a methodology capable of detecting changes in the ECG morphology.Thus, it is possible to classify normal or PVC beats based on ECG pattern recognition.This task was implemented through an ANN.In addition, algorithms were proposed to indicate if the analyzed ECG record has modifications that may be caused by abnormalities in the concentrations of calcium and potassium ions such as hyperkalemia, hypokalemia, hyperkalcemia and hypocalcemia.The latter provides an alternative to a noninvasive procedure to better characterize the ionic unbalance that can affect the morphology of ECG.The ANN training procedure was performed using patients' data from MIT/BIH Arrhythmia Database [19].The efficiency of the present approach was analyzed using data not present in the training step, also from [19].

Fundamentals of ECG
The ECG is the record of the electrical activity of the heart and consists of the P, Q, R, S, T and U waves. Figure 1 shows a basic cardiac cycle.These waves are continuously generated inside the cardiac muscle due to the differences of potential in membranes of heart cells, caused by diffusion of ions, such as calcium, potassium, sodium and magnesium.A normal sinus rhythm has the following characteristics: each P wave is followed by a Q, R and S waves (known as QRS complex).P wave rate ranges from 60 to 100 bpm (beats per minute) with maximum 10% variation.A rate less than 60 bpm is classified as sinus bradycardia and a rate greater than 100 as sinus tachycardia.A variation above 10% is considered as a sinus arrhythmia [2].Arrhythmias are irregular heartbeats and can be caused by diseases of the cardiac muscle, but can also be originated by abnormalities in the concentrations of ions inside the cardiac cells [2].The ECG signal can be captured through electrodes placed under the skin and its analysis is fundamental to detect heart diseases, particularly arrhythmias.In this sense, the development of methodologies capable of automatically detecting and classifying arrhythmias as well as indicating abnormalities in ions concentrations can be a valuable tool to improve the quality of the diagnosis.

Metallic Ions and Arrhythmias
As aforementioned, alterations in concentrations of metallic ions transported through the cellular membrane of cardiac cells can affect the ECG.For example, alterations in plasma potassium levels can affect cardiac cell conduction and may lead to marked changes in the ECG signal.As shown in Figure 2, hypokalemia is characterized by a potassium plasma concentration below 2.8 mEq/L [20] and can affect the ECG signal mainly reducing the T wave and increasing the U wave.Hyperkalemia is characterized by a potassium plasma concentration above 6.5 mEq/L [20] and can lead to a peaked T wave and with extremely high plasma potassium levels can produce a "sine-wave" appearance on the ECG [2].
Calcium is another ion that can affect the ECG signal, mainly the QT interval (Figure 1).Hypercalcemia is characterized by a calcium plasma concentration above 2.7 mEq/L [4] and leads to a shortening of the QT interval, whereas hypocalcemia is characterized by a calcium plasma concentration below 2.2 mEq/L [2] and the primary ECG alteration is lengthening of the QT interval.
Alterations in the ECG morphology due to the sodium are insignificant and alterations due to magnesium are not easily observed although both can perhaps affect the chemical equilibrium of the formers [21].

Database
The data used to implement and validate the proposed methodology were obtained from the MIT/BIH Arrhythmia Database, which consists of 48 records of two-channel ECGs, obtained from 47 subjects (25 men aged 32 to 89 years, 22 women aged 23 to 89 years), at Boston's Beth Israel Hospital between 1975 and 1979 [19].Each record is over 30 minutes long, and was digitized at 360 samples per second per channel with 11-bit resolution over a 10 mV range.A record consists of at least three files.For example, Record 106 has 106.atr, 106.dat, and 106.hea files.The annotation files (extension .atr)contain labels for each heart beat indicating its location (time  of occurrence) and type (for example, "V" for PVC and "N" for normal beat).There are also other annotations that indicate changes in the predominant cardiac rhythm and signal quality.The .dat file contains the ECG samples (in millivolts).The .hea (header) file is a text file that describes the signals in details.

Methods
The proposed method to detect PVC and to associate this arrhythmia with abnormal concentrations of calcium and potassium is based on a model composed of three main blocks: PVC detection, identification of disorders related to potassium (hypercalemia and hypocalemia) and identification of disorders related to calcium (hypercalcemia and hypocalcemia).It is important to mention that this information is obtained separately and from the same measured ECG record.The classification of each heart beat into normal or PVC is achieved by an ANN through pattern recognition of each QRS complex of an ECG record.A developed algorithm allows to associate changes on the amplitude of T and U waves (Figure 2) and shortening or extension of the QT interval (Figure 1), with abnormalities in potassium and calcium concentrations, respectively.

Ion Concentration Classification
As already pointed out above (shown in Figure 2), hypokalemia is characterized by a reduction of T wave amplitude and an increasing in the U wave amplitude.Figure 2 also shows that hyperkalemia can produce peaked T waves and in extreme cases it can produce a "sine-wave" appearance on the ECG.The literature review showed no automatic method to detect these changes.Therefore, the main question arises: how to build an automated tool to classify each T and U wave? How can these amplitudes indicate disorders such as hyperkalemia and hypokalemia?Furthermore, there is another drawback.The amplitudes of T and U waves vary from one ECG to another (after all, the waveforms in an ECG depend of each patient).In order to handle this feature the amplitudes of each U and T waves of a beat belonging to a patient record were normalized with respect to the maximum amplitude of the respective R wave.In the lack of more detailed experimental data and to implement the classification of the U and T waves, we carried out precise analyzes of the waves shown in Figure 2.These detailed analyzes served as the basis to build Table 1.The U wave amplitude was used to characterize hypokalemia.In the first column of Table 1, the U wave amplitude is divided into amplitude ranges.The four graphs from the top of Figure 2 show the amplitudes corresponding to hypocalemia concentrations of 2.8, 2.5, 2.0 and 1.7 mEq/L, respectively.These amplitudes correspond to the rows of first column of Table 1.Similarly, the T wave amplitude was used to characterize hyperkalemia.The four graphs from the bottom of Figure 2 show the amplitudes corresponding to hypercalemia concentrations of 6.5, 7.0 8.0 e 9.0 mEq/L, respectively.These amplitudes correspond to the rows of second column shown in Table 1.Based on these data shown in Table 1 it was developed an algorithm that identifies if each ECG beat is normal or shows signs that can characterize hypokalemia or hyperkalemia.Furthermore, the algorithm also indicates the possible concentration of the ion causing the disturbance.
The diagnosis related to calcium disorders is done based on the fact that calcium affects the length of the QT interval (Figure 1).The shortening of the QT interval may be a sign of hypercalcemia, and the enlargement of the QT interval may be a sign of hypocalcemia.In order to classify the QT interval as normal, short or long, the range defined in [22] and also shown in Figure 3 is considered.QTc defines the limits for QT interval corrected for each ECG cycle.As mentioned before, each individual has different amplitudes and different lengths of the ECG cycle.Consequently, the QT interval must also be normalized.Equation (1), proposed by Bazett [23], corrects the length of the QT interval and produces QTc, which is the QT interval corrected for a specific heart beat.The correction is formally written as In details, Figure 3 shows that a QTc interval below 0.35 seconds indicates a short QT interval.A QTc interval between 0.35 and 0.44 seconds indicates a normal QT interval and a QTc interval above 0.44 seconds indicates a long QT interval.The proposed methodology consists in calculate the average QTc of an ECG record and then proceed with the QT interval classification based on the ranges shown Figure 3. Thus, the QTc interval for each ECG beat should be obtained applying Equation (1) and the average QTc interval of the entire record is then calculated.From this average value, the implemented algorithm indicates if the analyzed ECG record can belongs to a patient with hypocalcemia or hypercalcemia.

PVC Arrhythmia Identification
Some arrhythmias, such as PVC, besides changing the ECG rhythm, can also change the corresponding morphology.In order to recognize PVC patterns from different patients, an ANN was used to recognize these patterns for each QRS complex of an ECG record.The use of an ANN overcomes the variability of the QRS complex and the difficult that its identification presents by using other mathematical techniques [6] [7].ANNs are computational methods with remarkable generalization capabilities.They are able to learn and recognize patterns in order to solve complex problems [24], characteristics that make it recommendable for this application.Here we used an ANN known as MLP (Multilayer Perceptron) with two internal layers intended to classify each heartbeat as normal or as PVC.The proposed classification process of each heart beat is done by feeding the ANN with the samples of a QRS complex of the beat.Thus the QRS complex is sliced and each slice becomes an ANN entry.
An analysis of available data [19] revealed that the number of samples of each QRS complex is not constant for the same record.Using a computational tool specifically designed to make this analysis, a detailed scan in each QRS complex of all available records showed that the smaller number of samples is 30 and the largest is 114.The average number of samples is around 37. Using a large ANN for example, with 114 inputs, most of these entries would not be used.Besides considering an average of 37 samples, it was established that the RNA would have 30 entries.A developed algorithm normalized all the QRS complex of a record with 30 samples.  Figure 4 shows an original QRS complex obtained from record 208 (blue squares) and the corresponding resampled QRS (red dots).As can be seen, the algorithm reproduced the original waveform of the QRS complex, resulting in a rate good enough to achieve the classification process, in principle, with enough accuracy.Using the proposed procedure, the first layer of the ANN used to detect PVC has 30 inputs, corresponding to the 30 samples of the QRS complex.After several tests, the best ANN configuration that produced the least mean square training error (10 −15 ) is shown in Figure 5.
A decisive point in the training and validation of the ANN lies in the fact that these procedures must be performed using different data sets.Thus, it was selected different records for the training and validation of the ANN from the MIT/BIH Arrhythmia Database [19].It is worth remembering that these data belong to real patients, and consequently the ANN was trained and validated with data from different group of individuals.Analyzing the table of heartbeat types for all 48 records from the available data base [19] we found that, in average, there are 2085 heartbeats per record.These records contain, 37 PVC beats, and about 77% of these 37 records have less than 250 PVC beats (approximately 12% of the total of PVC beats).About 14% of the records have between 250 and 520 PVC beats that are between 13% and 25% of the total of PVC occurrences) and approximately 9% have more than 520 PVC beats.Consequently, the whole records 106 and 119 were selected as the training set because they are mainly composed by normal and PVC heart beats and the proportion of each kind   of heart beat is reasonable (3050 heart beats of which 964 correspond to PVC occurrences).In that sense, those records (106 and 119) are representative because the main goal is to identify just the PVC occurrences and the normal heart beats; all the other registers available in the MIT/BIH Arrhythmia Database were used to test the ANN performance.Based on these considerations, the training process was done by feeding the ANN with every heart beat of the records 106 and 119, and the respective output was set as 1 if the heart beat corresponded to a PVC type and as 0 if it was a normal one.The minimization of the MSE (Mean Squared Error) obtained in the training of the ANN was approximately 10 −15 and shows the correct mapping of the input-output characteristics.In this way the ANN shown in Figure 5 was used to predict if a particular QRS complex has a PVC episode or not.The prediction error is calculated using Equation ( 2) in which Error pred is the prediction error, V exp is the expected value, namely, 1 (one) or 0 (zero), if the analyzed QRS complex has a PVC episode or not, respectively and V pred is the value predicted by the ANN.x(t-2) x(t- x(t) x(t-1) x(t-28) x(t-29)

Pattern Recognition of PVC
The ANN performance in the detection of heart beats with a PVC episode was evaluated by feeding the ANN with every QRS complex of every ECG record available in the MIT/BIH Arrhythmia Database.In this database, the records are separated in two groups, the first one contains the ECG records of patients normally found in the clinical routine and the second group contains those ECG records that present complex arrhythmias [19].The result for both groups of ECG records is shown in Table 2.For each record, this table shows the number of PVC in that record (NPVC), the number of PVC recognized by the ANN (RPVC) and the corresponding error.
The results shown in Table 2 demonstrate that the ANN was able to identify most of the QRS complexes that have PVC, reaching a performance of 92% on average for all analyzed records of group 1.Table 2 also shows better results for the second group of records (about 95% on average), again showing that the ANN was able to recognize characteristic patterns of PVC in totally different records.Therefore, it seems that the selected training set is good enough to make an automatic PVC detection system.

Potassium and Calcium Disorders Classifications
Although the data from MIT/BIH Arrhythmia Database are quite complete, the information contained in the records is only for arrhythmias, and there is no information on heart disease caused by ionic disturbances.This is really the key point in this work.In the absence of specific experimental data, we developed a computational tool based on algorithms capable of identify QRS complexes with changed U and T waves, according to Table 1, as well as identify QRS complexes with changed QT intervals, according to the classification proposed in Figure 3.All records listed in Table 2 were subjected to these procedures.Table 3 shows the results obtained by using these algorithms.The tool recognized hypercalemia in the records corresponding to the numbers 113, 116, 117, 215 and 230 and recognized hypocalcemia in the records corresponding to the numbers 108, 119, 203, 213 and 231.All the other were considered normal.Moreover in accordance with Table 1, the proposed methodology also provided indications of the possible concentrations of potassium that may be causing an ionic unbalance.Although there is no information about this disorder in the MIT/BIH Arrhythmia Database, an inspection of the records 113, 116, 117, 215 and 230 really shows changes in T wave, which could indicate hyperkalemia.Similarly an analysis of the records 108, 119, 203, 213 and 231 through the measurement of the QT intervals of these records directly in the MIT/BIH Arrhythmia Database demonstrates that they really have an extended QT interval on average greater than 0.44 seconds.In contrast, in the other records were not found evidence of hypocalcemia and hypercalcemia.The data files from the MIT/BIH Arrhythmia Database show the waveforms and also provide the measure of time between waves Q and T of each QRS complex.Consequently as the developed algorithm classifies the interval between the Q wave and T wave according to these measurements, one can say that the results are quite reliable.However records of patients with known disorders of calcium and potassium should be tested on the basis of the proposed model for its validity.Thus, experimental tests using the proposed approach would be required, using records of patients proven suffering from hyperkalemia, hypokalemia, hypercalcemia and hypocalcemia.Nevertheless, the present results seem to be sufficient to show the effectiveness of the model.Therefore, the procedures described for both potassium and calcium can be used to improve the quality of diagnosis, pointing out not only if the patient has arrhythmia, but also if this arrhythmia originates in the ionic imbalance of potassium or calcium.

Discussion
This work presents a new methodology for relating the alterations in the ion concentration of calcium and potassium in the bloodstream associated with premature ventricular contractions arrhythmias.An approach based on artificial neural networks was presented and analyzed in order to recognize arrhythmias by using just the waveform ECG morphology recognition.Furthermore, in order to link the arrhythmic patterns with the potassium and calcium concentration, we introduced an algorithm for the recognition of abnormal morphologies in the waveforms due to alterations in those ions concentrations in the bloodstream.
The proposed approach has several advantages such as to carry out analysis in real time.In general, a specialist needs first to check for arrhythmias in an ECG, then, if an arrhythmia is found, a second analysis is made in order to find out if the waveforms in the ECG have an abnormal morphology due to an improper ion concentration.Moreover, one should also take into account even a record of few minutes can have hundreds of QRS complexes to be analyzed.Therefore based on our approach, the diagnostic speed is improved because there is no need of going through these steps that a specialist usually carries out.By using the proposed methodology there is no need of a specialist analyzing the ECG at the whole time.Therefore, the actual proposal allows making analysis through a long period of time (i.e.24 hours or more).Consequently, a better diagnostic can be evaluated because the analyses carried out by a human specialist usu-ally are limited to a relatively short period of time.And if a specialist is intended to analyze a long ECG, the proposed system could help in the process by speeding up the diagnostic.Another advantage of our methodology is that in a preliminary diagnosis, the procedure does not require invasive methods such as blood sampling to check ionic disturbances.If any indication of ionic disorder is found, one can collect samples for the laboratory analysis.

Figure 2 .
Figure 2. Alterations in the ECG shape due to alterations in potassium concentration (hyperkalemia and hypokalemia)[20] and numbers in each figure correspond to concentrations (mEq/L).

Figure 3 .
Figure 3. Classification of the length of the QTc interval [22].

Figure 5 .
Figure 5. Developed ANN architecture for PVC pattern recognition.

Table 1 .
U and T wave amplitudes and the corresponding algorithm classification.

Table 3 .
Ann predictions for records with alterations in potassium (changed U and T waves) and calcium (changed QT intervals).