Early Detection and Monitoring System of Heart Disease Based on Electrocardiogram Signal

Heart disease is the number one deadly disease in Indonesia. One of the main causes of fatality is the late detection of the disease. To avoid escalation of mortality caused by heart disease, we need early detection and monitoring system of heart disease. Therefore, in this research we propose an early detection and monitoring system of heart disease based on ECG signal. The proposed system has three main components: ECG hardware, smartphone, and server. Since the proposed system is designed to classify heartbeat signal, heart disease symptom can be detected as early as possible. We use FLVQ-PSO algorithm to classify heartbeat signal. Experiment result shows that classification accuracy of the system can reach 91.63%. Moreover, the proposed system can be used to verify patients heartbeat by cardiologists from distant area (telehealth). Experiment result shows that responsiveness of the system for the telehealth system is less than 0.6 seconds.


Introduction
Coronary heart disease is listed as the number one cause of death and disability in the world [1]. In Indonesia, the percentage of deaths caused by heart and blood vessels disease increased from 9.1% in 1986 to 26.3% in year 2001 [2].Scientist predicted that in developing countries the death rate because of coronary heart disease will increase by 137% for men and 120% for women from 1990 to 2020 [3]. The lack of medical check-up is the main factor oh this phenomenon. Nowadays, most of the people don't have aware-ness of this disease. Therefore, they don't check their health periodically. The second factor is the lack of cardiac sig-nal detection device such as electrocardiograph (ECG) in the hospital or medical center. In addition, medical devices are still imported from other countries thus resulting high costs of healthcare service. The third factor is the lack of cardiologists in Indonesia. According center of statistic bureau, a ratio between the number of specialist doctors for heart disease and total population of Indonesia reached 1:665.730- [4].Furthermore, most of them live in capital city, and does not spread evenly in the whole area of Indonesia.
The number of heartbeats per unit time depends on the person's condition, such as health conditions, level of fitness, psychological pressure, and other conditions. A device called electro- cardiograph can be used to observe and record human heart rate. Then, heart condition of the human can be described from electrocardiograph record. Therefore, basically ECG signal can be analyzed for heart disease detection system. However, most of electrocardiograph devices available have large size and have no intelligent systems inside. The user cannot get any information from ECG record without cardiologists. Therefore, we need an electrocardiograph that also equipped by intelligent systems so it can detect heart diseases automatically. Such devices are expected to help people to monitor their heart periodically. If user heartbeat contain any heart disease symptoms, the device can detect it and report to the user. However, cardiologists' verification is needed to verify system prediction. It is also needed as suggestion for users to take further action.
The aim of this research is to develop integrated system for early detection and monitoring of heart disease based on ECG signal. The system includes hardware, software, and server. Hardware module of this system is electrocardiograph sensor which can record user's heartbeat. Software module is the core of this system. Software was implemented as mobile application in Android platform. Mobile phone platform is chosen to develop the software because smartphone is currently the most popular gadget in the society. Therefore, users can easily use their gadget to monitor their heart condition any time. In this system, we also use server for telehealth. The prediction given by system is needed to get the verification by cardiologists. As mentioned earlier, the number for cardiologists in Indonesia are quite small compared to the number of population. Therefore, by using telehalth system, patient condition can be verified by the doctors from distant area. In this research, we use artificial neural network Fuzzy Learning Vector Quantization algorithm combined with Particle Swarm Optimization method (FLVQ-PSO) to classify user heartbeat. FLVQ-PSO were originnally proposed by Jatmiko et al for recognizing mixture odor [5]. The algorithm uses PSO to optimize FLVQ learning process. FL-VQ is a modification of Learning Vector Quantization (LVQ) that uses fuzzy logic concepts for codebook representation [6]. Whereas PSO is an optimization method that use colony of agents (particles) to find optimum value. The idea of PSO is using individual factor and collective factor for the agents [7].
Several researches in ECG signal processing have conducted prior to this proposed research. Setiawan et al combined fuzzy logic concepts with Generalize learning Vector Quantization (GL-VQ) to form new algorithm called Fuzzy Neuro Generalize learning Vector Quantization (FNG-LVQ) for arrhythmias classification [8]. GLVQ is modification of LVQ using steepest decent and monotonic function approach in LVQ [9]. Imah et al modified GLVQ algorithm using Mahalonobis distance concept for arrhythmias classification [10]. In other research, Imah et al combined GL-VQ and online Principal Component Analysis (PCA) to form integrated feature extraction and classifiers [11]. Eka et al, implement FNGLVQ algorithm in Field Program-mable Gate Array (FPGA) [12]. Other researches were focused in other topics. Isa et al analyze optimal selection of wavelet thresholding algorithm for ECG signal denoising [13]. Widiyanto et al developed an ECG 12-lead hardware with SPIHT compressing scheme [14]. De Capua et al developed Smart ECG Measurement System Based on Web-Service-Oriented [15]. Gu Young Jeong et al developed portable ECG measurement device and PC software for automatic ST analysis [16]. Liang Kai et al developed portable ECG monitoring based on Bluetooth mobile phone [17]. Cheng Sun developed portable 12-lead ECG acquisition system [18]. ECG signal, is not only used for analyzing heart disease, but also other purpose i.e. sleep stages classification or sleep apnea detection [19].

System Architechture
This system has three components which consists of the hardware, smartphone, and server. Diagram of the system architecture is shown at Figure 1. Hardware module in this system consists of electronic ECG device, microcontrollers, and serial Bluetooth adapter. Hardware module is used for capturing human heartbeat signal and convert it to digital form. The ECG signal needs to be converted to digital form so that can be acquired by smartphone. Smartphone component is used to implement software module. Software module has four main functions, they are heartbeat preprocessing, heartbeat visualization, heartbeat classification, and save heartbeat as user history. The third component is the server. Server is used to implement telehealth system, and save all data in the database. Detail of each component will be explained in the sub sections below.

Hardware
As mentioned before, hardware is the component used to capture human heartbeat. The main component of the hardware is ECG sensor. In this research, we build ECG sensor using electrical components. The ECG sensor were built from scratch because there is no ECG sensor in the market that uses Bluetooth interface and provide application programming interface (API) to access heartbeat data. ECG used in this system consists of seven parts as shown in Figure 2.
The first part is the transducer that will be attached to the body. The amplifier is used to amplify the measured signal. The first amplifier in ECG component that we useis theINA118. This type of amplifier can generate 10 times stronger output signal than its input signal. In this first amplifier, we use electronic circuit called right-legdriven-loop. The circuit is used as inverted version common mode interference at right foot of human body. Therefore, the circuit can decreases interference coming from human body. This electronic circuit is also used for human safety system. Detail information aboud the circuit is explained in INA118 datasheet. The second amplifier uses input voltage between 5mV up to 40mV. This amplifier has responsibility to amplify the heartbeat signal so that its voltage is between 0.1V up t o 5 V. In other words, heartbeat signal will be amplified 50 to 125 times. For the second amplifier, we use non-inverted amplifier OP07 with reinforcement value of 100 times.Filter is a circuit that can separate the signals with a certain limit frequencies. There are two kinds of filters that used in the ECG components, they are High Pass Filter (HPF) and Low Pass Filter (LPF). HPF is used to pass signal whose frequency is above threshold value.On the other hand, LPF is used to pass signal whose frequency is below the threshold value. The HPF is used to avoid noises from body to ECG signal, whereas LPF is used to remove noises already contained in ECG signal. In this system, we uses HPD with cut off frequency of 0.05 Hz. The first LPF uses 40 Hz cut off frequency, whereas the second LPF uses 20 Hz cut off frequency. Physycal view of the ECG built in this research is shown in Figure 3.
The second component of the hardware module is the microcontroller. Microcontroller used in this system is AVR ATMega8. Microcontroller is used to perform ECG signal conversion from analog to digital. The second function of the microcontroller is sending heartbeat signal data to smartphone. However, smartphone does not support wired interface such as USB or mini USB. Therefore, we need bluetooth serial adapter (third component). The adapter can convert signal from wired to wirelessbluetooth network. Therefore, heartbeat signal can be accessed by smartphone. Microcontroller used in this system were shown in Figure 4. Bluetooth serial adapter component used in this system were shown in Figure 5.

Smartphone
In this research, use smartphones to visualize, classify and save user heartbeat data. The software is implemented on Android operating system. The view of the mobile application is shown in Figure  6.    application. There are several menus of the application which are the user management, heartbeat history, retrieve heartbeat data from ECG, heart disease information, cardiologist information, hospital information, doctor's menu, setting and help. Before using the application, user should register an account using user management menu. User can register as patient or doctor. Figure 6(b) show visualization of user heartbeat history. However, before visualize heartbeat history, user should retrieve its heartbeat from ECG as shown in Figure 6(c). After saving the heartbeat data, user can visualize the data, send the data to server, or delete the data. If users want to get system prediction, then they should press the "Classify" button.
User that registered as doctor can utilize special menu, called "doctor's menu". The most important function among doctor's menu is heartbeat verification. Cardiologists can give verification of the patient data that sent to the server. First, doctors should register their data in the server. Then, they need to synchronize their smartphone with server to get list of unverified heartbeat. Next, doctors can give verification of the data they choose. After visualizing the heartbeat, doctors can give their verification as shown in Figure 7(a). Doctors can also give annotations of the heartbeat signals as shown in Figure 7(b). Annotations are given as class label of the heartbeat.

Server
The third component of the system is server. There are two modules in the server, the web services and database. Web service provide many kind of functions i.e. register user data, save heartbeat history, verify heartbeat history, etc. There are 11 services provided by server to carry out telehealth function of the system. Detail of the 11 services are shown in Table 1.
Besides it contain web services, server also has a database. Database is used to save all data in   the system. There are five data tables in the server which are patients' data, cardiologist data, patient heartbeat history data, hospital data, and cardiologist affiliation data. Patient data consists of personal data i.e. name, address, email, phone, and body related data i.e. weight, height, blood type, and date of birth. Doctor and hospital data consists of general data i.e. name, address, and phone number. Patient heartbeat histories are saved in history table. The table contains heartbeat data, verification message from cardiologist, and its annotation. Detail of the database is shown as Entity Relationship Diagram (ERD) in Figure 8.

Heartbeat Signal Preprocessing
Before classifying the heartbeat signal, several preprocessing steps need to be done. The preprocessing consists of signal conversion, beat extraction and beat simplification.

Signal Conversion
Heartbeat signal captured from hardware module has integer format with data range from 0 to 255. In other words, the data uses 8-bits resolution. After being sent to the smartphone, the data will be converted to floating point format data ranging from -1 to 1. This conversion process uses equation (1).

Beat Extraction
After the conversion process has been done, heartbeat data will be separated so that each of the data will represent a single heartbeat. In this research, we use simple R-point detection. We search maximum point in 1000 points sample as Rpoint. Then, we search R-point in 1000 point samples forward. Then, we calculate the number of points between R-point to next R-point. There are approximately 850 points between R-point to the next R-point. Therefore, a single heartbeat can be   Figure 9 shows the result of beat extraction.

Beat Simplification
As mentioned in previous subsection, a single beat signal has approximately 850 points. To obtain faster and more efficient computation, we need to simplify the signal. In this process we use wavelet method. We use Daubechies 2 wavelet kernel to decompose every beats. Figure 10 shows Daubechies 2 wavelet kernel used in this research. As we use four level decompositions, therefore 850 samples of the signal can be reduced to 55 samples. This heart beat contains 55 samples that are ready for classification process, both training and testing.

Fuzzy Learning Vector Quantization -Particle Swarm Optimization (FLVQ-PSO) Classifier.
FLVQ-PSO is an algorithm that combines FLVQ classifier with PSO. FLVQ-PSO has several advantages compared to the standard FLVQ algorithm, i.e. ability to determine fitness value with matrix similarity analysis (MSA), and ability to determine optimal position with PSO. The difference between FLVQ-PSO and FLVQ is in the training process. In FLVQ-PSO, reference vectors were updated using FLVQ and optimized by PSO. After conducting training with a number of epochs, the reference vectors will be moved closer to each other until it reaches convergence state. Reaching con-vergence state of solution is the advantage of using PSO method.

Reference Vector Initialization
FLVQ-PSO method was developed to decrease the dependency of FLVQ to its initial reverence vector. In FLVQ, initial reference vector was produced by choosing one of the samples. Initial reference vectors in FLVQ-PSO method was produced by creating initial reference vectors as much as needed. This initialization was conducted randomly based on output class target, so we can get good initial reference vectors.
Fitness value FLVQ-PSO uses fitness value to determine the particles local best and global best value during PSO iteration. Fitness values obtained using MSA. Fitness value is calculated by the number of main diagonal in MSA minus the number of main nondiagonal in MSA. Suppose MSA consists of elements mij with i, j ∈ {1, 2, 3, n}, n x n order of matrix, and k-th particle, then the fitness value of the particle-k can be calculated by the following equation (2).
where f k is fitness value of the k-th particle, m ij is elements of matriks MSA, and n is the numbers of output class in the artificial neural network.Based on the definition of fitness function, it is known that the most representative reference vector in FLVQ-PSO is the reference vector whose greatest difference between diagonal value and non-diagonal value in similarity matrix, or in other words its MSA matrix closer to the identity matrix.

Global Best and Local Best
Global best and local best are used to update the value of reference vectors. Local best in FLVQ-PSO is the best reference vector for each particle. This local best value is obtained by performing comparisons between i-th and (i-1)-th iteration fitness value of reference vector. Suppose the i-th iteration fitness value of reference vector is better than (i-1)-th iteration fitness value of reference vector, then the reference vector from i-th iteration will be the local best value. Global best in FLVQ-PSO is reference vector which has the best fitness value among the others. For each iteration, local best of reference vector in each particles are compared. Maximum local best among particles will be global best. Local best and global best can be calculated using equation (3) and equation (4).
where k is index of the agent, and i is index of the iteration.

Reference Vector Update in FLVQ-PSO
Reference vector is updated through two different phases which are the FLVQ method and PSO method. Figure 11 shows the update process experienced by reference vector. Each update will change the position of particle. Particle velocity will affect the particle movement from its initial position. PSO formula will be used to calculate particle velocity. Particle velocity will determine degree of particle movement. Particle velocity is determined by difference between local best value and current vector value. It is also affected by difference between global best value and current vector value. Another aspects that affect velocity value of particle are cognitive value (c1) and social value (c2). Suppose cognitive value is greater than social value, then the particle tends to move closer to its local best. If social value is greater than cognitive value, then the particle tends to move closer to its global best. After calculating particle velocity, the new value of reference vector can be obtained by summing up the reference vector median with the value of particle velocity. Furthermore, the new minimum value and maximum value of reference vector can also be obtained by calculating the differences between reference vectors average before and after updating, which we label as d. Afterwards, d is summed with the value of its minimum and maximum.
Training using FLVQ-PSO Before training phase, all of the training data (input vectors) needs to be sorted with zig-zag pattern. This pattern ensures entire class that contained in input vectors enter the training process in each iterations. Afterwards, training using FLVQ-PSO can be done using following steps: 1) Initialize reference vector as much as needed. This initialization was conducted randomly based on the target output class; 2) Train using FLVQ algorithm. This step will produce similarity value between input vector and reference vector for each cluster layers; 3) Establish the MSA as many as the number of particle. The MSA will have n x n size matrix where n is the number of output classes. The value of MSA will be updated from the winner similarity value for each cluster layers; 4) Training process using PSO method will be conducted if and only if the value of MSA for each columns in matrix has been updated.
This step has several sub processes that have to be done. These sub processes are calculating fitness value for each MSAs in each cluster layers (4.a), determining local best for each particles by comparing fitness value from its MSA before it has been updated and fitness value from its MSA after it has been updated (4.b), determining global best from local best (4.c), updating reference vectors (4.d) using equation (5) and equation (6).
and calculating minimum and maximum value for each reference vectors (4.e) by using equation (7) and equation (8).
( ) ( + 1) = ( ) ( ) + In the equation (7) and (8), w(t) is average value of reference vector at the i-th output class and j-th feature before the update, w(t+1) is average value of reference vector at the i-th output class and j-th feature after the update, w(l)(t) is minimum value of reference vector at the i-th output class and j-th feature before the update, w(l)  ricular Fibrilation (VFIB), PACED, Normal with 30 beat per minute (bpm) and normal with 180 bpm shown in Figure 13. We have 90 heartbeat samples for each class, so total samples in our dataset is 720. The first experiment was conducted to measure heartbeat classification performance. As measurement criteria, we measure classification accuracy.
In this experiment we used two kinds of neural network algorithms,the FLVQ and FLVQ-PSO. Both of themused eight layers and 9-fold cross validation for validating theexperiment. The result of our experiment is shown in Table 2. Table 2 shows that mean accuracy of FLVQ-PSO algorithm is greater than mean accuracy of FLVQ algorithm.From the experiments, FLVQ-PSO showed overall better performance based on the mean accuracy of 91.63%while the FLVQ algorithm only reach the accuracy of 81.30%. Eventhough FLVQ-PSO did not always has better performance, i.e in Fold-1and Fold-2,the FLVQ-PSO still showed overall better performance than FLVQ.
As mentioned before that over all FLVQ-PSO has better performance in this system. It is caused by optimization used in FLVQ-PSO during training process. FLVQ-PSO generate several particles (candidates) of reference vector. Then it search for optimum referrence vector measured by matrix similarity analysis (MSA) as fitness function. Therefore, FLVQ-PSO can obtain better reference vector than FLVQ. As the result, FLVQ-PSO has higher accuracy than FLVQ. Most of the system misclassification occurred when system classified class V-Fib. Several instances of class V-Fib is detected as class VTACH. Those two types of arrhythmia have similarity seen from their signal pattern in Figure 13. Therefore, the system hardly differentiate them. The other minor failure is distributed evenly to all class instances.
The second experiment was conducted to measure server response. Telehealth system should have server with fast response. Therefore, in this experiment we measure response time of the server for each service provided. In this experiment we try to use each service of the server. Then, we calculate response time, which is time from sending request to server until server return the message that request is aready done by server. The result of the experiment is shown in Table 3. Table 3 shows that most services provided by server can be executed in less than 250 ms. From the experiment, we can only identify two services that use more than 250 ms to be execute. However, those two services can be executed in less than 600 ms.

Conclusion
Early detection and monitoring system of heart disease based on ECG signal was successfully implemented. The system consists of three main component, hardware, smartphone and server. Hardware component used this system is ECG sensor that consists of electronic ECG, microc-ontroller and bluetooth serial adapter. Smartphone is used to acquire, visualize, classify, and save heartbeat signal taken from the hardware. Doctorscould verify patient heartbeat using mobi-le application installed on the smartphone. Server is used to save all data in the system, and conneect patients with cardiologists from distance area. Heartbeat clasification accuracy reach 91.63% using FLVQ-PSO classifier, and 81.30% using FLVQ classifier. Services provied by server can be executed in less than 0.6 seconds.