Interbeat Interval Filtering
Abstract
Interbeat intervals (IBIs) carry heart rate and heart-rate variability information. When the IBIs are correct, this information can be extracted through simple statistics such as mean/median/standard deviation. However, more robust approaches are needed especially in ambulatory conditions where the underlying signal can be noisy. In this paper, we propose a lightweight filter that (i) tracks the time-varying distribution of interbeat intervals, (ii) is robust to outliers. The tracked distribution summarizes relevant information of interest and alleviates the need for further analysis. We demonstrate numerically that the tracked distribution can provide more accurate estimates than a two-stage algorithm that first fixes the IBIs before computing the statistics of interest.
I Introduction
The history/distribution of interbeat intervals (IBI) carries information about the cardiovascular system. Non-invasive methods of obtaining these intervals usually rely on detecting individual heartbeats from a modality like ECG, PPG, PCG, etc., to obtain IBIs. However, these modalities can be prone to motion/muscle artifacts, or, more generally, the signal quality from such non-invasive modalities may be poor. This in turn can throw off beat/peak detectors, resulting in erroneous interbeat intervals.
In this paper, we propose a light-weight algorithm that can track the time-varying IBI distribution that is also robust to errors in IBIs. The proposed algorithm is specifically useful for battery-powered devices that operate under strict energy/memory constraints.
Related Work
We combine ideas from heart beat series modeling and robust state-space filtering.
We assume a simple model where each IBI is taken as a sample from an inverse Gaussian distribution. Such a model can be motivated by assuming an underlying process and considering the hitting times for its running integral . Every time hits an integer, say, we declare a heart beat. If we take to be a random walk with drift, the IBIs follow an inverse Gaussian distribution (see Section II-A, or [9]). Building on this model, Barbieri et al. [7] propose to estimate, via linear regression, the parameters of the inverse Gaussian distribution using past IBIs. This yields a more accurate (i.e., lower variance) conditional density for the next beat, given the beat history.
Another variation on the above model is the ‘integral pulse frequency model’ (IPFM) [8, 21, 3, 18]. For this, is taken as a bandlimited signal. By performing spectral analysis of a variant of (e.g., cancelling the DC component, or normalizing with respect to time-varying heart rate), one can obtain further insight about HRV.
In an extension that builds on [7], Barbieri et al. assume in [6] that the model parameters (weights used in linear regression) follow a random walk. They propose an adaptive filter for estimating these time-varying parameters. This filter implicitly assumes that the input beats are correct. Taking a further step, Citi et al. [10] propose a beat correction algorithm, which can be used as a preprocessing step for further HRV analysis. Given the history, the algorithm in [10] evaluates the current IBI to decide whether it’s valid, or falls in one of the anomaly classes. Depending on the class, it fixes the interval to produce either a single IBI or multiple IBIs.
There also exist relevant work targeting not necessarily heart beats but more general neural spiking activity. In [1, 12], the authors consider Gaussian processes as latent states that drive a point process through its intensity function (the intensity function setting the probability of firing in an infinitesimal interval – see e.g. [26, 22] for background). Smith and Brown [1] propose estimating the parameters of the intensity function as well as the underlying latent space by resorting to the expectation maximization (EM) algorithm [11]. In contrast, Eden et al. [12] derive recursive update equations that estimate the latent space. In both papers [1, 12], the observations are not restricted to spike locations, but are arbitrary points in time. The latent process can, in principle, be estimated for every time instant.
Another category is rule-based algorithms as in [16, 20]. These algorithms can adapt their behavior to the underlying sequence of inter beat intervals and aim to fix the inter beat intervals that look anomalous. Thanks to the simplicity of their rules, they are easy to implement and efficient to run.
More generally, the literature on robust state space filters is vast. However, many of the papers in the existing literature assume a state and observation space that can be described or well approximated by a Gaussian process. Usually, outliers are handled by either incorporating an outlier generation model or manipulating the state/observation distributions to follow a heavy-tailed distribution – see for instance [27, 23, 2] for some relatively recent examples. While these approaches are valuable, they do not directly address our problem, where the states are clearly non-Gaussian.
An important category is the probabilistic data association filter (PDAF). PDAF is specifically designed to hande clutter or missing detections [4, 5]. In this framework, multiple hypotheses are postulated to describe the process that generates the observations. Given the observation, one computes the probability of each hypothesis and updates the filter parameters based on these probabilities. However, like the general robust filters mentioned above, in PDAF and its many variants, one usually assumes that the underlying states follow a Gaussian process.
Contribution
The proposed filter aims to retain the simplicity of rule-based methods [16, 20] designed specifically for IBI filtering, and robustness of the state-space filters [27, 23] that are not directly suitable for IBI filtering. We adopt the inverse Gaussian model for IBIs. In contrast to [6], we assume the parameters of this distribution are themselves random variables, with a suitable distribution. We handle anomalous observations by resorting to the PDAF [4, 5]. We specifically consider a two-hypothesis scenario; the observation being anomalous or not. We show that this choice plays well with the current setup, and yields a simple algorithm.
Pseudo-code for the algorithm is in Algorithm 1. While the steps may not be clear at this stage, we remark that the most complicated operations are and . Therefore, the algorithm is very suitable for running on edge devices.
Another aspect we emphasize from an edge device perspective is how the algorithm helps save on memory or energy. Generally, the IBI distribution changes much more slowly than individual IBIs. In turn, the parameters describing the distribution can be communicated at a much lower rate. For a battery-powered device, this means considerable compression and savings in terms of either memory, if the information is being stored, or energy, if the information is being communicated.
Outline
II Background on the Inverse Gaussian Distribution
The assumption underlying the proposed filter is that, locally, IBIs are generated by independently sampling an inverse Gaussian random variable (see [9] for a motivation, [7] for a modified model). The filter keeps track of this distribution.
We provide an overview of the inverse Gaussian distribution (see, e.g., [22] for derivations of these properties), and describe a useful conjugate prior.
II-A The Inverse Gaussian Distribution
An inverse Gaussian random variable is the time it takes for a random walk with drift to reach unity. Assuming denotes a standard Brownian motion process, a random walk with drift can be obtained as
Here, the term ensures that has linearly increasing mean, whereas controls its variance. The first time that reaches unity is an inverse Gaussian random variable, parameterized by and . Its pdf is of the form
The mean and variance of an inverse Gaussian random variable are
(1) | ||||
(2) |
Likelihood for an Inverse Gaussian
Suppose are independent samples from an inverse Gaussian distribution. The likelihood is of the form
where is independent of or .
Natural Conjugate Prior
The IBI filter operates by updating statistics for and . That is, we retain some “prior” information about these parameters, and update the prior information as we receive new observations. For Bayesian filtering, this prior information typically consists of a distribution. Adapting to our context, we need to postulate a distribution for , , and update that distribution with each new IBI observation. A convenient distribution to use as prior is the natural-conjugate prior [13].
From the likelihood function, we find that the natural conjugate is of the form (following the notation of [19])
(3) |
valid for , . Palmer [19] shows that this function is not integrable in its natural domain . Therefore, it is not a proper distribution. Nevertheless, it becomes integrable if we restrict the region of integration [19]. In the following, we will assume this restriction is in place, and employ to encode the information on , .
Comparing the natural conjugate prior’s parameters to the likelihood function, we reach a useful interpretation of the parameters as
-
•
2: sum of IBIs
-
•
: number of IBIs
-
•
2 : sum of the inverse of IBIs
-
•
2: number of IBIs
For what follows, we also note that the maximizer of is (which can be found by setting the gradient to zero),
(4) | ||||
(5) |
III Derivation of the Filter
We follow the standard schema for Bayesian filtering [24]. Specifically, we propose a state-space model where the parameters of the model are allowed to vary with time. Given the set of past IBIs , we assume that
where collects together the parameters.
III-A State Update Model
Before receiving the next IBI, we postulate that the state updates as
where .
For a unimodal function like , raising to a power less than unity preserves the mode, and increases the variance of the distribution. This is precisely the behavior that the standard random walk model in Gaussian state-space filtering achieves. For a detailed justification of this specific update model, we refer to [25].
Finally, given the distribution , the next IBI is assumed to be independent of previous IBIs, and follows the distribution .
III-B Filter Updates
Given this model, we can write down the rules for updating the parameters. Specifically, since
we obtain
(6) |
where
If, at anytime, the mean and variance of the heart rate distribution is required, they can be estimated using the mode of , along with (1)
III-C Filtering Out Anomalous Intervals
The simple tracker outlined above assumes that IBIs do not contain any outliers. In practice, IBI estimation is far from ideal, especially in ambulatory conditions. There can be failures due to incorrect peak detection, which can happen if the input signal quality is poor. Apart from peak detector failure, it is also possible to observe unexpected IBIs, due to ectopic beats. We would like the filter to be robust against such IBIs. For the purposes of this document, we do not distinguish ectopic beats from erroneous IBIs, and collect them under the same label, “anomalous”.
We follow the PDAF [4] framework to derive an algorithm that handles such cases.
Given each IBI, we have to evaluate two hypothesis:
-
•
: IBI is anomalous
-
•
: IBI is not anomalous
In the following, for simplicity of notation, we will drop the superscript, and write , .
We are interested in computing the probabilities of these hypotheses. To do that, we declare
-
(i)
a prior probability for getting an anomalous IBI,
-
(ii)
a probability distribution for anomalous observations .
For (ii), we postulate that anomalous observations follow an exponential distribution:
where denotes the step function. To incorporate PDAF, we introduced two new scalars, , , as parameters to tune.
The posterior distribution of , takes the form
(7) |
For what follows, for , we define
Computing Probability of Parameters Given Hypotheses
’s are relatively easy to compute. Under , we simply take
Under , we take
whose expression was provided in (6).
Computing Hypothesis Probabilities
We first write
Whether the IBI will be anomalous or not does not depend on previous observations. Therefore,
Consider now the other term. We have
and
The latter integral does not have a closed form expression. While it’s not the only choice, we opt for the simple approximation of
where the maximum likelihood estimates of and are given in (4). Plugging those in, we have
To summarize, we have
where
III-D Collapsing the Mixture
We provided expressions to compute the posterior probability in (7). However, this is a mixture distribution. In order to keep the recursions in the same form, we need to reduce the mixture to a single component as is typically done in Gaussian sum filtering and variants [4].
To come up with a reduction scheme, we recall the interpretation of the parameters in . These are either the number of observations, or the sum of a function of the observations. Under , it is as if we miss an observation, whereas in , we do make the proper observation. Therefore we can simply use a convex combination to combine the two set of parameters. The weight of the convex combination can be taken as . This leads to the update rule
where
The final expression suggests that we have made a ‘partial’ observation (of weight ) - an interpretation that is consistent with the motivation for the rule.
Putting it all together gives Algorithm 1.
IV Experiments
We consider IBI series obtained from the Fantasia database [15] made available through the Physionet ATM [14]. We conduct two experiments to assess different features of the proposed filter.
In the first experiment, we compare how the anomaly probability of the proposed filter compares against the robust Kalman filter proposed in [27].
The second experiment evaluates the proposed filter’s ability to accurately and robustly estimate HRV. We compare the filter against a two-stage scheme, that comprises a rule-based IBI fixing algorithm followed by a sliding window standard deviation computation. These are compared to ground truth HRV computed also using a sliding window.
![Refer to caption](x1.png)
For our experiments, given beat locations, we introduce two types of errors:
-
•
Missed detections, by randomly removing a small percentage, , of the beats,
-
•
False detections, by adding a small percentage, , of beats, where each addition is uniformly distributed over the entire collection.
Each ‘missed detection’ introduces a large anomalous IBI, whereas a ‘false detection’ introduces a consecutive pair of low anomalous IBIs. We set in our experiments.
Anomaly Detection Capability
For this experiment, we used the data from the subject ‘f1y02’ (young subject with relatively high HRV) from the Fantasia dataset. We produced a set of noisy IBIs by the procedure outlined above, by setting . Fig. 1 shows a small excerpt with true and anomalous IBIs used in the experiment.
In practice, we will not have access to a probability of anomaly, so we initialized our filter by setting the probability of error to . In fact, the value used in IBI generation and the probability of error in our filter are actually not exactly the same, so we are not really committing an inverse crime [28].
Running the IBIs through the proposed filter, we obtain a ‘probability of anomaly‘ for each IBI. Based on whether the IBI is true or not, we can produce two histograms as shown in Fig. 2. Ideally, we would see a single peak at 1 for the anomalous IBIs, and a single peak at 0 for the true IBIs.
![Refer to caption](x2.png)
We also ran the IBIs through the robust Kalman filter [27]. We modified the parameters so as to get as favorable a distribution as possible. We see from Fig. 2 that the proposed filter detects the anomalous IBIs more accurately. We think the main reason for the relatively poor performance of the robust Kalman filter is that its assumptions regarding the data distribution is not valid for this scenario. In other words, by tailoring the filter to a more accurate but still simple data model (namely, inverse Gaussian), we are able to retain simplicity of the filter without sacrificing accuracy.
HRV Accuracy
To test HRV accuracy, we let vary from 1% to 50% in our experiments. error is obviously an exaggeration, and we do not expect methods to handle such error levels successfully. But testing with high error helps us understand how robust the methods under investigation are.
We compare our algorithm against the rule-based algorithm proposed by Lipponen and Tarvainen [16], implemented in neurokit2 [17]. This algorithm takes as input a set of noisy IBIs, determines which IBIs are incorrect, and fixes them.
For the beat at , we compute an HRV value by considering the standard deviations of IBIs that fall in a sliding window. Specifically, we
-
•
compute the standard deviation of the neighboring 50 IBIs from either the original (clean) sequence of IBIs, or the sequence of “corrected” IBIs, or
-
•
use the std of the empiricial estimate of the inverse Gaussian distribution, namely .
For , the resulting 3 curves are shown in Fig 3. Even though the error is not critically high, the decoupled approach of fixing the IBIs followed by std computation with a sliding window does not give an accurate estimate.
![Refer to caption](x3.png)
Given these HRV estimates, we can compute an RMS error between
-
•
the std’s from original and fixed beats,
-
•
the std of the original beats and the std of the estimated inverse Gaussian.
![Refer to caption](x4.png)
For different values, these RMS values are shown in Fig. 4 for two different IBI sequences (f1y02 and f1o01) from the Fantasia dataset. In both, the trend suggests that while fixing the beats can be effective for very low probability of error, the proposed method is preferable in performance when error probability is high.
![Refer to caption](x5.png)
To check how the distribution varies over time, we show the estimated distribution from the proposed filter at different instances in Fig. 5. For these histograms, we consider 200 consecutive beats. Even though the histogram itself can be noisy due to the low number of beats that contribute to the histogram, the inverse Gaussian distribution appears to correctly track the distribution, leading to a more interpretable summary.
V Conclusion
This paper introduces a filter that tracks inter beat intervals that is robust to outliers. While there are competing approaches in the literature, the proposed filter fills a gap :
-
•
it is lean enough to be implemented on a wearable device without requiring too much memory/computation, in contrast to other Bayesian-filtering approaches,
-
•
it is robust and accurate enough that it performs arguably better than a two-stage approach where the first stage consists of applying a simple rule-based lightweight IBI correction.
The proposed filter builds on the framework of probabilistic data association filter (PDAF) with two hypotheses : the input IBI is an anomaly or not. A more rigorous approach is to consider additional hypotheses as done by [10] (which used a different framework for correcting IBIs). We plan to investigate such an extension in future work.
References
- [1] E.N. Brown A.C. Smith. Estimating a state-space model from point process observations. Neural Comput., 15(5):965–991, 2003.
- [2] G. Agamennoni, J. I. Nieto, and E. M. Nebot. Approximate inference in state-space models with heavy-tailed noise. IEEE Transactions on Signal Processing, 60(10):5024–5037, 2012.
- [3] R. Bailón, G. Laouini, C. Grao, M. Orini, P. Laguna, and O. Meste. The integral pulse frequency modulation model with time-varying threshold: Application to heart rate variability analysis during exercise stress testing. IEEE Transactions on Biomedical Engineering, 58(3):642–652, 2011.
- [4] Y. Bar-Shalom, F. Daum, and J. Huang. The probabilistic data association filter. IEEE Control Systems Magazine, 29(6):82–100, Dec 2009.
- [5] Y. Bar-Shalom, X. R. Li, and T. Kirubarajan. Estimation with Applications to Tracking and Navigation. Wiley, 2001.
- [6] R. Barbieri and E.N. Brown. Analysis of heartbeat dynamics by point process adaptive filtering. IEEE Transactions on Biomedical Engineering, 53(1):4–12, 2006.
- [7] R. Barbieri, E. C. Matten, A. A. Alabi, and E. N. Brown. A point-process model of human heartbeat intervals: new definitions of heart rate and heart rate variability. American journal of physiology Heart and circulatory physiology, 288, 2005.
- [8] E. J. Bayly. Spectral analysis of pulse frequency modulation in the nervous systems. IEEE Transactions on Biomedical Engineering, BME-15(4):257–265, 1968.
- [9] E. N. Brown. Course 14 - theory of point processes for neural systems. Les Houches, 80:691–727, 2005.
- [10] L. Citi, E. N. Brown, and R. Barbieri. A real-time automated point-process method for the detection and correction of erroneous and ectopic heartbeats. IEEE Transactions on Biomedical Engineering, 59(10):2828–2837, 2012.
- [11] A. P. Dempster, N. M. Laird, and D. B. Rubin. Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society B, 39:1–38, 1977.
- [12] U. T. Eden, L. M. Frank, R. Barbieri, V. Solo, and E. N. Brown. Dynamic analysis of neural encoding by point process adaptive filtering. Neural Comput., 16(5):971–998, 2004.
- [13] D. Fink. A compendium of conjugate priors. Technical Report, 1997.
- [14] A.L. Goldberger, L.A.N Amaral, L. Glass, J.M. Hausdorff, P.Ch. Ivanov, R.G. Mark, J.E. Mietus, G.B. Moody, C.-K. Peng, and H.E. Stanley. Physiobank, physiotoolkit, and physionet: Components of a new research resource for complex physiologic signals. Circulation, 101(23):e215e–e220, 2000.
- [15] N. Iyengar, C.K. Peng, R. Morin R, A.L. Goldberger, and L.A. Lipsitz. Age-related alterations in the fractal scaling of cardiac interbeat interval dynamics. Am. J. Physiol, 271:1078–1084, 1996.
- [16] J.A. Lipponen and M.P. Tarvainen. A robust algorithm for heart rate variability time series artefact correction using novel beat classification. J Med Eng Technol., 43(3):173–181, 2019.
- [17] D. Makowski, T. Pham, Z. J. Lau, J. C. Brammer, F. Lespinasse, H. Pham, C. Schölzel, and S. H. Annabel Chen. NeuroKit2: A python toolbox for neurophysiological signal processing. Behavior Research Methods, 53(4):1689–1696, feb 2021.
- [18] J. Mateo and P. Laguna. Analysis of heart rate variability in the presence of ectopic beats using the heart timing signal. IEEE Transactions on Biomedical Engineering, 50(3):334–343, 2003.
- [19] J. M. Palmer. Certain Non-Classical Inference Procedures Applied to the inverse Gaussian distribution. PhD thesis, Oklahoma State University, 2004.
- [20] J. Rand, A. Hoover, S. Fishel, J. Moss, J. Pappas, and E. Muth. Real-time correction of heart interbeat intervals. IEEE Transactions on Biomedical Engineering, 54(5):946–950, 2007.
- [21] O. Rompelman, J.B.I.M. Snijders, and C. J. Van Spronsen. The measurement of heart rate variability spectra with the help of a personal computer. IEEE Transactions on Biomedical Engineering, BME-29(7):503–510, 1982.
- [22] S. Ross. Introduction to Probability Models. Academic Press, 2014.
- [23] M. Roth, E. Özkan, and F. Gustafsson. A student’s t filter for heavy tailed process and measurement noise. In 2013 IEEE International Conference on Acoustics, Speech and Signal Processing, pages 5770–5774, 2013.
- [24] S. Särkkä. Bayesian Filtering and Smoothing. Cambridge University Press, 2013.
- [25] J. Q. Smith. A generalization of the bayesian steady forecasting filter. Journal of the Royal Statistical Society B, 41:375–387, 1979.
- [26] D. L. Snyder and M. I. Miller. Random Point Processes in Time and Space. Springer, 1991.
- [27] H. Wang, H. Li, J. Fang, and H. Wang. Robust gaussian kalman filter with outlier detection. IEEE Signal Processing Letters, 25(8):1236–1240, 2018.
- [28] A. Wirgin. The inverse crime. arXiv:math-ph/0401050, 2004.