Converter tool

Heart Rate Variability Analysis

Load beat-to-beat intervals or an ECG and get SDNN, RMSSD, pNN50, LF/HF, Poincare SD1/SD2 and entropy values, defined as in the 1996 Task Force standard.

Input

Recording

Heart Rate Variability Analysis from RR Intervals

Operator: Abdulla Al Fahad. How tools are built and checked

Heart rate variability is the spread of the beat-to-beat intervals, and the 1996 ESC and NASPE Task Force standard fixed what the common numbers mean: SDNN, RMSSD, pNN50, the triangular index, the power in the VLF, LF and HF bands, and the ratio of the last two. A chest strap or ECG gives you the intervals; this page turns them into those numbers, after replacing artefacts and refusing to compute spectra from a segment that is too short to carry them. It describes a recording and does not diagnose anything.

Key features

  • Reads RR intervals in milliseconds or seconds, one per line or as a column of a CSV, and up to 12 recordings at once for a side-by-side table
  • Detects R peaks in an ECG column with a Pan-Tompkins style detector when you give the sample rate
  • Replaces artefacts by comparison with the local median and shows how many intervals changed
  • Time domain: mean RR and heart rate, SDNN, RMSSD, SDSD, NN50 and pNN50, triangular index and TINN
  • Frequency domain by a Welch estimate on a 4 Hz spline tachogram and by a Lomb-Scargle periodogram, side by side, with VLF, LF and HF power in ms², normalised units, LF/HF and the peak frequencies
  • Poincare SD1 and SD2, sample and approximate entropy, and detrended fluctuation exponents alpha1 and alpha2
  • A start and end minute to select a segment, a tachogram, the spectrum and the Poincare plot, and a CSV summary and an interval CSV

Input layouts, artefact correction and the spectral estimators

Give one interval per line, or a CSV whose header has a column named rr, ibi, nn or similar; without such a name the last column is used. If the median value is below 10 the numbers are taken as seconds and converted to milliseconds. Polar and Kubios text exports with a plain list of intervals open as they are. Up to 30,000 intervals are analysed per recording; choose a segment for longer ones.

For an ECG, choose the ECG option, give the sample rate between 100 and 5,000 Hz, and use a file with at least 10 seconds of samples in one column. The page finds the beats and works from the intervals between them. FIT files and EDF files are not read, and there is no screen for correcting individual beats by hand.

How it works

Artefact correction marks an interval when it lies outside 250 to 2,500 ms or differs from the median of its eleven neighbours by more than the chosen percentage (20 by default). Marked intervals are replaced by straight-line interpolation between the nearest intervals that passed, so the series keeps its length and its timing. This is a simple threshold method, not the more elaborate detection of Lipponen and Tarvainen.

Time-domain values follow the Task Force. SDNN is the sample standard deviation of the intervals. RMSSD is the root mean square of successive differences. NN50 counts successive differences above 50 ms and pNN50 divides by the number of differences. The triangular index is the number of intervals divided by the height of the histogram peak in 1/128 s bins, and TINN is the base width of the triangle that best fits the histogram by least squares.

For the Welch estimate the beat series is resampled to 4 Hz with a cubic spline, detrended by smoothness priors when lambda is above zero, and averaged over Hann-windowed segments of up to 256 seconds with 50% overlap. The Lomb-Scargle periodogram works on the unevenly spaced intervals directly, on a 0.0005 Hz grid up to 0.5 Hz, scaled so that its integral over the band equals the variance. Band powers are sums of the density over each band: VLF 0.0033 to 0.04 Hz, LF 0.04 to 0.15 Hz, HF 0.15 to 0.4 Hz.

SD1 is SDSD divided by the square root of 2, and SD2 is the square root of 2·SDNN² − SD1². Entropies use embedding length 2 and tolerance 0.2 of the standard deviation on at most the first 3,000 intervals. The scaling exponent alpha1 is the slope of log fluctuation against log box size for boxes of 4 to 16 beats, and alpha2 uses 16 to 64 beats and needs at least 128 intervals.

Common use cases

  • A coach loads three morning recordings of 300 to 420 seconds each and reads SDNN, RMSSD and mean heart rate in the comparison table, then opens the one with the lowest RMSSD to look at its tachogram.
  • A student has a two-hour ECG at 250 Hz and cuts a 5-minute window with a start of 40 and an end of 45 minutes, so that the spectrum meets the Task Force length for LF and VLF.
  • A researcher with a 90-second strap segment sees the page decline to compute spectra, because frequency-domain values need at least 2 minutes of data, and uses the time-domain numbers only.
  • An analyst sees that 14 of 330 intervals were replaced, 4.2%, and the warning that above about 5% the results are doubtful, and goes back to the raw strap data.
  • A user compares Welch and Lomb-Scargle LF/HF on the same file and finds 1.46 and 1.39: the difference comes from windowing and the resampling step, not from a fault in either.

How to use this tool

  1. Choose whether the file holds intervals or an ECG, and add the sample rate for an ECG.
  2. Drop one or more files, paste a column, or use the example.
  3. Leave artefact correction on at 20% unless your recording is clean, and set a segment if you want a 5-minute window rather than the whole file.
  4. Read the time-domain cards and the note about any replaced intervals.
  5. Compare the Welch and Lomb-Scargle band powers; when they disagree by much, the segment is probably too short or too noisy.
  6. Download the summary CSV for all recordings, or the interval CSV for the selected one.

Example

The page's example: a simulated 5-minute recording of 354 beats with a 0.10 Hz and a 0.25 Hz rhythm of 30 ms and 25 ms amplitude plus noise

Intervals only. Artefact correction on, 20%. Detrending lambda 500. Whole recording.

Results

Mean RR 849.5 ms (70.6 beats/min), SDNN 27.79 ms, RMSSD 25.05 ms, pNN50 0.28%, triangular index 8.05
SD1 17.74 ms, SD2 35.07 ms
Lomb-Scargle: LF 443.1 ms², HF 319.6 ms², LF/HF 1.39, peaks at 0.100 and 0.250 Hz
Welch: LF 455.4 ms², HF 311.4 ms², LF/HF 1.46

Tips for best results

  • Use the Lomb-Scargle values when beats were removed or interpolated over a long gap, because it does not need the series to be evenly sampled.
  • Set the lambda of the detrending to 0 only when the recording is already stationary; a drifting mean heart rate otherwise leaks into the VLF and LF bands.
  • Keep segments the same length when you compare recordings, since SDNN grows with duration and VLF power depends on the window.

Common pitfalls

Short-term values cannot be compared with 24-hour values. SDNN over 5 minutes and SDNN over 24 hours measure different things, and the Task Force standards are separate for them.

LF/HF is not a clean measure of sympathetic balance. LF contains parasympathetic and baroreflex activity, and breathing slower than 9 breaths per minute puts respiratory power into the LF band.

Automatic R-peak detection can miss or double beats on a noisy ECG. The artefact count is the check: a high replaced percentage on an ECG usually means a missed beat, not real variability.

Entropy and DFA values need long, clean series. The page computes them from as few as 30 intervals, but values from under about 300 intervals are very noisy.

Common errors and how to fix them

Frequency-domain values need at least 2 minutes of data; this segment is too short.
Select a longer segment, or read the time-domain and Poincare values only; VLF appears from 5 minutes.
The values look like clock times (they rise steadily and are far too large for heartbeat intervals), for example Unix timestamps.
Pick the column that holds the gap between beats. If the file only has beat times, subtract each time from the one before it and save the differences as a new column.
Fewer than 30 intervals fall inside the selected segment.
Widen the start and end minutes, or clear them to use the whole recording.
Only 12 beats were detected. Check the sample rate and that the column is the ECG.
A wrong sample rate stretches the time axis and the detector then sees no QRS shape; check the rate stated by the device.
The segment has 41,203 intervals; the limit is 30,000.
Cut the recording to a shorter window, for example the 5 minutes you actually want to analyse.

Best practices

  • Record at rest, seated or supine, with steady breathing, when the aim is to compare days; movement changes every number.
  • Report the segment length, the artefact percentage and the spectral method next to any HRV value you quote.

What the Task Force minimums mean here

The page enforces the length limits instead of leaving them to you. Below 2 minutes it computes no spectrum. From 2 to 5 minutes it shows LF and HF with a warning and leaves VLF out, because the lowest VLF frequency, 0.0033 Hz, has a period of about 5 minutes. From 5 minutes it adds VLF. Time-domain values need only 30 intervals, but the standard recommends 5-minute segments for short-term analysis and the page shows the segment length so you can see what you are comparing.

Frequently asked questions

How were the definitions checked?

Each definition has a closed form that the code reproduces. An alternating series of 800 and 860 ms gives RMSSD 60.00 ms, pNN50 100% and SDNN 30.15 ms, which is the square root of 100/99 times 900. A sinusoid of 40 ms amplitude at 0.1 Hz sampled at a constant 0.8 s interval has LF power A²/2 = 800 ms², and Welch gave 799.8 and Lomb-Scargle 797.3. SD1² + SD2² equals 2·SDNN² for every series.

Why are the Welch and Lomb-Scargle results different?

Welch resamples the intervals onto a regular 4 Hz grid by a spline and uses windowed segments, which smooths the series and reduces resolution at low frequency. Lomb-Scargle fits sinusoids to the original irregular points. For the example recording they agree to within 3% in LF and 3% in HF; on short or gappy recordings they differ more.

Can I use this for a medical decision?

No. It is a calculator for research, training and curiosity. It has not been validated as a medical device, and normal ranges depend on age, sex, posture and recording length.

Does it read the HRV messages in a FIT file?

No. Export the intervals as text from the app that holds them, or give the ECG column.

Why is pNN50 so low in the example?

The simulated rhythm moves the interval by tens of milliseconds over several seconds, so successive beats rarely differ by more than 50 ms. The same SDNN with faster beat-to-beat swings would give a much higher pNN50.