Detection of R-Peaks in ECG Signal by Adaptive Linear Neuron (ADALINE) Artificial Neural Network

. This research proposes a new method to detect R-peaks in electrocardiogram by using the prediction value from adaptive linear neuron (ADALINE) artificial neural network. With this aim, the weights of four input neurons in ADALINE are updated for each encoded ECG vector-segment and the value of an output neuron is compared with the actual ECG followed by applying finite impulse response filter. Our simulated experiments with the MIT-BIH ECG database that represents the long-term recordings from the heart disease patients show that our proposed algorithm can detect R-peaks in ECG data with the accuracy of more than 99%.


Introduction
Electrocardiogram (ECG) that records the electric potentials resulting from a heart's activity can offer the clinical decision parameters to diagnose an abnormal heart sinus rhythm.The primary features that characterize ECG waveform include R-peak, QRS complex, S and T fiducial points in terms of time-location and morphological shape [1].
In the ECG data, the most crucial information is the time locations occurring in R-peak because this feature can be utilized to monitor especially Premature Ventricular Contraction (PVC) arrhythmia [2] and Heart Rate Variability (HRV) [3] in the long-term based heart health monitoring environment.So far, concerning the automatic detection of R-peaks in ECG data, the adaptive threshold level was sought [4] or a differential operator was applied to compute the gradient of ECG waveform [5].Also R-peak characteristic point was estimated by encoding the ECG data in wavelet transform [6,7,8] or Hilbert transform domain [9].In our study, a new algorithm to detect R-peaks is proposed by evaluating the predicting feature from ADALINE artificial neural network model [10,11] and comparing with the actual ECG voltage level.With this aim, ECG data is encoded successively in a four dimensional vector-segment format and feed forwards into four input neurons in ADALINE to update their weights.The value of an output neuron is computed as a prediction value for each ECG segment and compared with the actual voltage level to estimate the time locations of R-peak.

Prediction of ECG data by adaline neural network 2.1 ADALINE artificial neural network architecture
ADALINE has single output neuron that receives the weighted sum from the multiple input neurons with an optional bias.Fig. 1 shows the architecture of an ADALINE neural net consisted with n-input neurons X 1 , X 2 , … , X n , an output neuron y with specifying weights of w 1 , w 2 , …, w n and a bias b.In the ADALINE model, the weights of connections between input neurons and an output neuron are trained using the delta rule [12].Training and testing algorithm to extract the residual error between the predicted ECG and the real data as following steps; Step 1: Initialize weights w 1 , w 2 , w 3 , w 4 and set learning rate α = 10 -6 .
Step 2: Encode ECG input data X = [X 1 , X 2 , X 3 , … , X N ], N: the number of samples, into an i th segment S i , i = 1, 2, ….N in a fourth dimensional vector format: Step 3: Compute i th predicted vale from an output neuron by activating (i-1) th weights: , where • is a dot product operator and ିଵ = ൣ‫ݓ‬ ଵ ିଵ , ‫ݓ‬ ଶ ିଵ , ‫ݓ‬ ଷ ିଵ , ‫ݓ‬ ସ ିଵ ൧ ௧ (t: transpose) is a weight vector that was determined at (i-1) th training stage Step 4: Update and weights, i =1, 2, 3, 4, with nullifying a bias effect (i.e., b = 0): During the process of training algorithm, the weights are updated adaptively for each feed forwards ECG segment S i so as to minimize the residual error between the real ECG data X i and the output vale y i .In order to evaluate the performance in detecting R-peaks in ECG data, we use the MIT-BIH database [13] which recorded the long-term ECG readings with the sampling rate of 360 Hz (180 Hz in text file format) from the heart disease patients.For our experiments, the record titled with ECG100_1 (contains the normal sinus rhythms and one PVC beat) and ECG119_1 (includes a quite number of PVC abnormal heart beats) are considered.As a preprocessing step, a digital high-pass finite impulse response (FIR) filter is initially applied to the considered ECG data to eliminate the baseline wandering noise [14].

2 ADALINE artificial neural network architecture
Fig. 2-(a) shows that the part of residual error e i , i = 1, ... , N, between the predictive value from an output neuron as an estimate of ECG data ‫ݔ‬ (ECG100_1) and the real data.Fig. 2-(b) describes the updating weights when i th ECG segment S i (ECG100_1) feeds into the input neurons.In this figure, the error signal is abruptly changed in the neighborhood area of R-peak.Thus we can utilize this fact that the initial R-peaks candidates can be selected with applying a moving average filter followed by lowpass FIR digital filter to smooth the residual peaks and to set the adaptive threshold line in order to delineate Rpeak candidates.

Detection of R-peaks in ECG signal
In order to smooth the sharpness in the residual peaks, the moving average filter (window size, L is selected to be 20) is applied and eps (error in prediction signal from ADALINE) is defined as in equation ( 4).
To set the threshold line that is adaptively tune to the trend of residual error signal, eps is low-pass filtered by a FIR digital filter (see Table 1 for filter design specification).As of a result, Fig. 3 shows eps i with lowpass filtered eps signal, leps i , i=1, …, N.Here leps i is used as a reference level to delineate the time intervals including R-peaks.Finally, the time locations in R-peak can be resolved by computing the gradient value for each leps-segment for ‫ݐ‬ ≤ ‫ݐ‬ ≤ ‫ݐ‬ .Fig. 4 illustrates the result of R-peak detection as a symbol of 'o' for ECG100_1 and for ECG119_1.Note that two R-peaks in ECG119_1 are missed especially during the initial weights updating stage (i.e., the time less than 2 seconds) due to the inherent characteristics of neural network model.In other words, ADALINE needs some warming up time to trace the trend of input ECG data S i .The accuracy of estimating R-peaks by ADALINE can be slightly varied upon the size of moving average window L. Nonetheless, the overall performance of detecting R-peaks by ADALINE is superior to the conventional method that simply computes the gradient of ECG waveform.Table 2  and   In summarizing our proposed algorithm, ADALINE neural net accompanied with the necessary digital filtering processes is described in Fig. 5.

Conclusion
In this research, we can find the fact that R-peaks in ECG can be automatically detected with the high accuracy of more than 99% by ADALINE neural net implemented with four input neurons and one output neuron.Concerning the clinical decisions for the diagnosis of arrhythmia, FN index is the most crucial feature.As shown in Table 2 and 3

Figure 1 .
Figure 1.Architecture of an ADALINE neural net.

Figure 2 .
Figure 2. (a) The part of residual error e i for ECG100_1 dataset.(b) Updating weights of ADALINE neural net for ECG100_dataset.

Figure 3 .
Figure 3.The illustration of residual error: eps i (solid line), leps i (dotted line) in the top chart and the overall trend of leps i in the below one.

Figure 5 .
Figure 5.The proposed ADALINE neural net for detecting R-peaks in the ECG data.
, the number of FN's are 2 (L = 20) for ECG 100_1 and ECG 119_1 dataset, respectively.The main cause of this misclassification is the limited capacity of ADALINE neural network model when it deals with updating weights especially during the initial training stage.

Table 1 .
Design specifications of low-pass FIR filter for extracting leps i

Table 2 .
Comparison of performance in detecting R-peaks by ADALINE using the different size of window L with applying differential operator to ECG100_1