^{1}

^{1}

^{2}

^{3}

^{1}

^{2}

^{3}

The heart rate variability (HRV) signal derived from the ECG is a beat-to-beat record of RR intervals and is, as a time series, irregularly sampled. It is common engineering practice to resample this record, typically at 4 Hz, onto a regular time axis for analysis in advance of time domain filtering and spectral analysis based on the DFT. However, it is recognised that resampling introduces noise and frequency bias. The present work describes the implementation of a time-varying filter using a smoothing priors approach based on a Gaussian process model, which does not require data to be regular in time. Its output is directly compatible with the Lomb-Scargle algorithm for power density estimation. A web-based demonstration is available over the Internet for exemplar data. The MATLAB (MathWorks Inc.) code can be downloaded as open source.

A time record consisting of beat-to-beat RR intervals is referred to as the heart rate tachogram. This forms the basis for a number of metrics of heart rate variability (HRV). The simplest measures of HRV are based on variance determined over a range of time periods. More complex measures can be derived from power spectrum density (PSD) estimations. The two most commonly used PSDs are the Welch Periodogram, based on the DFT, and the AR Spectrum, based on an autoregressive process model [

Prior to transformation into the frequency domain, normal practice requires that the time series data are “detrended” or “high-pass filtered” at a very low frequency, say ~0.005 Hz. There is no universally formal justification for such detrending other than it minimises the effects of medium-term nonstationarity within the immediate time epoch (window) of interest [

A number of methods have been described to identify the trend component in the tachogram such that it can be simply removed by subtraction. These methods include fixed low-order polynomials [

However, the Tarvainen approach suffers two limitations. The first is conceptual: the algorithm requires resampling by interpolation onto a regular time axis. The second is practical: the MATLAB implementation is computationally inefficient and expensive and consequently very slow. In practice, its application is limited to relatively short tachograms [

In the present work, a novel algorithm is introduced which obviates these limitations by extending the SPA. The Smoothing by Gaussian process Priors (SGP) method described here explicitly does not require resampling and executes in MATLAB at least an order of magnitude faster than the SPA. By employing the SGP twice in sequence, the bandpass effect achieves detrending (high-pass) and low-pass filtering which is directly compatible with the Lomb Scargle Periodogram (LSP) [

The SPA method considers the problem of modelling the trend component in a time series with a linear observation model:

By choosing

Tarvainen et al. argue that selection of the observation matrix is done to simplify things, in the context of estimating parameters in a finite-dimensional space. A Bayesian interpretation of (

Use of the

A different approximation formula to the derivative, which does not imply uniform sampling, can also be obtained by Taylor expansion with nonuniform increments. After some algebra,

The rows of the operator now explicitly depend on the

The operator is denoted by the symbol

An efficient implementation of the above algorithm (MATLAB) is the following:

Note that to reduce the possibility of numerical instabilities in the solution of the linear systems, the D2hat matrix is normalised by the first element of vector V1.

The operation of the smoothing priors can be understood by looking at the following simplified form:

Since each element of

In the case of uniformly sampled data, the weighting functions have the same shape (except at the boundaries), which can be imagined as a sliding window translating in time: this is a consequence of the definition of the

Weight functions (

However, for the case of arbitrarily (irregularly) sampled data of the HRV tachogram, the

From the above, the power spectral density of the equivalent kernel filter is derived as

In Figure

Bode plot of theoretical transfer function of equivalent kernel filter.

Although the approximation in (

Inverting (

Since the number of data points mostly impacts the estimation of low frequencies, the expectation is that the approximation is good in the low-frequency range.

In a Monte Carlo simulation, 1000 replications of the Welch periodogram estimates were made of white Gaussian noise coloured through the equivalent filter

approximation of −3 dB point [Hz].

True –3 dB cut-off frequency | Approximate frequency |
---|---|

0.05 | 0.049 |

0.1 | 0.102 |

0.2 | 0.208 |

0.3 | 0.34 |

Figure

Bode plot of discrete transfer function of equivalent kernel filter.

There is very little phase distortion, except at very high frequencies close to the Nyquist frequency.

A synthetic data set of was generated (MATLAB) as series of normallydistributed random numbers of mean 0.85(1) s (equivalent to a heart rate of ~75 bpm) and std 0.025 s: this was low-pass filtered at 1 Hz (3rd-order phase-less IIR). These data were projected by interpolation, onto an irregular time axis of mean interval 0.86(1) s and variance 0.01s^{2}. The resulting synthetic HRV record, as a time record of band-limited Gaussian noise, was of 30 s duration, average sampling frequency of 1.15(6) Hz and had no significant power above 1 Hz.

Clinical ECG data from a Lead II configuration were recorded from a healthy adult seated for a period of 60 minutes using a Spacelabs Medical Pathfinder Holter system. RR intervals were available with 1 ms resolution.

The time domain and frequency domain (as the Lomb Scargle periodogram) representations of the synthetic data set and the clinical data set are shown in Figure

Synthetic and clinical HRV records band-pass filtered by sequential application of SGP: raw data

Resources relevant to this work are located at

A website demonstration of SGP running on an automation instance of MATLAB 2008a. Developed for JavaScript-enabled MS IE6+ and FireFox browsers.

MATLAB open-source code:

Smoothing by Gaussian process Priors (SGP): gpsmooth_3.m,

Optimized Lomb Scargle Periodogram (fLSPw:

The SGP (Smoothing by Gaussian process Priors) algorithm is a second-order response time-varying filter which operates on irregularly sampled data without compromising low-frequency fidelity. In the context of Heart Rate Variability analysis, it provides detrending (high-pass) and low-pass filtering with explicitly specified −3 dB cut-off points. A small limitation is the implicit requirement to assume a

Consider the posterior expectation of a GP regressor (

Comparing the above with (

The parameter

The smoothness properties of the resulting estimator depend not only on

A Gaussian process is completely described by its mean function and covariance function. Given a real process

A stationary covariance function is a function of

If any of the above conditions are violated, then the process is non-stationary; an example is the Gaussian process whose inverse covariance matrix is given by (

In general, matrix inversion is very computationally expensive and should be avoided whenever possible A more efficient solution uses the

With this decomposition, matrix inversion can then simply be written as the solution, in sequence, of two triangular systems of linear equations, which is a very fast and numerically stable operation:

Although the theoretical computational complexity of straight matrix inversion and the above (seemingly more complex) steps is the same, the

Speed-up of SGP over SPA with increasing data set size.

It is clear that, as the dimension of the data set increases, the speed-up increases quadratically, showing the inefficiency of the matrix inversion-based smoothing. The following code (MATLAB R006b) was used:

It should be noted that in MATLAB R2006a, and possibly previous versions, multiplication of the