## Materials and Methods
### Proposed Real-Time R and QRS Detection Method Using a Pair of Derivative Filters  
Figure 8 shows the entire block-diagram of the proposed real-time R and QRS detection method using a pair of derivative filters. The proposed method consists largely of an R-point detection module, a noise detection module, a detected R-point connection module, and an inaccurate RR elimination module. First, the proposed method detects the R peak using two kinds of first order derivative filter, [1, -1] and [-1, 1]. The [-1, 1] filter detects a rapid rising interval of the QRS, while the [1, -1] filter detects a drastic falling interval. The multiplication of each derivative filter result then suppresses the P wave or T wave and noise while enhancing the QRS interval. By applying the max filter to the multiplication of the derivative filter results, the QRS interval and R peak are detected through the normalization and threshold of 0.3. This threshold is applied to the normalized max filter result, which is the final stage of QRS interval detection, and applies to all records of MIT-BIH DB. Figure 9 shows an example of the QRS detection procedure using a pair of derivative filters for the Record 234 signal of MIT-BIH DB. The QRS interval including the R peak includes an abrupt rising  
Figure 8: Entire block-diagram of proposed real-time R and QRS detection method. HRV: heart rate variability. and falling section compared to other signal intervals. The derivative filter result \(D_{\alpha}(n)\) for the original ECG signal \(I(n)\) of the sliding window size is obtained as follows:  
\[D_{\alpha}(n)\ =\ \sum_{k\ =\ 0}^{2j-1}d_{\alpha}(k)I(n+k), \tag{2}\]  
where \(d_{\alpha}(k)\) means the derivative filters and is obtained as follows, while \(j\) denotes half of the signal point interval to which the derivative filters are applied; \(  
where \(f(=15)\) means half of the filter size of the maximum filter. As shown in Figure 10, by applying the threshold to the normalized max filter result \(M_{\rm N}(n)\), the candidate QRS interval is obtained as follows:  
\[I(n)\ =\ \left\{ \begin{array}{ll}\mbox{candidate QRS point},&\mbox{if }M_{\rm N }(n)>M_{\rm th}\\ \mbox{non $-$ candidate QRS point},&\mbox{else}\end{array} \right., \tag{6}\]  
where \(M_{\rm th}\ =\ 0.3\) is a threshold value for determining whether the current signal point belongs to the candidate QRS point. If the number of consecutive candidate QRS points (successive columns of \"1\" in the figure) exceeds a certain threshold, the interval is classified as a candidate QRS interval including R. The extended candidate QRS interval to improve the reliability of the R detection rate is obtained by adding an additional interval (offset \(=15\) in Figure 10) to both sides of the candidate QRS interval. The position of the R peak is retrieved in the extracted candidate QRS interval of Figure 10. The R peak detection method depends on the shape of the R wave to be detected, which is largely divided into a normal case (positive R) and PVC case (inverse R or PVC). The shape of the normal R peak represents a high positive R peak, whereas the shape of the R peak in PVC appears as a deep negative R peak. Accordingly, the R peak position in the candidate QRS interval is obtained by considering two cases, as follows:  
\[r_{\rm L}\ =\ \left\{ \begin{array}{ll}\mbox{argmin}\,C_{s,j,k},&\mbox{if }\beta\times\left(\max(C_{s,j,k})-\mbox{mean}(W_{s})\right)<\left(\mbox{ mean}(W_{s})-\min(C_{s,j,k})\right)\\ \mbox{argmax}\,C_{s,j,k},&\mbox{else}\end{array} \right., \tag{7}\]  
where \(\beta(=1.5)\) is a coefficient value to compare positive with negative R peaks such as PVC. The coefficient value is set to search for a negative R or PVC below the average of the ECG signal in the sliding window. In the PVC beat, the difference between the average value of the sliding window and the negative peak value is much larger than that between the positive peak value and the average value of the sliding window.