# Method and System for Heart Rate Estimation Using Linear Prediction Filtering +
## 2 Materials and Methods
### LPC: Heart Rhythm Estimation  
Most research on characteristic extraction of ECG signals primarily focuses on the QRS complex. This paper proposes using an LPC-based method to locate the instants when the QRS complex occurs, with a particular interest in the R-R interval.  
To understand the approach, consider the discrete-time ECG signal \(x[n]\), whose samples can be predicted from the signal \(\hat{x}[n]\) obtained by the 4 th-order (\(p\) = 4) LPC model (1). From the difference \(x[n]-\hat{x}[n]\), the error \(e[n]\) is computed. It is susceptible to high-frequency components and, consequently, to the inrush variations of the signal level within the QRS complex. Then, a threshold-based search can be easily applied to \(e[n]\) to retrieve heart rhythm information. Since the error signal carries only high frequency in this band, the offset drift caused by spurious interference and even possible \(T\) wave prominenceand other artifacts that can affect the ECG captured signal are absent. Then, the threshold logic detection of the peaks tends to be effective.  
The choice of a reasonable detection threshold has some level of subjectivity [31]. However, for a given sorted sequence in ascending order of the normalized absolute value of the error:  
\[\tilde{e}[n]=\frac{|e[n]|}{\sup_{n}|e[n]|}, \tag{7}\]  
is acceptable to discard the 10% higher values of the samples in \(\tilde{e}[n]\), resulting in a truncated sequence, \(\tilde{e}_{t}[n]\). Considering that this resultant sequence gives the spiking events a good prominence, a reference to the threshold value can be computed using the median \(\mu_{\frac{1}{2}}\):  
\[L=\sqrt{\mu_{\frac{1}{2}}(\tilde{e}_{t}^{2}[n]))}. \tag{8}\]  
And finally, it is possible to consider an adequate calibration for the threshold:  
\[D=\beta L,\ \beta>0. \tag{9}\]  
For example, a good value for the parameter \(\beta\) considering use with the MIT database was obtained as \(\beta=6\).  
The \(m_{k}\) sample is then considered an event to be marked if the condition \(\tilde{e}[m_{k}]\geq D\) is verified. For each of two consecutive marked samples \(m_{1}\) and \(m_{2}\) with \(m_{2}-m_{1}=N\), the heart rhythm \(HR\) in beats per minute (bpm) can be estimated as:  
\[HR=\frac{60f_{s}}{N}, \tag{10}\]  
where \(f_{s}\) is the sampling frequency in hertz. In Figure 2, a summary of this procedure is displayed.  
For example, in Figure 3a, an excerpt from an ECG signal from the MIT database with baseline correction is displayed in the basal state and also contaminated with wanderer and drift spurious signals. Figure 3b shows a similar pattern for the  
Figure 2: Heart rhythm computation using detected R waves.  
On the choice of LPC filter order, a signal reconstruction test is performed with an excerpt containing 600 samples, with a sampling frequency of 300 Hz taken from an ECG from Physionet. The excerpt used and the error variance as a function of the order is depicted in Figure 4. One can observe that orders \(p\) higher than four do not significantly improve the error variance. The high-pass nature of the LPC filter for \(p=4\) is shown in Figure 5.  
Figure 4: Error variance in the signal reconstruction as a function of order \(p\).  
Figure 3: Squared error patterns for ECG signals unperturbed (black) and perturbed with wanderer (blue) and drift (red) in a given window of measurement: (**a**) ECG signals and (**b**) squared error.