Detection of electrocardiogram QRS complex based on modified adaptive threshold

Received Feb 24, 2019 Revised Apr 8, 2019 Accepted Apr 19, 2019 It is essential for medical diagnoses to analyze Electrocardiogram (ECG signal). The core of this analysis is to detect the QRS complex. A modified approach is suggested in this work for QRS detection of ECG signals using existing database of arrhythmias. The proposed approach starts with the same steps of previous approaches by filtering the ECG. The filtered signal is then fed to a differentiator to enhance the signal. The modified adaptive threshold method which is suggested in this work, is used to improve QRS complex detection rate. This method uses a new approach for adapting threshold level, which is based on statistical analysis of the signal. Fortyeight records from an existing arrhythmia database have been tested using the modified method. The result of the proposed method shows the high performance of QRS complex detection metrics with a positive predictivity of 99.88% and sensitivity of 99.62%.


INTRODUCTION
Heart disease and cardiac stroke are the most leading causing of fatalities around the world in the last 15 years. These diseases were responsible for a 15.2 million deaths in 2016 [1]. The necessity and urgency of dealing and early detecting of these diseases were the motivation behind many publications and research center tasks. Different types of physiological signals can be captured from a human body to detect some signs of heart disease. The most detectable signal is the Electrocardiogram (ECG) which representative of the cyclical rhythm of heart muscles. ECG instruments can sense such electrical pulses because of its strength by electrodes positioned on the human skin [2,3]. These electrical pulses, represented ECG, can be plotted or saved in a format that can be interpreted by the specialists. ECG shape provides much information about heart state such as time interval and amplitude. Many features and metrics, consisting of many characteristic points, can detect cardiac abnormalities or behavioral changes such as heart rate variability [4].
Different segments of ECG signal have been used to detect the heart abnormalities. The QRS complex is considered one of the most significant parts of ECG signals. Pan and Tompkins [5] developed a method for the QRS complex detection. This method had used the assembly language and implementation was on a Z80 microprocessor. The performance of their method was deeply affected by frequency variation in QRS complexes which represented a main drawback of this algorithm. Therefore, a more adaptive real time QRS detection algorithm had been suggested by the same authors and implemented using the C language [6].  [7]. A syntactic technique is another technique used to detect QRS complex. But, this technique is very sensitive to noise [8]. Although, neural networks technique is affected badly with noise, but it gives good results when it uses with wavelet transform [9], [10]. Different combination of successful techniques is used to enhance results such as Hidden Markov Model with bandpass filter [11]. These combination result can be sensitive to some artifacts such as baseline wander or from heart rate variability or from noise [12]. Moreover, statistical and empirical methods are used to filter and detect QRS complex such as Empirical Mode Decomposition (EMD). The same researchers exapns there work and used singularity method for QRS detection [13]. Where the authors used both soft threshold and singularity to detect QRS. Again, results of methods are still fragile against noise [14].
Based on state-of-the art research papers, it is found that Hilbert transform is the most successful approach for QRS detection. Hilbert transform has adopted in different methods to identify successfully the real peaks from ECG signal. Moreover, R-wave detection performance is improved by using methods depend on Hilbert transform. However, this good performance in detection results is not maintained when they applied on diseases affect wave amplitude as in ischemic cases [15]. For normal beat in simple ECG signals a fixed threshold can detect R-waves efficiently [16]. However, in realistic ECG measurements, signals may differ dramatically from each other, due to acquisition artifacts such as patient movement or severe baseline drifting. As a consequence, the probability of missing QRS complexes may be rising. Hence, a more sophisticated adaptive threshold is needed to enhance ability of QRS detection [17].
Researchers have been used many empirical thresholds to implement adaptive threshold. Different techniques used adaptive threshold such as wavelet transform technique is used for QRS detection, as well as P and T waves [18]. These techniques have provided very good results for R wave peak detection [19,20].
In this work a modified adaptive method is proposed to enhance the detection accuracy. This technique uses a new approach for adapting threshold level, which is based on statistical analysis of the signal. The proposed approach which is based on two threshold levels (upper and lower), is expected to overcome most challenges of noise and artifact polluted signals.

DETECTION OF THE QRS COMPLEX
One cycle of ECG signal comprises different time segments, including P, T, and QRS complex waves as shown in Figure 1. A U-wave segment may also appear in 50 to75 % of ECG after the T-wave [21]. Based on several features extracted from these signals, cardiac abnormalities can be detected. The principal part of ECG analysis algorithm is mainly depends on how reliable and accurate QRS detection.
The depolarization of heart ventricles can be captured in a human skin, body as the QRS complex. The heart ventricles produce higher electrical activity than other parts of heart because they have greater muscle mass. R waves are the most significant highest amplitude part of ECG signal and hence it is the easiest part to detect. However, sometimes it is difficult to detect QRS complex. The challenges of QRS detection can be listed as follows: a) signal can be change dynamically with time, i.e., the ECG statistical properties not consistent with time; b) QRS complex may not be distinguishable all times; c) signal may be contaminated with noise (low SNR and artifacts, and e) QRS polarities may be inverted. Figure 2 shows an inverted R-peak. However, a good performance algorithm can detect QRS with both polarities of R-peaks. One of QRS complex challenges is shown in Figure 3 where a low amplitude R-peak is presented. Another challenge is the presence of ECG variation between two adjacent heart beats as shown in Figure 4.  This variation may come due patients movement of the baseline drifting. This challenge degrades detection accuracy if a high fixed threshold is adopted. However, if a low fixed threshold is used instead, this can easily lead to inaccurate detections. The fixed threshold might also affect badly T and P wave detection. To overcome these challenges, an adaptive threshold algorithm has been used and it is mainly implemented using multiple thresholds empirically which can improve the accuracy QRS complexes detection.

AMPLIFIER PROPOSED ALGORITHM
Three distinct points form the QRS complex, which positioned within a single heart cycle referred to as Q, R and S. For peak detection, several features of signal details are extracted. Setting R Rush is the first step of extraction feature. Main part of the energy of a dedicated complex lies between 3 Hz and 40 Hz. Wavelets transform is used to detect QRS. The fast changes of QRS complex can be identified by the maximum and zero equations of wavelet conversion. Figure 4 shows the block diagram of the suggested method.

ECG study dataset
In this work, an existing data set is adopted to test the proposed algorithm. This dataset was taken from a standard database called Metabee Online Hematonic Database which contains approximately 4,000 ECG records. This dataset is collected from patients at the Israel Hospital Pacemaker Between 1975 and 1979 [22]. It recorded in patients with arrhythmia issues which consists of 48-hour and half-hour ISG records. The collected signals have been sampled at 360 Hz for each channel with a resolution of 11-bit.

Preprocessing
The baseline trajectory and the interference in the main electricity are the dominant source of noise and can strongly affect the ECG signal analysis. A wander baseline that arises because of breathing lies between 0.15 and 0.3 Hz. The interference on the main electricity is a narrow-band noise concentrated on a 60-degree range with a range less than 1 magnitude. The ECG signals are pre-processed by filtering to remove high-frequency noise, main electrical interference and baseline drifting, thus enhancing the signal standard and equipment exclusion and environmental changes.

Filtering ECG
Another filtering stage is used to enhance the desired information in ECG signal. This stage includes a band-pass filter which helps to enhance the QRS complex. This filter also helps to remove muscular artifact from the ECG signal. A Butterworth band-pass filter with an order of 6 has been applied. This filter is set from 5 to 15 Hz. This helps to maximize the QRS complex and suppresses the P and T waves as shown in Figure 5.

Differentiation
Derivation Derivation of ECG signal helps to follow the type of changes and time of occurrence by indicating slopes. The rising of QRS complex (i.e. from Q to R) can be identified using first derivative as a high slop. While, the falling edge of QRS complex (i.e. from R to S) appears as minimum slop. The first derivative differentiation is calculated using 2 points of the central difference using (1).
number of samples. At the boundaries of time slot (i.e., k=0, and k=N-1), and based on error minimization, initial conditions can be set. The derivative also helps to remove motion artifacts and baseline drifts.

Hilbert transforms
In this work, Hilbert transform is fed with discrete time-series y(k). This operation can be defined as in (2).
where the vector h can be calculated as in Equation (3). The Fast Fourier Transform (FFT) of the y(k) signal is stored in vector f, and the acronym FFT -1 means the Inverse Fast Fourier Transform. In (4) describes the pre-envelope signal of original signal y(k) which is also considered as the analytic signal.
The instantaneous magnitude a(k) of z(k) is described in (5). It is also considered as the envelope f z(k).
While the instantaneous phase angle in the complex plane can be calculated by (6) ).

THE MODIFIED ADAPTIVE THRESHOLD
The most successful technique for R-segment peak detection is the adaptive threshold. However, using one threshold may be accurate enough so at a pair of threshold limits technique can offer more accurate results. These limits called the upper limit threshold (u th ) and the lower limit threshold (l th ). In this work a modified adaptive method is proposed to improve the detection accuracy. The proposed method calculates the adaptive thresholds for each analysis window (N samples) as follows: The upper threshold is defined by k=1,…, N.
And the lower threshold is defined by (8).
The dynamic operation of calculating threshold values, update these values with each epoch. Meanwhile, both numbers of detecting peaks (above threshold ℎ and threshold ℎ ) are calculated. The number of QRS complexes detected by ℎ is denoted by ℎ while the number of QRS complexes detected by ℎ is denoted by ℎ . Using this technique, the number of detecting peaks is different. The threshold value of ℎ is updated using Equation (9).
where is the error weight and ∆= ( + × ) × ( − ℎ ) is the difference between the defined two limits. Where c is a scaling, and are the mean and standard deviation of the signal in the current window. Based on simulations on the database w= 0.125 and c = 0.8 were chosen. The value of ℎ is calculate using Equation (10). The variables ∆ are as defined in (9).
According to their definitions, ∆= 0.05 × . Then the lower threshold limit is increased by ∆ as well. This process continues until the numbers of detecting QRS for upper and lower thresholds are equal ( . . ℎ = ℎ ). ∆= ( + × ) × ( − ℎ ) is the addition to improving the QRS detection that will give a good sensitivity.

RESULTS
The proposed QRS automatic detection technique has been validated using the MIT-BIH arrhythmia database. This database comprises 48 records. Each record includes an ECG signal with duration of 30 min with 5.556 s. The first channel of each record is needed for QRS detection. A total of 48 records has been analyzed. These records include abnormal signals such as: low amplitude QRS, inverted QRS polarity.
A wide range of testing, performance metric is used to evaluate the detection technique. These metrics include false negative (art) which means not detecting a real beat, false positive (PHP) which represents the detection of true, false and positive strikes (TP) is the total number devoted to detection correctly by the technique. Using phenotype, sensitivity (C), positive prediction (+P) and detection error rate (DER) can be calculated using equations (11)(12)(13). Sensitivity (Sen) (C): The heart rate correctly determined by the algorithm.
Positive Prediction (+P): The detection rate given by the algorithm corresponding to the annotation assigned by the specialist.
Detection Error Rate (DER): The percentage of false detections over the total number of detecting heartbeats.
A window size of ±13 samples is chosen around the beat detection to count this window as one beat detected. The results of the two-thresholds modified technique is listed in Table 1. These results are calculated based on 48 records selected from the MIT-BIH arrhythmia database. The results show that the challenging records are detected successfully with the proposed technique. Examples of these records are: (i) when the R-wave is not centered on the record (e.g., record 100). (ii) When the noise is very high (e.g., record 104 as shown in Figure 6 and (iii), the algorithm detected QRS precisely for record 117 with a challenge of low SNR when the amplitudes of R-peaks are low as shown in Figure 7.   Figure 8. This could appear clearly with the sensitivity rate of this record and this could justify the high number of FN beats, which is shown in Table 1.

DISCUSSION
A very well-known dataset is used in this work which is commonly used in many research papers. However, it is not very easy task to compare the performance of state of the art algorithms with our technique. This challenge arises because previously published work algorithms were not tested under the same environments. Moreover, they are not using the same records. To elaborate more, it is logical that QRS complex detection rate increases (e.g., higher performance metrics) when uses healthy records only and excludes the challenging records. Table 2 listed the performance of the modified approach in comparison with other recent works for the QRS detection, evaluation over the MIT-BIH arrhythmia database. In this table, the best results of the state-of-the art algorithms are selected [23][24][25][26][27][28][29] to assess our proposed algorithm. The well-known algorithm of Pan and Tompkins [5] is used in many papers as a point to start for better development of QRS detection. To improve QRS detection, many researchers resample the acquired ECG signal at 200 Hz. However, ECG resampling is not needed in our proposed.. In this work, a passband filter with a range of (5-15) Hz has been recruited to enhance the QRS energy. Although many researchers agreed to use the (5-15) Hz band, other researches use different passbands. However, most researchers agreed to use cascaded low-pass and high-pass filters to implement Band-pass filter of Pan and Tompkins algorithm [5]. Another addition to this work is to use a first derivate stage to reduce the bad effect of baseline drifts and movement artifacts. This stage is inserted before applying Hilbert transform. Also, another researcher applied adaptive quantized threshold [16]. To overcomes the drawbacks of using fixed thresholds, we suggested a new algorithm for QRS complex detection. This algorithm uses an adaptive upper and lower limits threshold. The results of our proposed algorithm (as can be seen in Tables 1 and 2), show improvement in detection rates of QRS complex due to the use of the combination of Hilbert transforms and modified adaptive threshold. The obtained results using the proposed algorithm is implemented successfully as clearly shown from the comparison between the proposed algorithm and the state of the art results of other researches which is listed in Table 2.

CONCLUSION
A modified approach for QRS detection suggested and implemented in this work. This approach is implemented by applying a modified adaptive threshold technique. The main contribution of this modified approach is to use the statistical features of ECG signal itself to update the two-threshold values. This modification enhances the detection accuracy of QRS complex, especially with challenging records such as ventricular ectopic, low amplitude R-peaks, negative QRS polarities, and low signal-to-noise ratio. The results proved that the modified algorithm outperforms other methods in performance metrics, including; a sensitivity of 99.88% and positive predictivity of 99.62 % for the used MIT -BIH database