Efficient Fiducial Point Detection of ECG QRS Complex Based on Polygonal Approximation

Electrocardiogram signal analysis is based on detecting a fiducial point consisting of the onset, offset, and peak of each waveform. The accurate diagnosis of arrhythmias depends on the accuracy of fiducial point detection. Detecting the onset and offset fiducial points is ambiguous because the feature values are similar to those of the surrounding sample. To improve the accuracy of this paper’s fiducial point detection, the signal is represented by a small number of vertices through a curvature-based vertex selection technique using polygonal approximation. The proposed method minimizes the number of candidate samples for fiducial point detection and emphasizes these sample’s feature values to enable reliable detection. It is also sensitive to the morphological changes of various QRS complexes by generating an accumulated signal of the amplitude change rate between vertices as an auxiliary signal. To verify the superiority of the proposed algorithm, error distribution is measured through comparison with the QT-DB annotation provided by Physionet. The mean and standard deviation of the onset and the offset were stable as −4.02±7.99 ms and −5.45±8.04 ms, respectively. The results show that proposed method using small number of vertices is acceptable in practical applications. We also confirmed that the proposed method is effective through the clustering of the QRS complex. Experiments on the arrhythmia data of MIT-BIH ADB confirmed reliable fiducial point detection results for various types of QRS complexes.


Introduction
Electrocardiogram (ECG) signals are electronically converted signals from the depolarization and repolarization of the atria and ventricle [1]. Generally, signals are composed of a P-wave, QRS complex, and T-wave, which occurred in the depolarization of the atrium and ventricle, and the repolarization of the ventricle, respectively [2,3]. Signals are determined by cardiac activity, so the signal instantly shows an arrhythmia. Signal analysis to diagnose arrhythmia has been widely used to recognize the deformation of the signal and analyze the feature value when arrhythmia occurs [4], and it is used for monitoring such as mental stress [5] and fear [6]. The study of signal analysis is subdivided according to various techniques and their purposes. In general, the signal analysis system can be divided into the noise removal step [7], fiducial point detection step [8][9][10], and feature value acquisition and arrhythmia classification step [11][12][13]. Various applications related to signal analysis include a signal monitoring system [14], heart rate measurement, signal compression [15,16], personal authentication [17,18], and so on.
The fiducial point detection step identifies the most important fiducial points of the ECG signal, which are represented by the onset, the peak, and the offset of the P-wave, the QRS complex, and the T-wave [8,[19][20][21][22][23]. With accurate detection of these fiducial points, the width and the interval information of ECG waveforms used as feature values can be accurately measured. Therefore, the detection of accurate fiducial points is an important research field that greatly affects all subsequent ECG signal analysis.
The R-peak, which is the peak of the QRS complex, is the easiest to detect because it has the largest amplitude value. It is used not only for measuring heart rate, but also for detecting other fiducial points. Typical R-peak detection methods are based on the Pan's method, which is approximately 99% accurate. However, accurate detection methods of the fiducial points of the QRS complex other than the R-peak have been not clearly determined. Their low detection rate and inaccuracy are problematic due to signal deformation caused by various arrhythmias. These difficulties stem from the ambiguity of the reference regions that serve as a starting point.
Among various signal compression techniques, a method using polygonal approximation compresses a signal through a small number of vertices. In this case, since the onset and offset of the waveform represent the boundary between the waveform region and the baseline region, they are well-preserved as vertices. Figure 1 illustrates the difference between the existing fiducial point detection method and the polygonal approximation method.  As shown in Figure 1a, since the existing technique uses all samples, the position of the fiducial point is ambiguous due to the samples having similar feature values nearby. Therefore, there is a high possibility of error in the threshold value, and the detection result is unreliable.
On the other hand, since the polygonal approximation uses the atomic vertices, there is a large difference in the feature values of the vertices. As shown in Figure 1b, even if the tolerance used in the approximation and the number of vertices changes, the fiducial point can be represented as a vertex of the same or similar position, so that stable detection thereof is possible.
In this paper, we propose a curvature-based vertex selection technique to solve the ambiguity of the fiducial points in the QRS complex. Our approach is roughly divided into three stages. The first stage consists of initial vertex selection using curvature-based polygonal approximation. Since the curvature value of the fiducial point is large, most of the fiducial points are represented as vertices. The second stage is an incremental vertex selection using repetitive sequential polygonal approximation, and the third stage performs an additional vertex optimization step using dynamic programming. These steps are applied for a missing case due to ambiguous curvature value.
After applying the polygonal approximation, unwanted variations of the QRS complex-such as the presence of Q-waves, S-waves, and the polarity of the waveform-remain a major problem. To mitigate the side effects of this problem, we have prepared an auxiliary signal by accumulating data from the polygonal approximation signal. This cumulative signal monotonically increases by accumulating the absolute value of the rate of change of the amplitude between the vertices of the polygonal signal. Thus, by effectively expressing and emphasizing the feature of the fiducial point, we could effectively represent changes in the QRS complex's shape and polarity. From the cumulative signal, we analyze feature values for each vertex, such as the amplitude difference between R-peak and vertex, the time difference between reference point and vertex and the angles with neighbor vertices. Then, we determine the vertex with the largest sum of these feature values as a fiducial point.
This paper is organized as follows. Section 2 briefly reviews the ECG signal composition and explains why detecting the fiducial point is relatively difficult. Section 3 introduces the curvature-based vertex selection technique proposed in this paper and shows the expected benefits when applied to ECG signals. Section 4 details our algorithm for generating the cumulative signal from the polygonal approximated signal and detecting the fiducial point therefrom. In Section 5, the performance of the proposed algorithm is verified through experiments on QT-DB [24] and MIT-BIH ADB [25], and Section 6 concludes the paper.

Composition of ECG Signal
The ECG signal, which consists of the P-wave, QRS complex, and T-wave, includes the corresponding onset, offset, and peak points, which are referred as fiducial points. Figure 2 shows the fiducial points and feature values of the P-wave, QRS complex, and T-wave of the ECG signal. As shown in Figure 2, the ECG signal is divided into a waveform region in which the amplitude is changed by depolarization and repolarization, and a baseline region in which no amplitude change occurs. The boundary point is a fiducial point of each waveform. However, the actual input signal contains various noise, not ideal forms, as shown in Figure 2. Typical types of noise are as follows [26][27][28][29].
1. Power line interference: various high frequency noise according to country. 2. Baseline wander: a low-frequency noise (0.15 up to 0.3 Hz). This noise results from the patient breathing and leads to a baseline shift in the signals. 3. Electrode contract noise, electrode motion artifacts, muscle contractions, electrosurgical noise, instrumentation noise, and so on.
1 and 2 are typical high-and low-frequency ECG signal noises, respectively. Since noise complicates the baseline, it is difficult to estimate baseline and thus detect the boundary with an ambiguous waveform. Most of study use the bandpass filter for suppress noises and in some case, it uses a notch filter [30] for aiming to suppress the power line interference, such as high frequency of 50 Hz or 60 Hz. Figure 3 shows the result of applying a high-pass and low-pass filter to suppress baseline deviation and power line interference.  Peaks, such as the R-peak, can be easily detected because the amplitude has a local maximum or minimum and the rate of amplitude change is large enough. In contrast, the boundary between the baseline and the waveform is still ambiguous, even when filtering is applied. This is because the amplitude change occurs slowly, and the features are similar to the surrounding samples. In this paper, we propose an effective fiducial point detection technique by emphasizing ambiguous fiducial points based on polygonal approximation.

Polygonal Approximation of ECG Signal
Signal approximation techniques have been widely studied by using polygonal approximation, such as sequential polygonal and cyclic polygonal approximation, and polynomial approximation, such as B-spline. However, these techniques are problematic, since they select too many vertices and errors are not minimized.
In the curvature-based vertex selection technique [31], curvature-based polygonal approximation [32], sequential polygonal approximation [33], and dynamic programming [34] are proposed as methods for minimizing vertices and resultant errors. This algorithm selects an initial vertex using a curvature-based polygonal approximation. A fiducial point with a large curvature is selected as a vertex. However, there is a problem when a fiducial point having an ambiguous curvature value is not selected as an initial vertex. To solve this problem, the sequential polygonal approximation method is adopted to select additional vertices, and the dynamic programming technique can optimize the position of the additional vertices by minimizing errors.
The algorithm flow of the curvature-based vertex selection method for the input ECG signal (S) is summarized as follows.
1. Separate the R-R section of the input signal. In this paper, we detect the R-peak by Pan's method. 2. After calculating the curvature for the separated R-R section, the curvature-based polygonal approximation technique is applied to select the initial vertices. Equation (1) represents the set of initial vertices.
3. We apply the sequential polygonal approximation method to the interval between each initial vertex to select additional vertices. Equation (2) represents a set of N V i − 1 additional vertices between the i-th initial vertex and the i + 1-th initial vertex, and both end vertices coincide with the two initial vertices.
4. Dynamic programming is applied to the additional vertices to optimize their position. Equation (3) is a set of corrected vertices for the additional vertex set V i .
5. Repeat steps 2-4 to proceed with polygonal approximation for the entire input signal. Equation (4) represents the set of N V vertices as the result of vertex selection. Figure 4 shows the result of each step of the polygonal approximation. In general, when the curvature-based polygonal approximation is applied to a pole with a large curvature value, it appears as an initial vertex, as shown in Figure 4a. However, with a smooth transition of the amplitude value near the fiducial point, such as the onset of the QRS complex and the offset of the P-wave in Figure 4b, there is a side effect wherein the fiducial point is not selected as the initial vertex. By applying additional vertex selection and correction to solve this problem, the fiducial points are efficiently represented by the vertex as shown in region A, and the similarity between the original signal and the approximated signal is preserved, as shown in B and C.

Fiducial Point Detection Based on Polygonal Approximation
The curvature-based vertex selection technique represents the ECG signal as a small number of vertices, and then detects the onset and offset of the QRS complex by analyzing the characteristic values of each vertex. However, it is not easy to express the characteristic value from the fiducial point because the QRS complex has various shapes based on its polarity, as well as the presence of the Qand S-peaks.
To resolve the difficulty of extracting features from the QRS complex's ambiguous shape, robust fiducial point detection using various auxiliary signals has been proposed. In Pan's method, the R-peak detection is assisted by an auxiliary signal generated by the derivative of the signal and an average filter. In Manriquez's method, the fiducial point is detected by a threshold value of the auxiliary signal generated from the Hilbert transform. This paper is also based on the auxiliary signal, for which we propose the cumulative signal of the polygonal approximation to preserve morphological features of the vertex that represent the fiducial point.

Generate the Cumulative Signal
To acquire the cumulative signal, we first obtain the amplitude difference (V D ) for the vertex, as shown in Equation (4).
With the absolute value of the amplitude difference obtained using Equation (5), that value is accumulated as shown in Equation (6) to generate the cumulative signal.
This simplifies the signal as monotonically increased, even if the QRS complex appears as a downward wave or includes Q-peaks and S-peaks that appear as downward or upward waves. The vertex corresponding to the fiducial point also maintains the feature of dividing the baseline and waveform regions. Figure 5 shows the cumulative signal results for various shapes of the polygonal approximation signals.
(a) With Q,S peak  As shown in Figure 5 even if the signal includes Q-or S-peaks, or the QRS complex shows a downward wave, it can be expressed as a cumulative signal of similar shape. In this case, the features are also similar, so that effective fiducial point detection is possible.

Algorithm of Fiducial Point Detection
The feature value of each vertex of the accumulated signal is analyzed to determine the fiducial point. In this paper, we propose three types of features for each vertex to determine the fiducial point: the amplitude difference between R-peak and vertex, the time difference between the reference point and vertex, and the angles with neighbor vertices. Figure 6, which is magnified from red-dotted box in Figure 5b, show amplitude difference between R-peak and vertex from this cumulative signal. The onset and offset of the QRS complex are the boundary points between it and the baseline region. The amplitude difference between the R-peak and the vertex in the accumulated signal is close to the maximum value near the fiducial point. Therefore, the Q-peak with a largest amplitude difference in Figure 5a become a smallest amplitude difference in the cumulative signal, which makes it easier to determine the fiducial point. Equation (7) represents the feature value obtained by using the amplitude difference between the R-peak and the vertex.

Amplitude Difference between R-Peak and Vertex
A i L denotes an amplitude difference between the previous R-peak and vertex, which is used to detect the offset. Similarly, A i R is used to detect the onset. In this paper, we suggest the time difference as a second feature value for excluding the case of detecting the onset of the P-wave. Generally, the normal width of the QRS complex is about 0.08 to 0.12 s. We use a reference point based on the point 0.3 s away from the R-peak for estimating the time difference and consider that the larger the time difference is, the more likely it is to be the fiducial point.

Time Difference between Reference Point and Vertex
If the ventricular arrhythmia occurred and the width of the QRS complex is increased, fiducial point may have lower time difference feature value when there is a vertex at notch in QRS complex. However, this problem can be easily solved from the amplitude difference between previous R-peak and vertex, since the amplitude of notch and fiducial point is similar to previous R-peak and baseline, respectively.
Equation (8) represents the feature value obtained by using the time difference between the references and vertex.
F denotes a sampling frequency and T i L denotes a time difference between the previous R-peak and vertex, which is used to detect the offset. Similarly, T i R is used to detect the onset.

Angles with Neighbor Vertices
Since the fiducial point is boundary between the waveform region and the baseline region, most significant feature of vertices of fiducial point is angle between the horizontal line and straight line connecting the neighbor vertex. Figure 8 shows the angles of the vertices corresponding to the fiducial points with the left and right vertices in the cumulative signal.
In the case of the onset, the angle with the left vertex is close to 0 degrees, and the angle with the right vertex is close to 90 degrees. In the case of the offset, it is reversed. θ i L and θ i R mean the left and right angles of the i-th vertex, respectively.

Detecting the Fiducial Point
Based on the feature values of the fiducial point, we can calculate the feature value of each vertex in the searching interval. Our approach provides a method to select the point with the highest probabilities of being the fiducial point by summarizing all feature values. Equations (9) and (10) represent equations used to detect the onset and offset of the QRS complex, respectively. where, and ω θ are weight functions for normalizing each feature value. ω A uses the maximum value in the search interval because sensitive amplitude changes in the QRS complex may be affected according to each heartbeat. ω T uses 0.3 s, which means the reference, and the ω θ C and ω θ S are used to have higher feature value when the baseline and waveform angles are close to 0 and 90 degree, respectively.
In the case of the baseline direction angle, the square root is added to consider that the vertex corresponding to the fiducial point may have a high value of about 30 to 40 degrees due to noise or signal distortion. On the other hand, since the waveform angle has a low possibility of distortion because of the large amplitude change, a square is added to have a low feature value for the vertices except the fiducial point. Figure 9 is the flowchart of our proposed algorithm. In the preprocessing step, noise suppression and R-peak detection are performed. Breathing and muscle movements cause the low-frequency noise, and power noise of 30 Hz or 60 Hz causes the high-frequency noise. In this paper, these noises are suppressed using a Butterworth bandpass filter of 1-25 Hz and the most widely known Pan's method is applied to R-peak detection. The QT-DB and MIT-BIH ADB provided by Physionet are used to evaluate the performance of the proposed algorithm.

Experiment in QT-DB
The QT-DB contains a total of 105 fifteen-minute excerpts of two-channel ECGs, which were carefully selected to avoid significant baseline wander or other artifacts. Within each record, around 30 numbers of beats were manually annotated by cardiologists, who can identify the onset, peak, and offset of the QRS complex. The proposed algorithm works on a single-channel signal, while cardiologist manually recorded one annotation considering both channel of signal simultaneously. Therefore, to compare our approach with the manual annotations on the QT-DB for each of the two single-channels, it is reasonable to choose the annotation result of the channel with less error [10]. After all the errors are obtained, the mean of total error µ and the standard deviation of total error σ are computed by averaging the intrarecording mean and standard deviation of each set of data. The standard deviation of the total error is used to measure the criterion for the algorithm's stability. In the CSE working party [35], tolerances for standard deviation of the error for the onset and offset of QRS complex are suggested as 6.5 ms and 11.6 ms, respectively.
We summarized the experimental results by our proposed method in Figure 10 according to the types of DB constituting the QT-DB.  Most of the data is regarded as having satisfied the tolerance or shown on the detection result similar to the tolerance. Especially in the case of MIT-BIH normal sinus rhythm DB (represented as a red marker), it can be confirmed that the standard deviation of the total error satisfies tolerance. On the other hand, MIT-BIH arrhythmia DB and sudden-death patient DB, represented by a black marker, contains various arrhythmia heartbeats and caused large errors compared to another DB. Table 1 shows the performance of the proposed algorithm compared to the existing detection algorithm. As with other algorithms, the standard deviation of error of the onset is out of tolerance. On the other hand, the offset satisfies the tolerance and confirmed a lower error than other algorithms.
To analyze experimental results in detail, we tried to cluster the experimental results for each data set. The experimental results of some data according to the types of QRS complex are shown in Figure 11. Figure 11. Clustering results.
Clustering was performed around the R-peak, and the position of the R-peak was shown as the origin. As shown in Figure 11a,b, not only the detection results of the normal type of QRS complex are stable, but also the fiducial point detection is well-performed for various types of QRS complex, such as absence of Q-peak, widen QRS complex and downward QRS complex (see Figure 11c-f).

Experiment in MIT-BIH ADB
Since MIT-BIH ADB only annotate the arrhythmia type of each heartbeat, statistical analysis for fiducial point detection is hard. We use the mean length of QR section, which start from the onset to R-peak, and RS section, which start from R-peak to the offset, as reference for onset and offset detection, respectively. According to the type of heartbeat, we separate into normal heartbeats and abnormal heartbeats, and calculate the mean and standard deviation of each type of heartbeats, respectively.
However, in the case of arrhythmia, there are various types of abnormal heartbeats. Most occur with premature atrial contraction (PAC; annotated as 'A') or premature ventricular contraction (PVC; annotated as 'V'), with the remainder very rare. For example, supraventricular premature or ectopic beat (SVP; annotated as 'S') only appears twice in record 208 over the total 107,265 heartbeats in MIT-BIH ADB. Thus, the test for abnormal heartbeat only proceeded for one of the most typical abnormal heartbeat types for records with more than 30 PACs or PVCs. Figure 12 shows the distribution of standard deviation of fiducial points in MIT-BIH ADB.  Figure 12a is distribution of fiducial points for normal heartbeats (annotated as 'N') or other representable type of heartbeat, such as left bundle branch block (LBBB; annotated as 'L'), right bundle branch block (RBBB; annotated as 'R') or pacemaker (PM; annotated as '/'). Considering that the length of each record is 30 min, which is 60 times longer than the length of QT-DB used in Section 5.1, and most signals are unstable with various arrhythmia, it can be confirmed that the detection result of fiducial point is excellent.
Generally, since the PAC does not affect the QRS complex, the stability of the fiducial point detection is high as shown in Figure 12b. On the other hand, since PVC deforms QRS complex into various shapes, the standard deviation of width is increased. Table 2 represents the detailed distribution of stable data in Figure 12b. In the case of PVC, the results for uniform PVC are shown.  Figure 13 shows the results of the proposed algorithm for the part of the MIT-BIH ADB data in which normal heartbeat and PVC occur consecutively. The proposed algorithm detected the fiducial points regardless of whether Q-or S-waves are present or not in the normal heartbeat. In addition, we could reliably detect the fiducial points for the various types of QRS complex with arrhythmia.
From this experiment, we can confirm that the proposed polygonal approximation method can effectively detect fiducial points compared with other algorithms. In addition, it obtains stable results for various types of QRS including arrhythmia. In some cases, detection error is high due to the acquisition of signals such as the V2 and V5 channel, rather than signal acquisition by the modified lead II (MLII) channel, which emphasizes the QRS complex. The distortion in the preprocessing process causes an error. Therefore, we consider that the signal acquisition clearly reflecting the shape of the QRS complex-such as the MLII channel-or the stable noise suppression technique can improve the performance of the proposed algorithm.

Conclusions
In this paper, the proposed algorithm focuses on mitigating the ambiguity of the fiducial point by polygonal approximation to extract the feature points of ECG signals, motivated from the characteristic that the polygonal approximation preserves the fiducial point as a vertex. Therefore, our approach resulted in better performance compared to other signal compression techniques. In addition, we propose an effective auxiliary signal for stable detection results in various types of QRS complex using these features. Experimental results show that the proposed auxiliary signal-based technique enables stable detection for various applications in real ECG databases equipped with QT-DB and MIT-BIH ADB.
In future research, the proposed method is required not only to expand the detection of P-and T-waves, but also to apply post-processing to improve the existing technique. This method can also be extended to study adaptive signal compression technique according to importance of intervals by reapplying fiducial point detection results. The trade-off between the accuracy and energy consumption could be achieved by adjusting the fiducial points compression ratio, so the extremely long-time ECG monitoring services are capable in the battery-operated wearable systems.