A Novel Wavelet-Based Algorithm for Detection of QRS Complex

: Accurate QRS detection is an important ﬁrst step for almost all automatic electrocardiogram (ECG) analyzing systems. However, QRS detection is di ﬃ cult, not only because of the wide variety of ECG waveforms but also because of the interferences caused by various types of noise. This study proposes an improved QRS complex detection algorithm based on a four-level biorthogonal spline wavelet transform. A noise evaluation method is proposed to quantify the noise amount and to select a lower-noise wavelet detail signal instead of removing high-frequency components in the preprocessing stage. The QRS peaks can be detected by the extremum pairs in the selected wavelet detail signal and the proposed decision rules. The results show the high accuracy of the proposed algorithm, which achieves a 0.25% detection error rate, 99.84% sensitivity, and 99.92% positive prediction value, evaluated using the MIT-BIT arrhythmia database. The proposed algorithm improves the accuracy of QRS detection in comparison with several wavelet-based and non-wavelet-based approaches.


Introduction
The signal processing and analysis of the electrocardiogram (ECG) is an important and noninvasive tool for identifying abnormal heart function.The QRS complex associated with the ventricular contractions is the most significant signal within an ECG cycle.The accurate detection of QRS is a crucial issue for an automatic ECG analysis system.Though a typical ECG waveform consists of P, Q, R, S, and T waves, the measured ECG may have different waveforms due to abnormal rhythms, and its waveform is also easily contaminated by several noise sources, such as 50 or 60 Hz power line noises, muscle contractions, baseline drift, and motion artifacts.A wide variety of ECG waveforms make it difficult to detect QRS accurately.
Previous studies have proposed numerous QRS detection methods, which can be divided into two stages: The ECG signal preprocessing and QRS peak decision.The purpose of the ECG signal preprocessing is to remove the low-frequency baseline drift and high-frequency noise.Many previous studies have designed linear or non-linear filters to remove additive noise and interferences, such as moving averaging filters [1], low-pass filters [2], bandpass filters [2][3][4][5], non-linear filters [6], quadratic filters [7], and Savitzky-Golay (SG) smoothing filters [8].The methods for noise removal based on the wavelet transform have also appeared in the previous works by removing part of the approximation and detail wavelet coefficients to filter out high frequency noise and baseline drift effects, respectively [9][10][11][12][13][14].Other studies have proposed noise removal methods based on mathematical morphology [15] and artificial neural networks [16].
The QRS peak decision is to find the position of the most prominent peak within a QRS complex.The real time detection of QRS peaks proposed by Christov [1] is based on a comparison of the absolute values of the summed differentiated ECG signals and the adaptive threshold.The threshold combines three parameters: An adaptive slew-rate value, a second value which rises when high-frequency noise occurs, and a third one intended to avoid missing low amplitude beats.Manikandana and Soman [3] developed an R-peak detector based on the Shannon energy envelope (SEE) estimator.Their method is better at detecting R-peaks in the case of wider and small QRS complexes, negative QRS polarities, and sudden changes in QRS amplitudes.The approach proposed by Karimipour and Homaeinezhad [11] used the first-order derivative of the ECG signal and combined adaptive threshold.The detection and delineation of P-and T-waves were achieved by a correlation analysis conducted between signals and their templates.Castells-Rufas and Carrabina [6] designed a simple real-time QRS detector using the MaMeMi (Maximum Mean Minimum) filter, which can detect the QRS signal in a simple way with minimal computational cost and resource needs using a non-linear filter.The MaMeMi filter is a high-pass non-linear filter which can effectively remove the baseline drift and also reduce the effect of the T wave.Phukpattaranont [7] developed a QRS detection algorithm based on the quadratic filter which can enhance the QRS-to-noise ratio and then allow us to use a single fixed threshold to detect the QRS.Farashi [13] proposed a method based on the analysis of multiresolution time-dependent entropy.It calculates the entropy of the ECG signal at different temporal resolutions and can improve the accuracy for the detection of various QRS morphologies.The decision rule proposed by Sharma and Sunkaria [8] is based on the root-mean-square of the signal.Their techniques include a novel approach for isoelectric line detection and a kurtosis-based false positive correction method.Yazdani and Vesin [17] proposed an adaptive mathematical morphology scheme for extracting QRS complexes and fiducial points.An adaptive structuring element in mathematical morphology operators is updated after the detection of each heartbeat for a more robust and precise detection.Chen and Chuang [5] developed an R-peak recognition method for wearable single-lead ECG devices.An ECG signal transformation was proposed to enhance QRS segments and restrain P and T waves.The QRS fiducial point is determined based on the detected crests and troughs of the transformed signal, and the R point can be recognized based on four QRS waveform templates.
Moreover, several studies have proposed wavelet-based methods for the detection of QRS peaks.Merah et al. [12] proposed an R-peaks detection method based on a stationary wavelet transform (SWT).Their algorithm used the information of local maxima, minima, and zero crossings of the fourth level detail coefficients to identify the significant points for detection and delineation of the QRS complexes, as well as the detection and identification of the QRS individual wave peaks.Berwal et al. [14] introduced a QRS complex detector based on a biorthogonal spline wavelet transform for wearable healthcare devices.The wavelet detail coefficients of the third and fourth levels are multiplied using the Booth multiplier, and a soft threshold method is applied to get the QRS peaks by the QRS peak detector block.The method proposed by Zidelmal et al. [18] used the product of the wavelet detail coefficients of the fourth and fifth levels to localize QRS complexes after a preliminary investigation of QRS spectral parameters.Bouaziz et al. [19] developed a method based on the power spectrum of the combination of the wavelet detail coefficients at the fourth and fifth levels.A moving window with specific width (160 ms) is used to investigate the positions of the maximum amplitude points in each window location, defining the QRS complex positions.
All of the above-mentioned techniques have demonstrated their superiority in the detection of QRS peaks.However, if we consider the requirements of hardware complexity and detection accuracy together, wavelet-based approaches can play a trade-off role [14,20].Providing a noise-free ECG signal is important for the QRS peak decision.However, noise is usually broadband and overlaps with the QRS complex.It is not easy to accurately separate the noise from the ECG signal without destroying the QRS waveform.The pre-filtering out of the high-frequency components not only reduces the noise level but also causes a reduction in the amplitudes of the QRS peaks and thus reduces their the detection accuracy.This study therefore proposes a novel wavelet-based algorithm for the detection of QRS complex peaks.A four-level biorthogonal spline wavelet transform is introduced for the decomposition of ECG signals.The wavelet detail signals of the second, third, and fourth levels are employed in the proposed QRS peak detection algorithm.A noise evaluation method is proposed to quantify the amount of noise and to select a lower-noise signal between the third and fourth wavelet detail signals for detection of QRS peaks instead of pre-filtering out the high-frequency noise in the preprocessing stage.
The rest of this paper is organized as follows.Section 2 describes the ECG recordings obtained from the MIT-BIH arrhythmia database.Section 3 presents the proposed wavelet-based algorithm for detection of the QRS complex peaks.Results and discussion are given in Section 4. Finally, Section 5 concludes this study.

ECG Recordings
All of the ECG data used in this study were obtained from the MIT-BIH arrhythmia database [21], which contains common and life-threatening arrhythmic heartbeats.This database contains 48 recordings of two-channel ambulatory ECG recordings with a length of 30 min, a sampling frequency of 360 Hz, and 11-bit resolution over a 10 mV range.In most recordings, the upper lead is a modified limb lead II (MLII), and the lower lead is usually a modified lead V1 (occasionally V2 or V5, and in one instance V4).Each recording was independently annotated by two or more cardiologists.There are a total of 109,488 beats included in this study that were annotated as one of 15 possible heartbeat classes.reduces their the detection accuracy.This study therefore proposes a novel wavelet-based algorithm for the detection of QRS complex peaks.A four-level biorthogonal spline wavelet transform is introduced for the decomposition of ECG signals.The wavelet detail signals of the second, third, and fourth levels are employed in the proposed QRS peak detection algorithm.A noise evaluation method is proposed to quantify the amount of noise and to select a lower-noise signal between the third and fourth wavelet detail signals for detection of QRS peaks instead of pre-filtering out the high-frequency noise in the preprocessing stage.The rest of this paper is organized as follows.Section 2 describes the ECG recordings obtained from the MIT-BIH arrhythmia database.Section 3 presents the proposed wavelet-based algorithm for detection of the QRS complex peaks.Results and discussion are given in Section 4. Finally, Section 5 concludes this study.

ECG Recordings
All of the ECG data used in this study were obtained from the MIT-BIH arrhythmia database [21], which contains common and life-threatening arrhythmic heartbeats.This database contains 48 recordings of two-channel ambulatory ECG recordings with a length of 30 minutes, a sampling frequency of 360 Hz, and 11-bit resolution over a 10 mV range.In most recordings, the upper lead is a modified limb lead II (MLII), and the lower lead is usually a modified lead V1 (occasionally V2 or V5, and in one instance V4).Each recording was independently annotated by two or more cardiologists.There are a total of 109,488 beats included in this study that were annotated as one of 15 possible heartbeat classes.

Signal Preprocessing
Each ECG recording was segmented by a sliding window of 4096 samples.Figure 2 illustrates the segmentation of the ECG recording.There is an overlap of 150 samples between two adjacent windows.The design of the 150-sample overlap is for those incomplete QRS complexes located at the end of the 4096-sample segments, which would be misidentified as Not QRS peaks.They can be completely included in the beginning of the next 4096-sample segment because of the overlap of 150 samples.Two median filters were then applied to remove the low-frequency baseline drift [22].Each ECG segment was first filtered by a median filter with a width of 200 ms (i.e., 72 samples at a sampling rate of 360 Hz) to remove the QRS and P waves; each segment was then filtered by a median filter with a width of 600 ms to remove the T waves.Hence, the baseline drift signal can be extracted by the output of the second median filter, and the baseline drift eliminated ECG recording can be obtained by subtracting the estimated baseline drift from the original ECG signal.Figure 3 shows the illustration of removing the low-frequency baseline drift, where the original ECG is the input signal, M1 and M2 are the outputs of the first and second median filters, respectively, and the filtered ECG is the baseline drift eliminated ECG.It is shown that most of the baseline drift can be removed.The high frequency components of the QRS wave were not pre-filtered out in the preprocessing stage.

Signal Preprocessing
Each ECG recording was segmented by a sliding window of 4,096 samples.Figure 2 illustrates the segmentation of the ECG recording.There is an overlap of 150 samples between two adjacent windows.The design of the 150-sample overlap is for those incomplete QRS complexes located at the end of the 4096-sample segments, which would be misidentified as Not QRS peaks.They can be completely included in the beginning of the next 4096-sample segment because of the overlap of 150 samples.Two median filters were then applied to remove the low-frequency baseline drift [22].Each ECG segment was first filtered by a median filter with a width of 200 ms (i.e., 72 samples at a sampling rate of 360 Hz) to remove the QRS and P waves; each segment was then filtered by a median filter with a width of 600 ms to remove the T waves.Hence, the baseline drift signal can be extracted by the output of the second median filter, and the baseline drift eliminated ECG recording can be obtained by subtracting the estimated baseline drift from the original ECG signal.Figure 3 shows the illustration of removing the low-frequency baseline drift, where the original ECG is the input signal, M1 and M2 are the outputs of the first and second median filters, respectively, and the filtered ECG is the baseline drift eliminated ECG.It is shown that most of the baseline drift can be removed.The high frequency components of the QRS wave were not pre-filtered out in the preprocessing stage.the baseline drift.The proposed wavelet-based algorithm includes signal preprocessing, a four-level dyadic wavelet transform, a search of candidate extreme points, a determination of candidate extremum pairs, an evaluation of noise, a calculation of candidate QRS peak positions, and a determination of QRS Peaks.The details are described in the following sections.

Signal Preprocessing
Each ECG recording was segmented by a sliding window of 4,096 samples.Figure 2 illustrates the segmentation of the ECG recording.There is an overlap of 150 samples between two adjacent windows.The design of the 150-sample overlap is for those incomplete QRS complexes located at the end of the 4096-sample segments, which would be misidentified as Not QRS peaks.They can be completely included in the beginning of the next 4096-sample segment because of the overlap of 150 samples.Two median filters were then applied to remove the low-frequency baseline drift [22].Each ECG segment was first filtered by a median filter with a width of 200 ms (i.e., 72 samples at a sampling rate of 360 Hz) to remove the QRS and P waves; each segment was then filtered by a median filter with a width of 600 ms to remove the T waves.Hence, the baseline drift signal can be extracted by the output of the second median filter, and the baseline drift eliminated ECG recording can be obtained by subtracting the estimated baseline drift from the original ECG signal.Figure 3 shows the illustration of removing the low-frequency baseline drift, where the original ECG is the input signal, M1 and M2 are the outputs of the first and second median filters, respectively, and the filtered ECG is the baseline drift eliminated ECG.It is shown that most of the baseline drift can be removed.The high frequency components of the QRS wave were not pre-filtered out in the preprocessing stage.

Four-Level Dyadic Wavelet Transform
The dyadic wavelet transform was applied in this study to decompose ECG signals into different frequency bands for detection of QRS peaks.The dyadic wavelet transform for a continuous signal x(t) is defined as follows: Appl.Sci.2019, 9, 2142 where u and 2 j denote the translation and dyadic scaling parameters, respectively.The selected prototype wavelet ψ(t) is a biorthogonal spline which has been applied to ECG signals in a previous study [14].Biorthogonal wavelets built with splines are especially attractive because of their short support and regularity [23].The corresponding low-pass filter H(z) and high-pass filter G(z) of the biorthogonal spline wavelet are given as follows [14]: which have the following impulse responses: The four-level dyadic wavelet transform in this study was implemented by the Mallat algorithm [24], as shown in Figure 4, which uses a two-channel filter bank to decompose ECG signals by the low-pass filter H(z) and high-pass filter G(z).a1, a2, a3, and a4 denote the low-frequency approximation signals of the first, second, third, and fourth levels, respectively, and d1, d2, d3, and d4 are the high-frequency detail signals of different levels.Figure 5 demonstrates several common QRS waves and their high-frequency detail signals d1, d2, d3, and d4, where N, V, L, and Q denote normal beat, ventricular premature contraction beat (VPC), left bundle branch block beat, and unclassifiable beat, respectively.Figure 6 further plots the extreme detail signals, including only the extreme values of the wavelet detail signals, named d1', d2', d3', and d4' according to d1, d2, d3, and d4 in Figure 5, respectively.It can be observed that the rising and falling segments of a QRS peak produce a negative and a positive extreme point, respectively, indicated by arrows.The pair of a negative and a positive extreme point is defined as an extremum pair in the study.The sharper the QRS peak, the larger the extreme value produced.Hence, we can detect the QRS peak by finding the largest extremum pair in the wavelet detail signals.The frequency ranges of the wavelet detail signals for d1, d2, d3, and d4 are from 90 Hz to 180 Hz, from 45 Hz to 90 Hz, from 22.5 Hz to 45Hz, and from 11.25 Hz to 22.5 Hz, respectively.Usually, the frequency range of the QRS complex wave is from 10 to 45 Hz [14].Hence, the detection of QRS peaks in this study is mainly based on the extreme detail signals of the third or fourth level, d3' or d4', according to the evaluation of noise amount.The d2' helps in identifying Por T-peaks.
The dyadic wavelet transform was applied in this study to decompose ECG signals into different frequency bands for detection of QRS peaks.The dyadic wavelet transform for a continuous signal x(t) is defined as follows: where u and 2 denote the translation and dyadic scaling parameters, respectively.The selected prototype wavelet ψ t is a biorthogonal spline which has been applied to ECG signals in a previous study [14].Biorthogonal wavelets built with splines are especially attractive because of their short support and regularity [23].The corresponding low-pass filter H z and high-pass filter G z of the biorthogonal spline wavelet are given as follows [14]: = −1 − 3 + 3 +  /4 (3) which have the following impulse responses:

Search of Candidate Extreme Points
Based on the wavelet detail signals, d2, d3, and d4, the following steps are developed for searching the candidate extreme points.

A rising segment A falling segment A negative extreme A positive extreme
Noisy QRS complex

Search of Candidate Extreme Points
Based on the wavelet detail signals, d2, d3, and d4, the following steps are developed for searching the candidate extreme points.

A positive extreme
Noisy QRS complex

Search of Candidate Extreme Points
Based on the wavelet detail signals, d2, d3, and d4, the following steps are developed for searching the candidate extreme points.
Step 1: Find the extreme detail signals, d2', d3', and d4', consisting of all the positive or negative extreme points which have sudden changes in slope in d2, d3, and d4, respectively.Step 2: Divide the extreme detail signals with a length of 4096 samples into four subsections with lengths of 1024 samples and then calculate the positive and negative thresholds, TH+ and TH−, respectively, as follows.
where M Max,i and M Min, i , i = 1, 2, 3, 4, denote the largest values of the positive extreme points and the smallest values of the negative extreme points for the four subsections.Each subsection is about 2.84 s at a sampling rate of 360 Hz and, hence, can at least include one QRS peak if the heartrate is greater than 21 bps.Before the detection of QRS peaks, it is easy to find the largest and smallest values of the extreme points produced by the QRS peaks in each subsection.The thresholds are defined by one fourth of the average values of four extreme values.The use of four extreme values is to avoid the thresholds being dominated by an extreme value that is too large or too small.
Step 3: Search the candidate extreme points with values larger than the positive threshold, TH+, or smaller than the negative threshold, TH−.A too-large positive or a too-small negative threshold may lose the extreme points produced by the true QRS peaks with smaller amplitudes.On the contrary, a too-small positive or a too-large negative threshold may include the extreme points produced by the noise peaks.The proposed TH+ and TH− are a compromise of the two.Step 1: Find the extreme detail signals, d2', d3', and d4', consisting of all the positive or negative extreme points which have sudden changes in slope in d2, d3, and d4, respectively.

Determination of Candidate Extremum Pairs
Step 2: Divide the extreme detail signals with a length of 4,096 samples into four subsections with lengths of 1,024 samples and then calculate the positive and negative thresholds,  + and  −, respectively, as follows.
−= 1 4 , +  , + , +  , 4 where  , and  , ,  = 1, 2, 3, 4, denote the largest values of the positive extreme points and the smallest values of the negative extreme points for the four subsections.Each subsection is about 2.84 seconds at a sampling rate of 360 Hz and, hence, can at least include one QRS peak if the heartrate is greater than 21 bps.Before the detection of QRS peaks, it is easy to find the largest and smallest values of the extreme points produced by the QRS peaks in each subsection.The thresholds are defined by one fourth of the average values of four extreme values.The use of four extreme values is to avoid the thresholds being dominated by an extreme value that is too large or too small.
Step 3: Search the candidate extreme points with values larger than the positive threshold,  +, or smaller than the negative threshold,  −.A too-large positive or a too-small negative threshold may lose the extreme points produced by the true QRS peaks with smaller amplitudes.On the contrary, a too-small positive or a too-large negative threshold may include the extreme points produced by the noise peaks.The proposed  + and  − are a compromise of the two.Condition 1: An extremum pair consists of a positive extreme point followed by a negative extreme point or a negative one followed by a positive one.This condition makes an extremum pair represent a positive or negative peak in the QRS wave.Condition 1: An extremum pair consists of a positive extreme point followed by a negative extreme point or a negative one followed by a positive one.This condition makes an extremum pair represent a positive or negative peak in the QRS wave.

Determination of Candidate Extremum Pairs
Condition 2: The positive and negative extreme values, y 1 and y 2 , of a candidate extremum pair are larger and smaller than the positive and negative thresholds defined in Equations ( 6) and (7), respectively.This condition makes a candidate extremum pair represent a peak with a large enough amplitude in the QRS wave.
Condition 3: The distance between the first and second extreme points of a candidate extremum pair, x 2 − x 1 , is less than 45 samples.This condition makes a candidate extremum pair represent a sharp enough peak in the QRS wave.This distance ranges from about 5 to 20 samples for narrower R waves produced by normal, paced, atrial premature beats, etc., and ranges from about 21 to 44 samples for wider R waves mostly produced by ventricular premature contraction beats.
According to the above three conditions, we can determine the candidate extremum pairs in d2', d3', and d4'.

Evaluation of Noise Amount
The detection of QRS peaks in this study is based on the candidate extremum pairs in d3' or d4' to find the positions of the corresponding candidate QRS peaks in the original ECG signal and to further identify the true QRS peaks.The selection of d3' or d4' is based on their noise amount.A noise evaluation method is proposed to quantify the amount of noise in d3' and d4'.We remove the extreme points which are greater than or smaller than 1.6 times the positive or negative thresholds in d3' and d4'.These removed extreme points represent the components possibly contributed by the QRS peaks, not by the noise.The remaining extreme points are applied to evaluate the amount of noise, which is defined as the sum of the square values of the remaining extreme points.If the noise amount in d3' is smaller than that in d4', the detection of QRS peaks is based on d3'; otherwise it is based on d4'.

Calculation of the Positions of the Candidate QRS Peaks in the Time-Domain
According to the candidate extremum pairs in d3' or d4', we define the following equation to calculate the positions of the corresponding candidate QRS peaks in the original ECG signal: where β denotes the time delay produced by the filtering of the wavelet filter banks.The values of β in d3' and d4' are 9 and 12 samples, respectively.If y 1 = y 2 , x p is located in the middle of x 1 and x 2 , then subtract β.If y 1 > y 2 .If x p is closer to x 2 , then subtract β.If y 1 < y 2 , x p is closer to x 1 , then subtract β.

Identification of QRS Peaks
Because it is possible that multiple candidate QRS peaks present within the same QRS complex and the candidate QRS peaks also include sharp P-and T-peaks, we propose the following decision rules to identify the most prominent QRS peak.The distance thresholds of 130 and 100 samples to define the following Cases 1, 2, and 3 are determined by pre-analyzing the relationships between the positions of all candidate QRS peaks and true QRS peaks annotated by the MIT-BIH arrhythmia database.
Case 1: The distance between the current candidate QRS peak and the previous QRS peak is greater than 130 samples.In this case, it is considered that the current candidate QRS peak is far enough from the previous QRS peak and, hence, is identified as a new QRS peak.This identified QRS peak may also be replaced by the next candidate QRS peak, according to the following Cases, 2.3 and 3.
Case 2: The distance between the current candidate QRS peak and the previous QRS peak is greater than 100 samples and less than 130 samples.In this case, it is considered that the current candidate QRS peak may be a new peak or a sharp T-peak.
Case 2.1: The current candidate QRS peak and the previous QRS peak both have a candidate extremum pair in the higher frequency d2'.In this case, the current candidate QRS peak is identified as a new QRS peak.Case 2.2: The current candidate QRS peak does not have a candidate extremum pair in the higher frequency d2', but the previous QRS peak has one.In this case, the current candidate QRS peak is considered as a lower frequency T peak, not a QRS peak.
Case 2.3: The current candidate QRS peak has a candidate extremum pair in the higher frequency d2', but the previous QRS peak does not have one.In this case, the current candidate QRS peak is identified as a new QRS peak and the previous QRS peak is identified as a lower frequency P peak, not a QRS peak.
Case 3: The distance between the current candidate QRS peak and the previous QRS peak is less than 100 samples.In this case, it is considered that the two peaks are located in the same QRS wave and only a sharper peak remains.A sharpness parameter α of a peak based on the corresponding extremum pair is defined as follows: The larger the extreme values, or the shorter the distance between the first and second extremum points, the larger the sharpness parameter α.If the sharpness of the current candidate QRS peak is larger than that of the previous QRS peak, we remove the previous QRS peak and identify the current candidate QRS peak as a new QRS peak.Otherwise, we remove the current candidate QRS peak and reserve the previous QRS peak.

Illustrations of the Identifications of QRS Peaks
The detection of QRS peaks is based on a lower-noise wavelet detail signal between d3' and d4' according to the evaluation of the amount of noise.Figure 8a,b demonstrate the QRS detection results for a high-noise ECG signal from recording 104 using d3' and d4', respectively.The top figures in Figure 8a,b are the same ECG signal.The red circles denote the detected QRS peaks.FP denotes a false positive peak.The bottom figures in Figure 8a,b are d3' and d4'.The candidate extremum pairs marked as a red circle followed by a green one are determined using the conditions defined in Section 3.4.Two red solid lines indicate the positive and negative thresholds defined in Equations ( 6) and (7) to search for candidate extreme points.Two red dashed lines indicate the positive and negative thresholds of 1.6 times.The extreme points between two red dashed lines are applied to evaluate the amount of noise.It is obvious that the noise amount of d3' is larger than that of d4' for this noisy ECG signal.If the detection of QRS peaks is based on d3', several peaks are misidentified as QRS peaks, as shown in the top figure of Figure 8a.If the detection of QRS peaks is based on d4', all QRS peaks are identified accurately, as shown in the top figure of Figure 8b.Hence, the lower-noise d4' is selected in the detection of QRS peaks for noisy ECG signals.
Figures 9-11 illustrate the identifications of QRS peaks for Cases 1, 2, and 3 defined in Section 3.7.Figure 9 illustrates the identifications of QRS peaks for Case 1.The top and bottom figures plot the ECG signal and d3', respectively.The detected QRS peaks are marked as red circles in the ECG signal, and the candidate extremum pairs are marked as a red circle followed by a green one in d3'.The candidate extremum pairs in d3' are used to calculate the positions of the candidate QRS peaks using Equation (8) in Section 3.6.All of their corresponding candidate QRS peaks are from Case 1 in Section 3.7 and are identified as QRS peaks because all the distances between the two successive candidate QRS peaks are about 280 samples, which are greater than the defined 130 samples.
Figure 10 demonstrates the identifications of QRS peaks for Case 2.1 and shows the waveforms of the ECG signal (top), d3' (middle), and d2' (bottom).The positions of the candidate QRS peaks are calculated by the candidate extremum pairs in d3', and d2' is applied to provide assistance with the identification of the P-or T-peaks.There are three candidate extremum pairs marked as pairs 1, 2, and 3 in d3' and d2', and their corresponding candidate QRS peaks are P1, P2, and P3 in the ECG signal.All of the candidate QRS peaks are identified as QRS peaks and marked as red circles in the ECG signal.
In addition to P2 and P3, the identifications of other QRS peaks are Case 1 in Section 3.7 because the distances between two successive QRS peaks are greater than 130 samples.The previous QRS peaks of P2 and P3 are P1 and P2, respectively.Because P2, P3, and their previous QRS peaks have candidate extremum pairs in d2', P2 and P3 are identified as QRS peaks according to Case 2.1 in Section 3.7.have candidate extremum pairs in d2', P2 and P3 are identified as QRS peaks according to Case 2.1 in Section 3.7.Figure 11 shows the identifications of QRS peaks for Case 2.2 and Case 3. The candidate extremum pairs in d3' are used to calculate the positions of the candidate QRS peaks.P1, marked as a red circle, is identified as a QRS peak.P2 and P3, marked as black squares, are identified as not a QRS peak.There are three candidate extremum pairs marked as pairs 1, 2, and 3 in d3', and only one candidate extremum pair marked as pair 1 in d2' for the first QRS complex.The identification of P2 is Case 3 in Section 3.7 because the distance between P1 and P2 is only 31 samples and is less than 100 samples.Based on the evaluation of the sharpness of P1 and P2 using Equation ( 9), P2 is identified   Figure 11 shows the identifications of QRS peaks for Case 2.2 and Case 3. The candidate extremum pairs in d3' are used to calculate the positions of the candidate QRS peaks.P1, marked as a red circle, is identified as a QRS peak.P2 and P3, marked as black squares, are identified as not a QRS peak.There are three candidate extremum pairs marked as pairs 1, 2, and 3 in d3', and only one candidate extremum pair marked as pair 1 in d2' for the first QRS complex.The identification of P2 is Case 3 in Section 3.7 because the distance between P1 and P2 is only 31 samples and is less than 100 samples.Based on the evaluation of the sharpness of P1 and P2 using Equation ( 9), P2 is identified Figure 11 shows the identifications of QRS peaks for Case 2.2 and Case 3. The candidate extremum pairs in d3' are used to calculate the positions of the candidate QRS peaks.P1, marked as a red circle, is identified as a QRS peak.P2 and P3, marked as black squares, are identified as not a QRS peak.There are three candidate extremum pairs marked as pairs 1, 2, and 3 in d3', and only one candidate extremum pair marked as pair 1 in d2' for the first QRS complex.The identification of P2 is Case 3 in Section 3.7 because the distance between P1 and P2 is only 31 samples and is less than 100 samples.Based on the evaluation of the sharpness of P1 and P2 using Equation ( 9), P2 is identified as not a QRS peak because the sharpness parameter of P1 is larger than that of P2.The identification of P3 is Case 2.2 in Section 3.7 because the distance between P1 and P3 is 126 samples, is greater than 100 samples, and is less than 130 samples.It is obvious that the current candidate QRS peak, P3, has no extremum pair in the higher frequency d2', but the previous QRS peak, P1, has one.Hence, P3 is identified as not a QRS peak.It is considered as a T-peak.as not a QRS peak because the sharpness parameter of P1 is larger than that of P2.The identification of P3 is Case 2.2 in Section 3.7 because the distance between P1 and P3 is 126 samples, is greater than 100 samples, and is less than 130 samples.It is obvious that the current candidate QRS peak, P3, has no extremum pair in the higher frequency d2', but the previous QRS peak, P1, has one.Hence, P3 is identified as not a QRS peak.It is considered as a T-peak.

Performance Evaluation of the Proposed QRS Peak Detection System and Comparison with the Previous Studies
The MIT-BIH arrhythmia database containing 48 ECG recordings was used to evaluate the performance of the proposed QRS peak detection system in order to compare with some previous specific studies which used the same database.An identified QRS peak is recorded as a true peak if it is located within 100 ms (i.e., 36 samples at sampling rate of 360 Hz) of the annotation time [12].The commonly used performance parameters for the QRS peak detection system are defined as follows: Sensitivity (Se): Positive prediction value (+P): Detection error rate (DER): where TP is the number of true positive peaks (QRS peaks detected as QRS peaks), FN is the number of false negative peaks (QRS peaks detected as Not QRS peaks), and FP is the number of false positive peaks (Not QRS peaks detected as QRS peaks).Table 1 lists the summary performance of the proposed QRS detection algorithm using the first channel of the MIT-BIH arrhythmia database.Most of the QRS peaks can be accurately detected by the proposed algorithm even if the ECG signals include severe baseline drifts, abrupt changes, high-

Performance Evaluation of the Proposed QRS Peak Detection System and Comparison with the Previous Studies
The MIT-BIH arrhythmia database containing 48 ECG recordings was used to evaluate the performance of the proposed QRS peak detection system in order to compare with some previous specific studies which used the same database.An identified QRS peak is recorded as a true peak if it is located within 100 ms (i.e., 36 samples at sampling rate of 360 Hz) of the annotation time [12].The commonly used performance parameters for the QRS peak detection system are defined as follows: Sensitivity (Se): Positive prediction value (+P): Detection error rate (DER): where TP is the number of true positive peaks (QRS peaks detected as QRS peaks), FN is the number of false negative peaks (QRS peaks detected as Not QRS peaks), and FP is the number of false positive peaks (Not QRS peaks detected as QRS peaks).Table 1 lists the summary performance of the proposed QRS detection algorithm using the first channel of the MIT-BIH arrhythmia database.Most of the QRS peaks can be accurately detected by the proposed algorithm even if the ECG signals include severe baseline drifts, abrupt changes, high-frequency noise, low-amplitude QRS complexes, sharp P and T waves, or wide ventricular premature contractions.There are a total of 271 detection failures including 180 false negative beats and 91 false positive beats.The highest number of detection failures is 46 failures for recording 203, followed by 31 failures for recording 105, 23 failures for recording 108, 21 failures for recording 228, and 20 failures for recording 116.The individual sensitivity, positive prediction value, and detection error rate range from 98.89% to 100%, from 98.96% to 100%, and from 0% to 1.54%, respectively.The total sensitivity, positive prediction value, and detection error rate are 99.84%,99.92%, and 0.25%.Table 2 shows the performance comparison of the proposed QRS peak detection system with the previous studies.In addition to Berwal et al. [14] only providing the results of one-minute signal per ECG recording, other studies have the results of complete 30-minute signal per ECG recording.Though the FN and FP of Berwal et al. [14] have only 22 and 26, respectively, its DER of 1.49% is the highest among the studies in Table 2. Comparing the proposed algorithm with wavelet-based methods using 30-minute ECG signals, the minimum FN is 140 for Bouaziz et al. [19], followed by 178 for Merah et al. [12] and 180 for the proposed algorithm, and the proposed method has the minimum FP of 91 and FP+FN of 271.The proposed algorithm has the best DER of 0.25% and +P of 99.92% among the wavelet-based methods in Table 2.The Se of the proposed method is 99.84%, which is slightly lower than 99.87% of Bouaziz et al. [14].The results show that the proposed method improves the QRS detection accuracy of the wavelet-based methods.Most of the previous studies removed the high-frequency noise to increase the signal-to-noise ratio and reduce the interference of noise.However, the pre-filtering out of the high-frequency components would not only reduce the noise level, but also cause a reduction in the amplitudes of the QRS peaks and a decrease in the detection accuracy of the QRS peaks.Instead of removing the high-frequency components in the preprocessing stage, this study selects a lower-noise wavelet detail signal according to the results of the noise amount evaluation to reduce the interference of noise.For low-noise ECG signals, the higher-frequency d3' is usually selected for the detection of QRS peaks because the higher frequency wavelet detail signal has smaller energy to the lower frequency signal.Furthermore, d3' has higher detection accuracy than d4' for low-noise signals.If ECG signals suffer interference from a large amount of high-frequency noise, usually the higher frequency d3' would be contaminated by noise more than the lower frequency d4'.The detection of QRS peaks based on the lower-noise d4' can reduce the noise interference and improve the detection accuracy of QRS peaks for high-noise ECG signals.
Comparing the proposed algorithm with non-wavelet-based methods using 30-minute ECG signals, the minimum FN was 79 in Manikandan and Soman [3], followed by 137 in Yazdani and Vesin [17], and 180 in the proposed method.The minimum FP is 91 in the proposed method, followed by 108 in Yazdani and Vesin [17], and 140 in Manikandan and Soman [3].The DER of the proposed method is 0.25%, which is slightly higher than the 0.20% of Manikandan and Soman [3] and the 0.22% of Yazdani and Vesin [17].The Se of the proposed method is 99.84%, which is slightly lower than the 99.93% of Manikandan and Soman [3] and the 99.87% of Yazdani and Vesin [17].The maximum +P is 99.92% in the proposed method, followed by 99.90% in Yazdani and Vesin [17].The results show that the proposed algorithm also improves the detection accuracy of QRS peaks in comparison with the non-wavelet-based methods.

Limitations of the Proposed Algorithm
The limitations of the proposed QRS peak detection algorithm caused 271 detection failures of QRS peaks, which can be classified into several types.Figure 12 illustrates the detection failure caused by sudden high-frequency noise.The red circles indicate the QRS peaks that were correctly identified, and the red arrow followed with FP:18569 indicates a false positive beat at sample 18569.Because the sudden high-frequency noise cannot be detected by the proposed noise evaluation method, the QRS peak detection was still based on the higher-frequency d3', and, hence, this sudden large-amplitude noise peak in Figure 12 is misidentified as a QRS peak.A total of 41 detection failures were caused by the sudden high-frequency noise.Figure 13 demonstrates the detection failure caused by the greatly reduced amplitude of the QRS peak compared to the adjacent QRS peaks.The black arrow followed by V:295133 indicates the peak of a VPC beat at sample 295133, which is misidentified as a false negative beat.Because the amplitude of this VPC beat is greatly reduced in comparison with those of other QRS complexes, the peak of the VPC beat was misidentified as not being a QRS peak.Greatly decreased amplitudes of QRS peaks caused a total of 62 detection failures.Figure 14 shows the detection failures caused by large-amplitude artifacts.It is obvious that the four peaks of large-amplitude artifacts are very similar to QRS peaks and are misidentified as QRS peaks.A total of 26 detection failures were caused by large-amplitude artifacts.Figure 15 illustrates the detection failure caused by a distance of less than 100 samples between two successive QRS peaks, which caused a total of 15 detection failures.The VPC beat by V:267025 was misidentified as not being a QRS peak because the distance between it and the previous QRS peak was less than 100 samples.Figure 16 demonstrates the detection failures caused by a P-peak sharper than the QRS peak.The FP:141706 denotes a false positive beat at sample 141706, and the N:141768 represents a normal beat at sample 141768, which is misidentified as a false negative beat.When a P-or T-peak is sharper than a QRS peak, it causes two detection failures.One is the P-or T-peak misidentified as a QRS peak, and the other is the QRS peak misidentified as not being a QRS peak.A total of 36 detection failures were caused by the P-or T-peak being sharper than the QRS peak.Figures 17 and 18 illustrate the detection failures caused by the inconsistent annotation of the MIT-BIH arrhythmia database.Not QRS peaks that were annotated as QRS peaks caused a total of 57 detection failures.It is obvious that the peaks indicated as N in Figure 17 are not QRS peaks but are annotated as peaks of the normal QRS complexes.QRS peaks that were annotated as Not QRS peaks caused a total of 10 detection failures, as illustrated in Figure 18.The peak indicated as FP should be a QRS peak, but the corresponding annotation was lost.The remaining 24 detection failures were caused by other types.The limitations of the proposed algorithm for these types of detection failures of QRS peaks should be addressed in future work.

Conclusion
This study proposes a QRS detection algorithm based on a four-level biorthogonal spline wavelet transform.A noise evaluation approach was developed for selecting a lower-noise wavelet detail signal to reduce the noise interference instead of pre-filtering out the high-frequency noise in

Conclusions
This study proposes a QRS detection algorithm based on a four-level biorthogonal spline wavelet transform.A noise evaluation approach was developed for selecting a lower-noise wavelet detail signal to reduce the noise interference instead of pre-filtering out the high-frequency noise in the signal preprocessing.If the noise amount in d3' is lower than that in d4', the detection of peaks is based on d3'; otherwise, it is based on d4'.The identification of QRS peaks was based on the extremum pairs in the selected wavelet detail signals and the proposed decision rules.The proposed algorithm was evaluated by the MIT-BIH arrhythmia database.It presents a high accuracy to detect QRS peaks.The results show a 0.25% detection error rate, 99.84% sensitivity, and 99.92% positive prediction value.The performance of the proposed algorithm is better than that of several wavelet-based methods and non-wavelet-based algorithms.

Figure 1
Figure 1 is a block diagram of the proposed wavelet-based algorithm for the detection of the QRS complex.The purpose of the signal preprocessing is to segment the ECG recording and remove the baseline drift.The proposed wavelet-based algorithm includes signal preprocessing, a four-level dyadic wavelet transform, a search of candidate extreme points, a determination of candidate extremum pairs, an evaluation of noise, a calculation of candidate QRS peak positions, and a determination of QRS Peaks.The details are described in the following sections.

Figure 1 .
Figure 1.Block diagram of the proposed wavelet-based algorithm for detection of the QRS complex.

Figure 1 Figure 1 .
Figure1is a block diagram of the proposed wavelet-based algorithm for the detection of the QRS complex.The purpose of the signal preprocessing is to segment the ECG recording and remove

Figure 2 .
Figure 2. Illustration of segmentation of the electrocardiogram (ECG) recording.

Figure 3 .
Figure 3. Illustration of removing the low-frequency baseline drift.

Figure 2 .
Figure 2. Illustration of segmentation of the electrocardiogram (ECG) recording.

Figure 2 .
Figure 2. Illustration of segmentation of the electrocardiogram (ECG) recording.

Figure 3 .
Figure 3. Illustration of removing the low-frequency baseline drift.

Figure 3 .
Figure 3. Illustration of removing the low-frequency baseline drift.

Figure 4 . 4 Figure 4 .
Figure 4.A four-level dyadic wavelet transform of ECG signals using a two-channel filter bank.

Figure 7
Figure7illustrates an extremum pair that is produced by a QRS peak in d3'.It includes a positive and a negative extreme point.Let the coordinates of the first and second extreme points, M 1 and M 2 , be (x 1 , y 1 ) and (x 2 , y 2 ), respectively.A candidate extremum pair corresponding to a possible QRS peak should meet the following conditions.

Figure 7
Figure 7 illustrates an extremum pair that is produced by a QRS peak in d3'.It includes a positive and a negative extreme point.Let the coordinates of the first and second extreme points, M1 and M2, be ( ,  and ( ,  , respectively.A candidate extremum pair corresponding to a possible QRS peak should meet the following conditions.

Figure 8 .
Figure 8. Illustration of the QRS detection results for a noisy ECG signal using (a) d3' and (b) d4'.

Figure 10
Figure10demonstrates the identifications of QRS peaks for Case 2.1 and shows the waveforms of the ECG signal (top), d3' (middle), and d2' (bottom).The positions of the candidate QRS peaks are calculated by the candidate extremum pairs in d3', and d2' is applied to provide assistance with the identification of the P-or T-peaks.There are three candidate extremum pairs marked as pairs 1, 2, and 3 in d3' and d2', and their corresponding candidate QRS peaks are P1, P2, and P3 in the ECG signal.All of the candidate QRS peaks are identified as QRS peaks and marked as red circles in the ECG signal.In addition to P2 and P3, the identifications of other QRS peaks are Case 1 in Section 3.7 because the distances between two successive QRS peaks are greater than 130 samples.The previous QRS peaks of P2 and P3 are P1 and P2, respectively.Because P2, P3, and their previous QRS peaks

Figure 8 .
Figure 8. Illustration of the QRS detection results for a noisy ECG signal using (a) d3' and (b) d4'.

Figure 9 .
Figure 9. Illustration of the identifications of QRS peaks for Case 1.

Figure 10 .
Figure 10.Illustration of the identifications of QRS peaks for Case 2.1.

Figure 9 .
Figure 9. Illustration of the identifications of QRS peaks for Case 1.

Figure 9 .
Figure 9. Illustration of the identifications of QRS peaks for Case 1.

Figure 10 .
Figure 10.Illustration of the identifications of QRS peaks for Case 2.1.

Figure 10 .
Figure 10.Illustration of the identifications of QRS peaks for Case 2.1.

Figure 11 .
Figure 11.Illustration of the identifications of QRS peaks for Case 2.2 and Case 3.

Figure 11 .
Figure 11.Illustration of the identifications of QRS peaks for Case 2.2 and Case 3.

19 Figure 12 .
Figure 12.Illustration of the detection failure caused by sudden high-frequency noises.

Figure 13 .
Figure 13.Illustration of the detection failures caused by greatly reduced amplitudes of QRS peaks compared to the adjacent QRS peaks.

Figure 12 . 19 Figure 12 .
Figure 12.Illustration of the detection failure caused by sudden high-frequency noises.

Figure 13 .
Figure 13.Illustration of the detection failures caused by greatly reduced amplitudes of QRS peaks compared to the adjacent QRS peaks.

Figure 13 .
Figure 13.Illustration of the detection failures caused by greatly reduced amplitudes of QRS peaks compared to the adjacent QRS peaks.

Figure 12 .
Figure 12.Illustration of the detection failure caused by sudden high-frequency noises.

Figure 13 .
Figure 13.Illustration of the detection failures caused by greatly reduced amplitudes of QRS peaks compared to the adjacent QRS peaks.

Figure 14 .
Figure 14.Illustration of the detection failures caused by large-amplitude artifacts.

Figure 15 .
Figure 15.Illustration of the detection failure caused by the distance shorter than 100 samples between two successive QRS peaks.

Figure 15 .
Figure 15.Illustration of the detection failure caused by the distance shorter than 100 samples between two successive QRS peaks.

Figure 16 .
Figure 16.Illustration of the detection failures caused by the P-peak being sharper than the QRS peak.

Figure 17 .
Figure 17.Illustration of the detection failures caused by Not QRS peaks being annotated as QRS peaks by the MIT-BIH Arrhythmia Database.

Figure 16 .
Figure 16.Illustration of the detection failures caused by the P-peak being sharper than the QRS peak.

Figure 15 .
Figure 15.Illustration of the detection failure caused by the distance shorter than 100 samples between two successive QRS peaks.

Figure 16 .
Figure 16.Illustration of the detection failures caused by the P-peak being sharper than the QRS peak.

Figure 17 .
Figure 17.Illustration of the detection failures caused by Not QRS peaks being annotated as QRS peaks by the MIT-BIH Arrhythmia Database.

Figure 17 . 19 Figure 18 .
Figure 17.Illustration of the detection failures caused by Not QRS peaks being annotated as QRS peaks by the MIT-BIH Arrhythmia Database.Appl.Sci.2019, 9, x FOR PEER REVIEW 18 of 19

Figure 18 .
Figure 18.Illustration of the detection failures caused by QRS peaks but annotated as Not QRS peaks by the MIT-BIH Arrhythmia Database.

Table 1 .
Summary performance of the proposed QRS peak detection system using the first channel of the MIT-BIH arrhythmia database.

Table 2 .
Performance comparison of the proposed QRS peak detection system with the previous studies.