viewof hr = Inputs.range([45, 110], { value: 65, step: 1, label: "Mean heart rate (bpm)" })
viewof resp = Inputs.range([4, 30], { value: 15, step: 0.5, label: "Respiratory rate (breaths/min)" })
viewof rsa = Inputs.range([0, 10], { value: 3, step: 0.1, label: "Respiratory fluctuation A_resp (bpm)" })
viewof baro = Inputs.range([0, 6], { value: 1.5, step: 0.1, label: "Baroreflex fluctuation A_baro (bpm)" })
viewof slow = Inputs.range([0, 6], { value: 2, step: 0.1, label: "Slow fluctuation A_slow (bpm)" })
viewof noise = Inputs.range([0, 30], { value: 5, step: 1, label: "SD of measurement noise ε (ms)" })
viewof ectopic = Inputs.toggle({ label: "Insert 3 premature beats", value: false })
viewof correct = Inputs.toggle({ label: "Correct abnormal beats (replace beats deviating ≥20% from the local median)", value: false })
viewof regen = Inputs.button("Change the noise random seed")8 Hands-on: HRV Analysis in the Browser
In this chapter, we synthesize 5 minutes of RR intervals in the browser and analyze them with the procedure from Chapters 4 and 5 (correction of abnormal beats → time-domain metrics → resampling → spectral estimation by Welch’s method). When you move a slider, everything from data generation to analysis is redone on the spot.
WarningThis is a “conceptual model”
The RR intervals are artificial data made by adding together sine waves for respiration, the baroreflex (0.1 Hz), and slow fluctuations, plus noise. Real heart-rate fluctuations are more complex, but this is sufficient to check what the metrics respond to and what they are easily misread as.
8.1 Model
The instantaneous heart rate is constructed as the mean heart rate plus three kinds of fluctuation, converted to RR intervals, and then noise is added.
\mathrm{HR}(t) = \overline{\mathrm{HR}} + \underbrace{A_{\mathrm{resp}} \sin(2\pi f_{\mathrm{resp}} t)}_{\text{respiration (RSA)}} + \underbrace{A_{\mathrm{baro}} \sin(2\pi \cdot 0.1\, t + \phi_1)}_{\text{baroreflex}} + \underbrace{A_{\mathrm{slow}} \, s(t)}_{\text{slow fluctuation}}, \qquad \mathrm{RR}_i = \frac{60000}{\mathrm{HR}(t_i)} + \varepsilon_i
The sizes of the fluctuations are given in units of heart rate (bpm). Therefore, for the same fluctuation, the RR-interval fluctuation becomes smaller when the mean heart rate is higher (Chapter 6).
8.2 Control panel
8.3 Results
8.3.1 Tachogram
● Premature beats ○ Beats replaced by correction
8.3.2 Power spectrum and Poincaré plot
The blue dashed line is the respiratory frequency.
8.3.3 Metrics
8.4 Experiments
Before each experiment, return the panel to the defaults (heart rate 65, respiratory rate 15, A_resp 3, A_baro 1.5, A_slow 2, noise 5, premature beats and correction off) and press “Save current values as baseline” before making changes; this makes it easier to compare percentage changes.
8.4.1 Experiment A: What happens to LF/HF when breathing slows?
Lower the respiratory rate from 15 to 6 breaths/min. Do not change the size of the fluctuation (A_resp).
TipWhat to observe
- From which band to which band did the spectral peak move?
- How did LF, HF, and LF/HF change?
- How did RMSSD change? Is the change larger or smaller than for HF?
NoteExplanation
A respiratory rate of 6 breaths/min = 0.1 Hz, so the respiratory fluctuation falls into the LF band. As a result, HF decreases greatly, and LF and LF/HF increase greatly. Although nothing about the autonomic state (the size of the fluctuations) was changed in this model, reading it as “LF/HF rise = sympathetic dominance” leads to exactly the wrong conclusion (Chapters 5 and 6).
RMSSD also decreases because the differences between adjacent beats become smaller when the fluctuation slows, but the change is not as extreme as for HF. In real humans, slow, deep breathing also increases the amplitude of RSA itself (try reproducing this by raising A_resp).
8.4.2 Experiment B: Just three premature beats
Turn on “Insert 3 premature beats”. That is only 3 beats (about 1%) out of about 300 beats in 5 minutes.
TipWhat to observe
- How much did RMSSD, pNN50, and HF change? Compared with SDNN?
- What appeared in the Poincaré plot?
- Next, when you turn on “Correct abnormal beats”, how far do they return to the original values?
NoteExplanation
A premature beat creates very large adjacent differences (“short RR → long RR”), so RMSSD, which squares and averages adjacent differences, jumps sharply. In the spectrum, abrupt changes scatter power across a wide band, so HF and others also increase. In the Poincaré plot they appear as points far from the main cluster.
The fact that abnormal beats amounting to only 1% change the metrics greatly shows that detection and correction of abnormal beats, and reporting of the correction rate, are essential (Chapter 4).
8.4.3 Experiment C: HRV falls just because heart rate rises
Keep the size of the fluctuations (in bpm) unchanged and raise the mean heart rate from 65 to 90 bpm.
NoteExplanation
From the relationship RR = 60000 / HR, even for the same ±3 bpm fluctuation, the RR-interval fluctuation becomes smaller at a higher heart rate (about half going from 65 bpm → 90 bpm). SDNN, RMSSD, and HF all decrease greatly.
In real organisms, a rise in heart rate (vagal withdrawal) and a fall in HRV often occur together, and it is not easy to distinguish how much is “autonomic change” and how much is “a mathematical effect” (Chapter 6).
8.4.4 Experiment D: What if the vagus is blocked? (picture atropine administration)
When the vagus is blocked, the respiratory fluctuation almost disappears, the baroreflex fluctuation also decreases greatly, and the heart rate approaches the intrinsic heart rate. Try the following settings.
- Mean heart rate: 100 bpm
- A_resp: 0, A_baro: 0.3, A_slow: 1
NoteExplanation
Confirm that not only HF but LF also decreases greatly. If LF were “an index of sympathetic activity”, vagal blockade should not reduce LF. In real humans too, it is known that atropine abolishes most of LF, and this is one of the grounds on which the interpretation “LF = sympathetic” is rejected (Chapters 2 and 5).
8.4.5 Experiment E: The effect of measurement noise
Raise the noise SD from 5 to 20 ms. This assumes errors in inter-beat intervals derived from PPG (pulse wave), or quantization error at a low sampling frequency.
NoteExplanation
Beat-to-beat independent noise enlarges adjacent differences and therefore causes overestimation of RMSSD and pNN50. In the spectrum, power is added evenly across all bands (as white noise), so the wider HF band gains a larger amount (ms²). The effect on SDNN is smaller than on RMSSD. This is one reason PPG-derived PRV tends to overestimate RMSSD and HF outside rest (Chapter 4).
8.5 Open exercises
- Assuming resonance-frequency breathing (6 breaths/min), what happens to SDNN when A_resp is increased?
- When the respiratory rate is set to 30 breaths/min (0.5 Hz), where does the respiratory fluctuation go? Think about the relationship between the upper HF limit of 0.4 Hz and the mean heart rate (which corresponds to the sampling rate)
- Confirm with several settings that SD1 and RMSSD / √2 almost coincide