Open Access
This article is
 freely available
 reusable
Sensors 2018, 18(11), 3870; https://doi.org/10.3390/s18113870
Article
Missing RRI Interpolation Algorithm based on Locally Weighted Partial Least Squares for Precise Heart Rate Variability Analysis
^{1}
The Department of Systems Science, Kyoto University, Kyoto 6158085, Japan
^{2}
The Department of Material Process Engineering, Nagoya University, Nagoya 4648601, Japan
^{*}
Author to whom correspondence should be addressed.
Received: 7 October 2018 / Accepted: 9 November 2018 / Published: 10 November 2018
Abstract
:The RR interval (RRI) fluctuation in electrocardiogram (ECG) is called heart rate variability (HRV), which reflects activities of the autonomic nervous system (ANS) and has been used for various health monitoring services. Accurate R wave detection is crucial for success in HRVbased health monitoring services; however, ECG artifacts often cause missing R waves and deteriorate the accuracy of HRV analysis. The present work proposes a new missing RRI interpolation technique based on JustInTime (JIT) modeling. In the JIT modeling framework, a local regression model is built by weighing samples stored in the database according to the distance from a query and output is estimated only when an estimate is requested. The proposed method builds a local model and estimates missing RRI only when an RRI detection error is detected. Locally weighted partial least squares (LWPLS) is adopted for local model construction. The proposed method is referred to as LWPLSbased RRI interpolation (LWPLSRI). The performance of the proposed LWPLSRI was evaluated through its application to RRI data with artificial missing RRIs. We used the MITBIH Normal Sinus Rhythm Database for nominal RRI dataset construction. Missing RRIs were artificially introduced and they were interpolated by the proposed LWPLSRI. In addition, MEAN that replaces the missing RRI by a mean of the past RRI data was compared as a conventional method. The result showed that the proposed LWPLSRI improved root mean squared error (RMSE) of RRI by about 70% in comparison with MEAN. In addition, the proposed method realized precise HRV analysis. The proposed method will contribute to the realization of precise HRVbased health monitoring services.
Keywords:
R wave detection; heart rate variability analysis; JustInTime modeling; locally weighted partial least squares1. Introduction
The RR interval (RRI) fluctuation in an electrocardiogram (ECG) is known as heart rate variability (HRV), which is a physiological activity reflecting the cardiovascular control exerted by the autonomic nervous systems (ANS) [1,2]. Since the ANS is a control system that acts largely unconsciously and regulates functions such as the heart rate, digestion, respiration, perspiration, and body temperature, it is related to various diseases. Many types of HRV features have been proposed for evaluation of ANS activities, [3,4], and application areas of HRV analysis has been expanded due to recent advances in machine learning technologies. A brief introduction of HRV analysis is described in Appendix A.
It is known that changes in sleep condition affect HRV [5,6]. An HRVbased drowsiness detection method using linear discriminant analysis (LDA) was developed by Vicente et al. [7]. Patel et al. proposed a drowsiness detection algorithm based on a neural network (NN) [8]. A drowsy driving detection algorithm was proposed by integrating HRV analysis and multivariate statistical process control (MSPC), which is a wellknown anomaly detection method [9,10].
Apnea affects HRV during sleep because it contributes to the future development of cardiovascular events and HRV reflects the cardiovascular control [11,12]. Sleep apnea can also be screened through monitoring HRV. It has been reported that frequency domain features of HRV are useful for apnea screening [13]. Roche et al. developed a sleep apnea detection method based on HRV features [14].
HRV analysis was also used for epilepsy seizure detection [15], since HRV changes in preictal phases [16,17]. In addition, Fujiwara et al. developed an epileptic seizure prediction algorithm utilizing MSPC, which can predict seizure occurrence prior to onset [18].
Precise longterm RRI measurement devices are needed for realizing these HRVbased health monitoring services. The Holter monitor is used for longterm ECG measurement; however, its use in daily life is difficult since the Holter monitor is expensive and requires operation skills. Yamakawa et al. developed a wearable RRI sensor based on ECG for realtime HRV analysis, which can easily measure RRI [19]. A wearable chemicalelectrophysiological sensors for health and fitness monitoring was developed by Imani et al. [20]. In addition, tattoo type sensors for ECG monitoring have been investigated [21,22,23].
Adequate HRV feature extraction for RRI data is required. In particular, R wave detection from ECG is essential because HRV feature extraction is easily fluctuated by artifact contamination in the raw RRI data. R waves are not always detected stably due to ECG artifacts caused by body movement or ECG electrode contact failure. Figure 1 illustrates an example of an ECG trace with artifacts, in which the colored band denotes contaminated artifacts.
Some HRV features easily fluctuate when a missing RRI occurs even if it is just one. Figure 2a shows an example of RRI data with one missing and Figure 2b–d are RMSSD, NN50, and HF that were calculated from the RRI data of Figure 2a. A threeminute time window was used for HRV calculation. The vertical line denotes a missing RRI occurrence point. This example shows that some of the extracted HRV features were significantly altered when the R detection error occurred and that their influence lasted for three minutes in this case, which is the window size of HRV calculation.
Although missing R waves may easily be found when the ECG data are analyzed offline, such offline analysis cannot be used for online applications like drowsy driving detection and epileptic seizure prediction.
When the ($j+1$)th R wave is not detected, ${r}_{j}$ is as
where ${\tilde{r}}_{j}$ is the true RRI measurement when both the jth and ($j+1$)th R waves are detected correctly.
$$\begin{array}{c}\hfill {r}_{j}={\tilde{r}}_{j}+{\tilde{r}}_{j+1}\end{array}$$
The simplest way of missing RRI treatment is to remove or ignore ${r}_{j}$ [24]. Although Clifford and Tarassenko recommended using the LombScargle (LS) periodogram after removing ${r}_{j}$ for frequency domain feature extraction [25], such treatment cannot be used online because it causes time gaps between realtime. An ectopic RRI modification method from ECG data was proposed by using prior knowledge about arrhythmia [26]. However, its use for missing RRI interpolation is difficult since the effect of R wave detection errors on changes in RRI data is different from that of arrhythmia. Thus, missing RRI should be interpolated appropriately in realtime for precise HRV analysis. Highly adequate interpolation is required particularly in drowsy driving detection and epileptic seizure prediction because their errors caused by missing RRI may lead to severe injuries and accidents.
The electrode contact failure or sensor failure may cause longterm ECG measurement failure. In such cases, HRV analysis and its use for health monitoring should be stopped because we cannot use any information for HRV analysis. Thus, this study focuses on the modification of an isolated R wave detection error.
The present work proposes a new missing RRI interpolation method based on justintime (JIT) modeling. JIT modeling or lazy learning is a statistical modeling method that builds a local regression model and that estimates an output using the constructed local model only when an estimate is requested. Although some JIT modeling methods have been proposed [27,28,29,30], the present work adopts locallyweighted partial least squares (LWPLS), which utilizes partial least squares (PLS) for local model construction [31,32]. The proposed method, referred to as LWPLSbased RRI interpolation (LWPLSRI), interpolates missing RRIs by using a local regression model only when an R wave detection error is detected. R wave detection errors are detected by using a threshold of the measured RRI.
This paper is organized as follows. Section 2 introduces LWPLS and proposes new missing RRI interpolation method. Section 3 validates the performance of the proposed missing RRI interpolation method through a case study of RRI data with artificial missing RRI. Finally, the conclusion and future work are described in Section 4. Although a preliminary version of this work has been reported in [33], the data analyzed in [33] was small, and the performance of the proposed method was not compared with other methodologies.
2. Materials and Methods
The present work proposes a new JITbased algorithm for interpolating missing RRI, which is referred to as LWPLSbased RRI interpolation (LWPLSRI). This section begins with partial least squares (PLS) and locallyweighted PLS (LWPLS) used in the proposed algorithm.
2.1. PLS
PLS is a widely used linear regression method that can build an accurate model with a small number of latent variables. Given an input data matrix $\mathit{X}\in {\Re}^{N\times M}$ whose nth row is the nth input sample ${\mathit{x}}_{n}\in {\Re}^{M}$ and an output data vector $\mathit{y}\in {\Re}^{N}$ whose nth element is the nth output sample ${y}_{n}\in \Re $. $\mathit{X}$ and $\mathit{y}$ are meancentered and appropriately scaled. In PLS, the input $\mathit{X}$ and the output $\mathit{y}$ are broken down as follows:
where $\mathit{T}\in {\Re}^{N\times K}$ is the latent variable matrix whose columns are the latent variable ${\mathit{t}}_{k}\in {\Re}^{N}$ $(k=1,\cdots ,K)$, $\mathit{P}\in {\Re}^{M\times K}$ is the loading matrix of $\mathit{X}$ whose columns are the loading vectors ${\mathit{p}}_{k}\in {\Re}^{M}$, and $\mathit{b}={[{b}_{1},\cdots ,{b}_{K}]}^{T}$ is the regression coefficient vector of $\mathit{y}$. K denotes the number of adopted latent variables. $\mathit{E}\in {\Re}^{N\times M}$ and $\mathit{f}\in {\Re}^{N}$ are errors.
$$\begin{array}{ccc}\hfill \mathit{X}& =& {\mathit{TP}}^{T}+\mathit{E}\hfill \end{array}$$
$$\begin{array}{ccc}\hfill \mathit{y}& =& \mathit{Tb}+\mathit{f}\hfill \end{array}$$
The nonlinear iterative partial least squares (NIPALS) algorithm can be used to construct a PLS model [34]. Suppose that the first to kth latent variables ${\mathit{t}}_{1},\cdots ,{\mathit{t}}_{k}$, the loading vectors ${\mathit{p}}_{1},\cdots ,{\mathit{p}}_{k}$ and the loading ${b}_{1},\cdots ,{b}_{k}$ are given. The ($k+1$)th residual input and output can be expressed as follows:
${\mathit{t}}_{k}$ is a linear combination of the columns of ${\mathit{X}}_{k}$, that is, ${\mathit{t}}_{k}={\mathit{X}}_{k}{\mathit{w}}_{k}$ where ${\mathit{w}}_{k}\in {\Re}^{M}$ is the kth weighting vector. It is defined so that the covariance between ${\mathit{y}}_{k}$ and ${\mathit{t}}_{k}$ is maximized under ${\mathit{w}}_{k}=1$. Using the Lagrange multipliers method, the function to maximize can be defined as
where $\mu $ is the Lagrange multiplier. By solving $\partial {G}_{k}/\partial \mathit{w}=0$, ${\mathit{w}}_{k}$ is derived as
The kth loading vector ${\mathit{p}}_{k}$ and the kth loading ${b}_{k}$ are as follows:
Finally, the above procedure is repeated until the number of adopted latent variables K is achieved; K can be determined by cross validation.
$$\begin{array}{ccc}\hfill {\mathit{X}}_{k+1}& =& {\mathit{X}}_{k}{\mathit{t}}_{r}{\mathit{p}}_{k}^{T},\hfill \end{array}$$
$$\begin{array}{ccc}\hfill {\mathit{y}}_{k+1}& =& {\mathit{y}}_{k}{b}_{k}{\mathit{t}}_{k}.\hfill \end{array}$$
$$\begin{array}{c}\hfill {G}_{k}={\mathit{y}}_{k}^{T}{\mathit{t}}_{k}\mu ({\mathit{w}}_{k}1)={\mathit{y}}_{k}^{T}{\mathit{X}}_{k}{\mathit{w}}_{k}\mu ({\mathit{w}}_{k}1),\end{array}$$
$$\begin{array}{c}\hfill {\mathit{w}}_{k}={\displaystyle \frac{{\mathit{X}}_{k}^{T}{\mathit{y}}_{k}}{{\mathit{X}}_{k}^{T}{\mathit{y}}_{k}}}.\end{array}$$
$$\begin{array}{c}\hfill {\mathit{p}}_{k}={\displaystyle \frac{{\mathit{X}}_{k}^{T}{\mathit{t}}_{k}}{{\mathit{t}}_{k}^{T}{\mathit{t}}_{k}}},\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}{b}_{k}={\displaystyle \frac{{\mathit{y}}_{k}^{T}{\mathit{t}}_{k}}{{\mathit{t}}_{k}^{T}{\mathit{b}}_{k}}}.\end{array}$$
Instead of using the Lagrange multipliers method, the derivation of the weighting vectors ${\mathit{w}}_{k}$ in the NIPALS algorithm can be formulated as an eigenvalue problem. ${\mathit{w}}_{k}$ is the eigenvector corresponding to the maximum eigenvalue of the following eigenvalue problem:
where $\lambda $ is an eigenvalue.
$$\begin{array}{c}\hfill {\mathit{X}}_{k1}^{T}{\mathit{y}}_{k1}^{T}{\mathit{y}}_{k1}{\mathit{X}}_{k1}{\mathit{w}}_{k}=\lambda {\mathit{w}}_{k},\end{array}$$
Algorithm 1 describes the eigenvaluebased NIPALS algorithm for PLS modeling.
Algorithm 1 NIPALS. 

2.2. LocallyWeighted Partial Least Squares
In general, a global linear model cannot function well when a system has strong nonlinearity or changes in characteristics with time. The use of nonlinear modeling methods, such as support vector machine (SVM) or artificial neural network (ANN), is the first choice; however, nonlinear modeling methods are not always applicable because a considerable amount of data is required for nonlinear modeling. Also, it is difficult to even for nonlinear models to cope with changes in system characteristics with time.
Another method for dealing with these problems is JIT modeling, which has the following features:
 Store new samples into a database when available.
 Construct a local model by the samples located in the neighboring region around a query and estimate an output only when estimation is required.
 Discard the constructed local model after its use for output estimation.
In JIT modeling, samples for local modeling should be selected appropriately.
LWPLS is an expansion of PLS based on the framework of JIT modeling for dealing with nonlinearity and system characteristics change. In LWPLS, a local PLS model is built by weighted samples stored in a database according to the similarity between the query and the weighted samples only when an estimate is requested. The constructed local model represents a nonlinear relationship between the input and the output around the query because a nonlinear relationship can be approximated as a linear relationship in a small region. After being used for estimation, the used local model is purged [31,32].
Let $\mathit{X}$ and $\mathit{y}$ have already been stored in a database. When an estimate is requested for a query ${\mathit{x}}_{q}$, the similarity ${\omega}_{n}$ between ${\mathit{x}}_{q}$ and the nth sample ${\mathit{x}}_{n}(n=1,\cdots ,N)$ is calculated, and a local PLS model is built by the weighted samples with a similarity matrix $\mathsf{\Omega}\in {\Re}^{N\times N}$ defined as:
The similarity between the query ${\mathit{x}}_{q}$ and a sample ${\mathit{x}}_{n}$ ${\omega}_{n}$ in this work is defined as:
where ${\sigma}_{d}$ denotes the standard deviation of ${d}_{n}\phantom{\rule{4pt}{0ex}}(n=1,2,\cdots ,N)$ and $\phi $ is a localization parameter; the similarity decreases steeply when $\phi $ is small and gradually when $\phi $ is large. When the similarity matrix $\mathsf{\Omega}$ is an identity matrix, LWPLS becomes the original PLS.
$$\begin{array}{c}\hfill \mathsf{\Omega}=\mathrm{diag}[{\omega}_{1},{\omega}_{2},\cdots ,{\omega}_{N}].\end{array}$$
$$\begin{array}{ccc}\hfill {\omega}_{n}& =& {e}^{({d}_{n}\phi /{\sigma}_{d})},\hfill \end{array}$$
$$\begin{array}{ccc}\hfill {d}_{n}& =& \sqrt{{({\mathit{x}}_{n}{\mathit{x}}_{q})}^{T}({\mathit{x}}_{n}{\mathit{x}}_{q})}\hfill \end{array}$$
Algorithm 2 describes a procedure of LWPLS based on the NIPALS algorithm. Steps 4–7 derive the latent variable $\mathit{t}$, the loading vector $\mathit{p}$, and the regression coefficient vector b iteratively. In step 6, ${\mathit{w}}_{k}$ is calculated as the eigenvector of ${\mathit{X}}_{k}^{T}\mathsf{\Omega}{\mathit{y}}_{k}{\mathit{y}}_{k}^{T}\mathsf{\Omega}{\mathit{X}}_{k}$, which corresponds to the maximum eigenvalue. The final estimate is output when $k=K$. A localization parameter $\phi $ and the number of latent variables K are tuning parameters, which are determined by trial and error or crossvalidation.
Algorithm 2 LWPLS. 

2.3. Missing RRI Interpolation
When the ($j+1$)th R wave is not detected and the measured rth R wave is expressed as Equation (1), only the jth RRI estimate ${\widehat{r}}_{j}$ is required because the next RRI estimate ${\widehat{r}}_{j+1}$ can be calculated from ${r}_{j}$ and ${\widehat{r}}_{j}$: ${\widehat{r}}_{j+1}={r}_{j}{\widehat{r}}_{j}$. At this time, successive missing occurrences are not considered.
Appropriate input variables should be determined for interpolating missing RRI by LWPLS. Multiple past RRI measurements ${r}_{j1},\cdots ,{r}_{jL+1}$ and the current measurement ${r}_{j}$ are used as input variables;
where L is the number of past measurements. Although the current measurement may be useful for interpolation, the measured ${r}_{j}$ is about double of ${\tilde{r}}_{j}$. Thus, its average ${r}_{j}/2$ is used as input.
$$\begin{array}{c}\hfill {\mathit{x}}_{j}=[{r}_{j}/2,{r}_{j1},\cdots ,{r}_{jL}]\end{array}$$
The procedure of the proposed LWPLSRI is described in Algorithm 3. Before missing RRI interpolation starts, the initial RRI buffer has to be stored for more than the buffer size W. In step 4, $\overline{r}$ is the threshold for finding an R wave detection error. When the RRI measurement ${r}_{j}$ exceeds $\overline{r}$, it is determined that an R wave detection error has occurred. The threshold $\overline{r}$ is a predetermined parameter to be tuned beforehand; however, the default value of $\overline{r}$ can be set to 1,500 msec. In step 5, the newly measured RRI ${r}_{j}$ is queued into the RRI buffer in a firstinfirstout (FIFO) manner when an R wave is detected correctly. On the other hand, ${\widehat{r}}_{j}$ is estimated by LWPLS when an R wave detection error occurs in steps 8–10. Finally, ${r}_{j}$ is replaced by the estimated ${\widehat{r}}_{j}$ and ${\widehat{r}}_{j+1}$ which are queued into the RRI buffer in a FIFO manner in steps 11 and 12. The proposed LWPLSRI has four tuning parameters: the localization parameter $\phi $, the numbers of latent variables K and past RRI measurements used for an input L, and the buffer size W.
Algorithm 3 LWPLSRI. 

In the proposed algorithm, the RRI data collected from any persons can be used for the initial RRI buffer. Even when the RRI data collected from persons other than users are stored in the initial RRI buffer, the stored RRI data are replaced by the RRI data measured from users themselves through the FIFO manner in steps 11 and 12 in Algorithm 3.
3. Results and Discussion
This section evaluates and discusses the interpolation performance of the proposed LWPLSRI through its application to RRI data in which missing RRIs were introduced artificially. Longterm ECG measurement failure and an ectopic RRI caused by arrhythmia were not considered here.
3.1. Simulation Procedure
This case study used the MITBIH Normal Sinus Rhythm Database for objective data construction [35]. ECG data measured from subjects 1–18 were clipped from the database and ECG data containing strong artifacts were eliminated. The R waves in the clipped ECG data were detected by using the peak detection algorithm, and each RRI was calculated. Each of eighteen pieces of RRI data, ${\mathit{r}}^{\left[s\right]}$, was divided into three datasets for parameter optimization of LWPLS ${\mathit{r}}_{o}^{\left[s\right]}$, initial RRI buffer in Algorithm 3, ${\mathit{r}}_{b}^{\left[s\right]}$, and validation ${\mathit{r}}_{v}^{\left[s\right]}$, where $s(s=1,\cdots ,18)$ denotes the subject index. The numbers of samples in ${\mathit{r}}_{o}^{\left[s\right]}$, ${\mathit{r}}_{b}^{\left[s\right]}$, and ${\mathit{r}}_{v}^{\left[s\right]}$ were 6000, 500, and 5000, respectively. There was no R wave detection error in any of these datasets.
Missing RRIs were artificially introduced to the parameter optimization dataset ${\mathit{r}}_{o}^{\left[s\right]}$ and the validation datasets ${\mathit{r}}_{v}^{\left[s\right]}$ in a random manner as ${r}_{j}^{\prime}={r}_{j}+{r}_{j+1}$ and eliminated ${r}_{j+1}$. There were no successive missing RRIs, and the missing rates were $\alpha =0.3\%$, $0.5\%$, and $1\%$. Since the ordinal heart rate of a healthy adult is about 60–80 bpm, 1% missing means that R wave detection error occurs about every 1.5 min. Figure 3 illustrates an example of RRI data with $\alpha =0.5$ which was generated from the RRI data of subject 16 ${\mathit{r}}_{v}^{\left[16\right]}$.
In this case study, the HRV features described in Appendix A were extracted. A rectangular sliding window whose size is three minutes was used. The time domain features were extracted directly from the raw RRI data. For frequency domain feature extraction, the RRI data were interpolated by the thirdorder spline and resampled at 4 Hz. An AR model of order 40 was used to calculate frequency domain features. These HRV feature extraction settings were determined based on [18]. Figure 4 shows NN50, RMSSD, HF, and LF/HF extracted from the data in Figure 3. HRV features except for NN50 change greatly due to missing RRIs and such a situation may deteriorate the performance of HRVbased monitoring services.
Before applying the proposed LWPLSRI to the validation datasets ${\mathit{r}}_{v}^{\left[s\right]}$, appropriate parameters in LWPLS were determined using the parameter optimization datasets ${\mathit{r}}_{o}^{\left[s\right]}$. 1% of R wave detection errors artificially occurred in all ${\mathit{r}}_{o}^{\left[s\right]}$ in a random manner. The localization parameter $\phi $ and the number of latent variables K in LWPLS were determined so that the root mean squared error (RMSE) between the true and interpolated RRIs was minimized. Here, the RRI buffer size W and the number of past RRIs used for input L were fixed to 500 and 3. The determined parameters were $\phi =1.3$ and $K=3$, respectively.
The proposed method with the determined parameters was applied to the validation datasets ${\mathit{r}}_{v}^{\left[s\right]}\phantom{\rule{4pt}{0ex}}(s=1,\cdots ,18)$. Although step 4 in Algorithm 3 judges missing RRI occurrences, missing RRI positions were known in this case study for interpolation performance evaluation. The following three interpolation methods were tested for comparison:
 MEAN: Replace the missing RRI ${r}_{j}$ by a mean of ${\mathit{x}}_{j}$.
 Equal Division (ED): Replace ${r}_{j}$ by the value of ${r}_{j}/(q+1)$, where q is the number of successive R wave detection errors.
 PLSRI: Replace ${r}_{j}$ by an output of a PLS model whose input is ${\mathit{x}}_{j}$.
The ectopic RRI remove method [24] was not tested in this case study because it can not be used in online applications. After interpolation by these methods, RMSE between the true and interpolated RRIs and RMSE between HRV features derived from the true and interpolated RRIs were calculated.
In this case study, missing RRI generation in the validation datasets ${\mathit{r}}_{v}^{\left[k\right]}$ and missing RRI interpolation were repeated 30 times for precise performance evaluation.
3.2. Interpolation Results
Figure 5 shows application results of four missing RRI interpolation methods to RRI data with $\alpha =0.5\%$ in Figure 3 and HRV extraction from the interpolated RRI data. These RMSEs of the four methods were calculated through a simulation repeated 30 times using all of the eighteen pieces of validation data. RMSEs of PLSRI and the proposed LWPLSRI were lower than those of MEAN and ED, and LWPLSRI was the best. The proposed LWPLSRI improved RMSE about 70% in comparison with MEAN when $\alpha =0.5\%$. In addition, the interpolation performance hardly changed even if the error rate increased.
HRV features were derived from the RRI data interpolated by four methods. Figure 6, Figure 7 and Figure 8 show RMSEs of eight HRV features calculated by the interpolated RRIs through a simulation repeated 30 times. The proposed LWPLSRI achieved the highest performance.
These results demonstrate the usefulness of the proposed LWPLSRI for HRV analysis from RRI data with missing RRIs.
3.3. Discussion
According to the simulation, the proposed LWPLSRI achieved the best performance of missing RRI interpolation, of which the mean of RMSEs calculated from all subjects was 15.1 when the error rate was $\alpha =1\%$. However, there were differences among subjects as shown in Figure 9. RMSE calculated from subject 6 was worse than the other subjects. None of the interpolation methods could improve his/her RMSE. The standard deviations of the raw RRI data of subject 6 and subject 5 whose RMSE was small were 61.8 and 140.4, respectively, which clearly showing that RRI fluctuation of subject 6 was much larger than that of subject 5 although there were no RRI detection errors. This indicates that a missing RRI cannot be interpolated appropriately when the fluctuation range of RRI is huge. LWPLS uses the past information most similar to a sample to be estimated; however, the number of past similar RRIs for interpolation becomes small when RRIs fluctuate largely.
The current RRI measurement ${r}_{j}(={\tilde{r}}_{j}+{\tilde{r}}_{j+1})$ is used for utilizing missing information. To investigate the effect of using the current measurement, RRI interpolation without ${r}_{j}$ was tested. The number of past RRIs used for input L was $L=4$ so that the total number of input variables did not change. As a result, the means of RMSE by MEAN, PLSRI, and LWPLSRI were 49.1, 34.2, and 31.9, respectively, which are worse than RRI interpolation with ${r}_{j}$. This shows that the current RRI measurement ${r}_{j}$ should be used for interpolation in any method.
In the proposed LWPLSRI, the RRI buffer size W and the number of past RRIs used for input L were fixed to 500 and 3 in this case study. To investigate the effect of these parameters on the interpolation performance of the proposed LWPLSRI, different parameter settings were compared. The RRI buffer size W was changed to $W=100,300,500,$ and 1000 and other parameters were fixed to the same values as Section 3.1. RMSEs were calculated using validation data with $\alpha =0.5\%$ in a simulation repeated 30 times. The means of RMSE were 15.9, 15.4, 15.7, and 15.1 when $W=100,300,500,$ and 1000, respectively. These numbers show that the interpolation performance was not improved when a large buffer size was selected, and in fact became worse when $W=100$. Thus, $W=300$ is sufficient for RRI interpolation.
The number of past RRIs used for input L was changed to $L=2,3,4$, and 5, and other parameters were fixed to the same values as Section 3.1, except the number of latent variables K which was determined using the parameter optimization dataset for every different L. RMSEs were calculated using validation data with $\alpha =0.5\%$ in a simulation repeated 30 times. The means of RMSE were 12.7, 12.8, 12.9, and 12.8 when $L=2,3,4$, and 5, which shows that the interpolation performance did not change, regardless of which L was selected.
In addition, the proposed LWPLSRI was applied to the RRI data containing two successive missing RRIs and compared with the single RRI missing case. In this simulation, two successive missing RRIs were randomly generated at five different points in each validation dataset, and they were interpolated sequentially by LWPLSRI whose parameters were the same as Section 3.1. The following input was used for the interpolation instead of Equation (23):
The interpolated RRI for the first missing ${\widehat{r}}_{j,1}$ was added to the input for the second interpolation as
Using these inputs, the RRI data containing two successive missing RRIs were interpolated by LWPLSRI sequentially, and RMSEs of the first and the second interpolations were calculated. This procedure was repeated 30 times. The mean of RMSE of the first missing interpolation was 24.9, which was worse than that of the single missing interpolation. More information about RRI was lost in the successive missing case than the single missing case, which makes it difficult to interpolate RRI. Thus, it becomes more difficult to interpolate missing RRIs when more than three successive missing RRIs occur. However, the mean of RMSE of the second missing interpolation was 15.2 which is almost the same as the single missing interpolation case. This may have been caused by input variable construction for the second interpolation. Equation (25) uses the interpolated first RRI ${\widehat{r}}_{j,1}$. Information lost through successive missing RRIs was recovered to some extent by the first interpolation and ${\widehat{r}}_{j,1}$ contained such recovered information that may be useful for the second missing interpolation.
$$\begin{array}{c}\hfill {\mathit{x}}_{j,1}=[{r}_{j}/3,{r}_{j1},\cdots ,{r}_{jL}].\end{array}$$
$$\begin{array}{c}\hfill {\mathit{x}}_{j,2}=[({r}_{j}{\widehat{r}}_{j,1})/2,{\widehat{r}}_{j,1},{r}_{j1},\cdots ,{r}_{jL+1}].\end{array}$$
The proposed LWPLSRI can be easily implemented in mobile computers such as a smartphone because the computational load is much lighter than methods that need to process ECG signals directly. This is important from the viewpoint of practical use. An HRVbased epileptic seizure prediction smartphone app has already been developed and tested in hospitals [18]. In addition, an HRVbased drowsy driving detection smartphone app has been commercialized [9]. The performances of these smartphone apps will be improved through appropriate RRI interpolation by the proposed method.
It is concluded that the proposed LWPLSRI has the potential for realizing highly accurate HRVbased health monitoring services in the future.
4. Conclusions
A missing RRI interpolation method was proposed utilizing the framework of JIT modeling, whereby a local model is constructed, and missing RRI is estimated by the constructed model only when R wave detection errors occur. The result of applying the proposed LWPLSRI to real RRI data with artificial missing RRIs showed that it interpolated missing RRI more appropriately than other methods. The proposed method is not applicable to longterm ECG measurement failure since it modifies only one RRI. HRV analysis should be stopped during longterm ECG measurement failure.
The limitations of this study include the properties of the objective data collected from the Physionet database, such as the limited number of subjects and the fact that all subjects were healthy and did not have arrhythmia or other cardiovascular diseases.
In the future work, we will develop a unified framework for interpolating and modifying ectopic RRI data caused by arrhythmia as well as R wave detection errors.
Author Contributions
K.K. and K.F. developed the proposed method and wrote the initial draft of the manuscript. T.K. analyzed the data. M.K. contributed to data collection and analysis and assisted in the preparation of the manuscript. All authors approved the final version of the manuscript, and agree to be accountable for all aspects of the work.
Funding
This work was supported in part by AMED SENTAN #171122, JST PRESTO #JPMJPR1859, the Hattori Hokokai foundation, the SECOM science and technology foundation, the SEI Group CSR Foundation, and the Murata science foundation.
Conflicts of Interest
The authors declare no conflict of interest.
Appendix A Heart Rate Variability Analysis
This appendix introduces HRV analysis. A typical ECG trace consists of some peaks, and the highest peak is called an R wave. The RR interval (RRI) [ms] is defined as an interval between an R wave and the next R wave. The R wave is detected by using a derivativebased peak detection algorithm [36]. Every RRI changes due to ANS activities, and this phenomenon is called HRV. Standard HRV features are classified into time domain features and frequency domain features [1].
The time domain features are obtained from the original RRI data.
 meanNN: Mean of RRI.
 SDNN: Standard deviation of RRI.
 Total Power (TP): Variance of RRI.
 RMSSD: Root means square of the difference of adjacent RRI.
 NN50: Number of pairs of adjacent RRI, whose difference is more than 50 ms.
Frequency domain features are defined based on the power spectrum density (PSD) of the resampled RRI data, which is derived by Fourier analysis or an autoregressive (AR) model.
 LF: Power of the lowfrequency band (0.04–0.15Hz) in PSD. LF reflects the activity of both the sympathetic and parasympathetic nervous systems.
 HF: Power of the highfrequency band (0.15–0.4Hz) in PSD. HF reflects the parasympathetic nervous system activity.
 LF/HF: Ratio of LF to HF. LF/HF expresses the balance between the sympathetic nervous system activity and the parasympathetic nervous system activity.
For frequency analysis, the raw RRI data are interpolated by using spline and are resampled at equal intervals, because they are not sampled at equal intervals. Appropriate settings of HRV analysis should be determined depending on applications; however, the HRV analysis guideline recommends that RRI data should be measured for more than two minutes and that the sampling rate should be at least 200 Hz [1].
References
 Variability, H.R. Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology. Circulation 1996, 93, 1043–1065. [Google Scholar]
 Karemaker, J.M. An introduction into autonomic nervous function. Physiol. Meas. 2017, 38, R89. [Google Scholar] [CrossRef] [PubMed]
 Kleiger, R.E.; Miller, J.P.; Bigger, J.T.; Moss, A.J. Decreased heart rate variability and its association with increased mortality after acute myocardial infarction. Am. J. Cardiol. 1987, 59, 256–262. [Google Scholar] [CrossRef]
 Malliani, A. Cardiovascular neural regulation explored in the frequency domain. Circulation 1991, 84, 482–492. [Google Scholar] [CrossRef] [PubMed]
 Versace, F.; Mozzato, M.; De Min Tona, G.; Cavallero, C.; Stegagno, L. Heart rate variability during sleep as a function of the sleep cycle. Biol. Psychol. 2003, 63, 146–162. [Google Scholar] [CrossRef]
 Jurysta, F.; van de Borne, P.; Migeotte, P.F.; Dumont, M.; Lanquart, J.P.; Degaute, J.P.; Linkowski, P. A study of the dynamic interactions between sleep EEG and heart rate variability in healthy young men. Clin. Neurophysiol. 2003, 114, 2146–2155. [Google Scholar] [CrossRef]
 Vicente, J.; Laguna, P.; Bartra, A.; Bailon, R. Drowsiness detection using heart rate variability. Med. Biol. Eng. Comput. 2016, 54, 927–937. [Google Scholar] [CrossRef] [PubMed]
 Patel, M.; Lal, S.K.L.; Kavanagh, D.; Rossiter, P. Applying neural network analysis on heart rate variability data to assess driver fatigue. Expert. Syst. Appl. 2011, 38, 7235–7242. [Google Scholar] [CrossRef]
 Abe, E.; Fujiwara, K.; Hiraoka, T.; Yamakawa, T.; Kano, M. Development of Drowsiness Detection Method by Integrating Heart Rate Variability Analysis and Multivariate Statistical Process Control. SICE J. Control Meas. Syst. Integr. 2016, 9, 10–17. [Google Scholar] [CrossRef][Green Version]
 Fujiwara, K.; Abe, E.; Kamata, K.; Nakayama, C.; Suzuki, Y.; Yamakawa, T.; Hiraoka, T.; Kano, M.; Sumi, Y.; Masuda, F.; Matsuo, M.; Kadotani, H. Heart Rate Variabilitybased Driver Drowsiness Detection and its Validation with EEG. IEEE Trans. Biomed. Eng. 2018. [Google Scholar] [CrossRef] [PubMed]
 Aeschbacher, S.; Bossard, M.; Schoen, T.; Schmidlin, D.; Muff, C.; Maseli, A.; Leuppi, J.D.; Miedinger, D.; ProbstHensch, N.M.; SchmidtTrucksass, A.; Risch, M.; Risch, L.; Conen, D. Heart Rate Variability and SleepRelated Breathing Disorders in the General Population. Am. J. Cardiol. 2016, 118, 912–917. [Google Scholar] [CrossRef] [PubMed]
 Gong, X.; Huang, L.; Liu, X.; Li, C.; Mao, X.; Liu, W.; Huang, X.; Chu, H.; Wang, Y.; Wu, W.; Lu, J. Correlation Analysis between Polysomnography Diagnostic Indices and Heart Rate Variability Parameters among Patients with Obstructive Sleep Apnea Hypopnea Syndrome. PLoS ONE 2016, 11, e0156628. [Google Scholar] [CrossRef] [PubMed]
 AlvarezEstevez, D.; MoretBonillo, V. Spectral Heart Rate Variability analysis using the heart timing signal for the screening of the Sleep ApneaHypopnea Syndrome. Comput. Biol. Med. 2016, 71, 14–23. [Google Scholar] [CrossRef] [PubMed]
 Roche, F.; Gaspoz, J.M.; CourtFortune, I.; Minini, P.; Pichot, V.; Duverney, D.; Costes, F.; Lacour, J.R.; Barthelemy, J.C. Screening of Obstructive Sleep Apnea Syndrome by Heart Rate Variability Analysis. Circulation 1999, 100, 1411–1415. [Google Scholar] [CrossRef] [PubMed][Green Version]
 Jeppesen, J.; Beniczky, S.; Johansen, P.; Sidenius, P.; FuglsangFrederiksen, A. Detection of epileptic seizures with a modified heart rate variability algorithm based on Lorenz plot. Seizure 2015, 24, 1–7. [Google Scholar] [CrossRef] [PubMed]
 Behbahani, S.; Dabanloo, N.J.; Nasrabadi, A.M.; Teixeira, C.A.; Dourado, A. Preictal heart rate variability assessment of epileptic seizures by means of linear and nonlinear analyses. Anadolu Kardiyol Derg. 2013, 13, 797–803. [Google Scholar] [CrossRef] [PubMed]
 CalandraBuonaura, G.; Toschi, N.; Provini, F.; Corazza, I.; Bisulli, F.; Barletta, G.; Vandi, S.; Montagna, P.; Guerrisi, M.; Tinuper, P.; Cortelli, P. Physiologic autonomic arousal heralds motor manifestations of seizures in nocturnal frontal lobe epilepsy: Implications for pathophysiology. Sleep Med. 2012, 13, 252–262. [Google Scholar] [CrossRef] [PubMed]
 Fujiwara, K.; Miyajima, M.; Yamakawa, T.; Abe, E.; Suzuki, Y.; Sawada, Y.; Kano, M.; Maehara, T.; Ohta, K.; SasaiSakuma, T.; Sasano, T.; Matsuura, M.; Matsushima, E. Epileptic seizure prediction based on multivariate statistical process control of heart rate variability features. IEEE Trans. Biomed. Eng. 2016, 63, 1321–1332. [Google Scholar] [PubMed]
 Yamakawa, T.; Kinishita, R.; Fujiwara, K.; Kano, M.; Miyajima, M.; Sakata, T.; Ueda, Y. Accuracy Comparison of Two Microcontrollerembedded Rwave Detection Methods for Heartrate Variability Analysis. In Proceedings of the 2015 AsiaPacific Signal and Information Processing Association Annual Summit and Conference (APSIPA), Hong Kong, China, 16–19 December 2015; pp. 1010–1013. [Google Scholar]
 Imani, S.; Bandodkar, A.J.; Mohan, A.M.; Kumar, R.; Yu, S.; Wang, J.; Mercier, P.P. A wearable chemicalelectrophysiological hybrid biosensing system for realtime health and fitness monitoring. Nat. Commun. 2016, 7, 11650. [Google Scholar] [CrossRef] [PubMed]
 Kim, J.; Sempionatto, J.R.; Imani, S.; Hartel, M.C.; Barfidokht, A.; Tang, G.; Campbell, A.S.; Mercier, P.P.; Wang, J. Simultaneous Monitoring of Sweat and Interstitial Fluid Using a Single Wearable Biosensor Platform. Adv Sci (Weinh) 2018, 5, 1800880. [Google Scholar] [CrossRef] [PubMed]
 Mishr, R.K.; Barfidokht, A.; Karajic, A.; Sempionatto, J.R.; Wang, J.; Wang, J. Wearable potentiometric tattoo biosensor for onbody detection of Gtype nerve agents simulants. Sens. Actuators B Chem. 2018, 273, 966–972. [Google Scholar] [CrossRef]
 Choi, J.; Ghaffari, R.; Baker, L.B.; Rogers, J.A. Skininterfaced systems for sweat collection and analytics. Sci. Adv. 2018, 4, eaar3921. [Google Scholar] [CrossRef] [PubMed][Green Version]
 Lippman, N.; Stein, K.M.; Lerman, B.B. Comparison of methods for removal of ectopy in measurement of heart rate variability. Am. J. Physiol. 1994, 267, H411–H418. [Google Scholar] [CrossRef] [PubMed]
 Clifford, G.D.; Tarassenko, L. Quantifying errors in spectral estimates of HRV due to beat replacement and resampling. IEEE Trans. Biomed. Eng. 2005, 52, 630–638. [Google Scholar] [CrossRef] [PubMed]
 Mateo, J.; Laguna, P. Analysis of Heart Rate Variability in the Presence of Ectopic Beats Using the Heart Timing Signal. IEEE Trans. Biomed. Eng. 2003, 50, 334–343. [Google Scholar] [CrossRef] [PubMed]
 Atkeson, C.G.; Moore, A.W.; Schaal, S. Locally Weighted Learning. Artif. Intel. Rev. 1997, 11, 11–73. [Google Scholar] [CrossRef]
 Bontempi, G.; Birattari, M.; Bersini, H. Lazy learing for local modelling and control design. Int. J. Cont. 1999, 72, 643–658. [Google Scholar] [CrossRef]
 Cheng, C.; Chiu, M. A new databased methodology for nonlinear process modeling. Chem. Eng. Sci. 2004, 59, 2801–2810. [Google Scholar] [CrossRef]
 Fujiwara, K.; Kano, M.; Hasebe, S. SoftSensor Development using CorrelationBased JustInTime modeling. AIChE J. 2009, 55, 1754–1765. [Google Scholar] [CrossRef]
 Kano, M.; Fujiwara, K. Virtual Sensing Technology in Process Industries: Trends and Challenges Revealed by Recent Industrial Applications. J. Chem. Eng. Jpn. 2013, 46, 1–17. [Google Scholar] [CrossRef]
 Kim, S.; Okajima, R.; Kano, M.; Hasebe, S. Development of softsensor using locally weighted PLS with adaptive similarity measure. Chemometr. Intell. Lab. Syst. 2013, 124, 43–49. [Google Scholar] [CrossRef][Green Version]
 Kamata, K.; Fujiwara, K.; Yamakawa, T.; Kano, M. Missing RRI interpolation for HRV analysis using LocallyWeighted Partial Least Squares Regression. In Proceedings of the 38th Annual International Conference of the IEEE Engineering in Medicine and Biology Society, Orlando, FL, USA, 17–20 August 2016; pp. 2386–2389. [Google Scholar]
 Wold, S.; Sjostrom, M.; Eriksson, L. PLSRegression: a Basic Tool of Chemometrics. Chemom. Intell. Lab. Syst. 2001, 58, 109–130. [Google Scholar] [CrossRef]
 Goldberger, A.L.; Amaral, L.A.; Glass, L.; Hausdorff, J.M.; Ivanov, P.C.; Mark, R.G.; Mietus, J.E.; Moody, G.B.; Peng, C.K.; Stanley, H.E. PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals. Circulation 2000, 101, e215–e220. [Google Scholar] [CrossRef] [PubMed]
 Pan, J.; Tompkins, W.J. A RealTime QRS Detection Algorithm. IEEE Trans. Biomed. Eng. 1985, 32, 230–236. [Google Scholar] [CrossRef] [PubMed]
Figure 1.
An example of an ECG trace with artifacts (colored band). An R wave cannot be detected due to artifacts.
Figure 2.
Missing RRI data and its effect on HRV features: (a) RRI, (b) RMSSD, (c) NN50, and (d) HF. The HRV features greatly fluctuate when the R detection error occurs.
Figure 3.
Example of missing RRI with $\alpha =0.5\%$: some RRIs were intentionally eliminated randomly.
Figure 4.
HRV features extracted from the missing RRI: (a) NN50, (b) RMSSD, (c) HF, and (d) LF/HF. There were large errors in HRV features due to frequent missing RRI
Figure 5.
RMSE of RRI interpolated by MEAN, ED, PLS, and LWPLS when $\alpha =0.3\%$ (left), 0.5% (center), and 1% (right) when a simulation was repeated 30 times using all of the eighteen pieces of validation data. The proposed LWPLSRI achieved the best interpolation performance.
Figure 6.
RMSE of HRV features derived from RRIs interpolated by MEAN, ED, PLS, and LWPLS when $\alpha =0.3\%$. These eight HRV features were explained in the Appendix A. RMSEs of the four methods were calculated through a simulation repeated 30 times using all of the eighteen pieces. The proposed LWPLSRI achieved the best HRV analysis performance.
Figure 7.
RMSE of HRV features derived from RRIs interpolated by MEAN, ED, PLS, and LWPLS when $\alpha =0.5\%$. These eight HRV features were explained in the Appendix A. RMSEs of the four methods were calculated through a simulation repeated 30 times using all of the eighteen pieces. The proposed LWPLSRI achieved the best HRV analysis performance.
Figure 8.
RMSE of HRV features derived from RRIs interpolated by MEAN, ED, PLS, and LWPLS when $\alpha =1.0\%$. These eight HRV features were explained in the Appendix A. RMSEs of the four methods were calculated through a simulation repeated 30 times using all of the eighteen pieces. The proposed LWPLSRI achieved the best HRV analysis performance.
Figure 9.
RMSE of RRI interpolation in each subject by LWPLS when $\alpha =0.5\%$. Although RMSEs of almost all subjects except Subject 6 were less than twenty, that of Subject 6 was more than forty.
© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).