A ECG Waveform Detection Algorithm Based on Differential Threshold and Wavelet Transform

With the portable ECG device develops rapidly, the ECG waveform detection is particularly important. As far as we know, the goal of most researchers is designing a new, real-time, high efficiency, perfect effect ECG detection algorithm. In order to obtain better detection accuracy, a new type of algorithm which combines differential threshold and the wavelet transform is designed, the method uses improved version of the differential threshold method to detect the QRS wave group, and then the P, T-wave is identified by biorthogonal wavelet transform. Dozens of MIT-BIT test data show that the algorithm fully meets the testing requirements, achieve the desired goal and obtain good results.


Introduction
With the increasing of the patients with cardiovascular disease, such diseases become the major threat of human life and health.So more and more researchers pay their attention to ECG signal processing.Currently there are many algorithms about ECG detection, but the performance of detection is not very well, and the correct rate is low.A new waveform detection algorithm is proposed in this paper, which combined differential threshold with the wavelet transform.This new algorithm not only make up the weakness that the detection performance of differential threshold is poor for P wave and T wave with lower magnitude, but also avoid the complex calculations of wavelet transform.Experimental results show that the performance of this method is well, and have a high detection accuracy.

Related Research on Wave Group Algorithm
Electrocardiogram(ECG) automatic analysis include waveform recognition and feature extraction.Waveform recognition includes detection for QRS wave, P wave and T wave [1].
There are many detection algorithms, including differential threshold [2,3], wavelet transform [4], neural network [5] and fuzzy rules [6].differential threshold is simple, with high processing speed, and easy to implement; wavelet transform is a time-frequency detection method with multi-scale decomposition of the original signal, and process data in the selected scale.Now many researchers use wavelet transform to improve the accuracy of ECG detection and feature extraction [7].Neural network need time to train the network, so this method costs a long time.fuzzy rules has high computational complexity, and is sensitive to baseline drift and high frequency noise.

Introduction to algorithm
Preprocessing of ECG Signal.ECG noise is mainly include the following categories [8]: frequency interference, baseline drift and respiratory interference.The dominant factor is the frequency interference and baseline drift, so these two interferences are mainly considered In ECG signal pre-processing stage.Because of the requirements of real-time, we use a more convenient method that is mean filtering [9].The specific approach is as follows: y(n) = (x(n)+x(n-1)+...+x(n-358)+x(n-359)) / M. (1) Where x(n) is the original ECG signal with interference, y(n) is the interference signal to be filtered out.We can get the filtered data by subtracting the interference signal with the original signal.M is the number of Sampling points.Figure 1 shows a original ECG signal whose sampling rate is 360Hz and the ECG signal after processing.It can be seen from the figure that the baseline drift of original signal waveform is obvious, and the original signal is interfered seriously by the noise.Mean filter removes most of the baseline drift and the noise is significantly reduced, as shown in figure 1.The abscissa unit is 3ms in the figure.Detection for QRS Wave Group.In this paper, an improved differential threshold method is proposed.The specific principle of this algorithm is as follows: because QRS wave is the most change-intense region in ECG waveform, the rising slope and down slope of the waveform changes more severe than that of other waveform.We can detect the derivative of the ECG sequence relative to the time (the change of slope) to locate the position of the QRS complex wave.Generally the greatest change of the slope in ECG wave is the rising edge and falling edge of R wave, the position of R wave is the zero point of the first derivative and the extreme point of the second derivative.By calculating the first order differential and second order differential of the filtered signal, combining with the empirical threshold and using window and amplitude threshold, we can determine the top of the QRS characteristic wave.The slope method can be achieved in several ways.In this paper, the first order differential and second order differential are integrated together to detect QRS complex wave.Firstly the first and second order differential are squared, then summed together, finally use the energy value of QRS complex wave to detect the waveform.Such can highlight where changes fast in rising rate in complex wave.Considering that the central difference formula is the higher order infinitesimal of relative error square, we use differential equation formula in detection.The first-order differential form is as follow: ( The second-order differential form is:

Smart Technologies for Communication
The new data sequence F(n) is: This algorithm detects waveform using data series F(n) which represents the energy of the ECG signal.Experiment shows that the position energy centralized is corresponding to the position of QRS complex wave.We need to select a suitable threshold Th, then judge the sequences value: if there are three consecutive F(i)>Th or more, then the peak point of R wave is in the middle position.In each group of data sequences which meet F(i)>Th, its first point is the beginning of QRS complex wave, the last point is the end of QRS complex wave.The process of the algorithm is shown in figure 2.
Fig. 2 QRS wave group detection process The improved differential threshold method is used to detect the ECG signal with a good performance.After detecting dozens of ECG, there are 2400 R waves, including 4 missing detections and 2 false detections, the detection rate is 99.75%.The result is shown in figure 3.
Fig. 3 The result of R wave Detection for P,T Wave.In this paper, wavelet transform is adopted to detect P,T wave.We use mold extreme value method [10] to determine.The principle of detection for P wave and T wave is broadly consistent, so here we only introduce detection method for P wave: firstly determine PR Advanced Engineering Forum 4 interval according to the position of R peak, then calculate the window area of the P wave peak according to PR interval, finally search window forward to determine the position of P-wave peak according to the beginning of the QRS complex wave.Meanwhile, the wavelet of ECG signal is decomposed in four scales, and set zero outside the range of P wave peak in the fourth scale, then calculate the positive-negative modulus maxima in the processed data sequence.We can determine the position of P wave peak by the adjacent pairs of the positive-negative modulus maxima.
Biorthogonal Spline Wavelet Filter Bank.Because the wavelet transform does not involve the specific form of the wavelet function, we just need to know the two coefficients h k and g k .Because spline wavelet has a linear phase, which has a good correlation with the original signal.The number of filter coefficients is limited, and the coefficients are rational numbers with symmetry.This article adopts biorthogonal quadratic B-spline wavelet, which is the first derivative of a smooth function.The filters in [11] is used as follow: The coefficients of wavelet decomposition filter are: h 0 =1/4, h 1 =3/4, h 2 =3/4, h 3 =1/4; g 0 =-1/4, g 1 =-3/4, g 2 =3/4, g 3 =1/4.Figure 44 shows the specific decomposition in various scales.

Fig.4 ECG signal in the four-scale decomposition
The Relationship of P Peak Point And Modulus Maxima on Zero-Crossing Point.A typical ECG includes P wave, QRS wave, T wave, PR interval and QT interval.P wave is the adjacent wave before QRS wave group, T wave is the adjacent wave after QRS wave group.To achieve the characteristic parameters of ECG signal, we need to locate the ECG wave.In this paper, the position of P wave peak is determined by using the relationship between the modulus maxima and the peak point.First we calculate the modulus of the waveform which is decomposed by wavelet transform at each scale, and calculate the maximum of the modulus in the given interval.Then calculate the zero point of the positive-negative modulus maxima, which is the peak point of original waveform.The method for calculating local maxima is as follow: 1) Calculate the positive-negative modulus maxima in the range where P wave peaks distribute, and select 10 maximum of modulus maxima: M 1 , M 2 , M 3 ……M 10 .
2) Calculate the average of modulus maxima M.
Finally we can get the positive-negative modulus maxima pairs in the range of P wave peak, as shown in figure 5. Then the peak point of the P wave is calculated according to the correspondence between modulus maxima and the peak point, figure 6 shows the detection results.Fig. 5 The modulus maxima of P wave range Fig. 6 The result of P wave Determine the Beginning and the End of P Wave.For the P wave with a single peak, the starting point is determined by threshold, the qualification is the slope and the amplitude of the point.If the modules of amplitude of one point is the quarter of the modulus maxima next to it, and the absolute value of the slope of the point is less then 0.3, then this point is determined to be the starting point of P wave.For the P wave with double peaks, the starting point is the beginning of the positive maximum forward and the midpoint of the peak point, The endpoint was the end of the negative maximum and the midpoint of the peak point.The judgment of the point is identical with the P wave with a single peak.

Experiment and Results
The MIT-BIH standard arrhythmia database file is used as the experiment data, including 40 samples.The sampling rate of data is 360Hz.Table 1 shows the detection results of five representative signal waveforms in database respectively using the filter method [12], the template matching method and the algorithm proposed in this paper.File 101 is the normal rhythm with noise; File 105 is the normal rhythm interfered by multiple noises seriously; File 201 is the rhythm with even rate and interfered by noise seriously; File 217 is the rhythm using the heart pacemaker; File 222 is the atrial ectopic rhythm interfered by high frequency noise and artifacts seriously.
From table 1 we can see that the correct detection rate of this algorithm is higher than filter method and template matching method in file 105, 201 and 222.40 different quality samples of MIT-BIH library files are tested.A total of 91263 characteristic waves are detected with 255 false detections.The average detection accuracy of wave group is up to 99.72%.It can be seen that the differential threshold-wavelet transform method has a good detection performance.In particular, the performance is excellent obviously for P, T wave detection.

Conclusion
This paper first discusses the advantage of the differential threshold-wavelet transform in the ECG signal waveform detection.On this basis, The coefficients of biorthogonal spline wavelet filter is given, which is used for the decomposition of the ECG signal and the detection of QRS complex wave, P wave and T wave.It can be seen from the experimental results that differential threshold can complete the detection of the QRS wave group with high quality.P wave and T wave is detected by biorthogonal wavelet transform, which improve the accuracy of waveform detection.So it can be seen that the detection rate of the method proposed in this paper is increased, compared to traditional methods and the template matching method.This algorithm could detect the characteristics of ECG wave group with high accuracy, high efficiency and excellent real-time performance.

Fig. 1
Fig.1 Original signal and Signal after median filtering