Frequency Domain Analysis Methodology in LensHRV

Engineering decisions behind LF and HF metrics

Capturing Heart Rate Variability (HRV) with photoplethysmography (PPG) presents a challenge: high susceptibility to beat loss. This document details the technical path and engineering decisions behind LensHRV for computing frequency-domain metrics, prioritizing stability and mathematical fidelity of the signal.

1. The Task Force (1996) standard and its limitations for PPG

The starting point for frequency analysis in HRV is the standard published in 1996 by the international Task Force (Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology, 1996).

In this framework, one of the methods used to analyze the signal spectrum is the Fourier method, which decomposes a signal into the frequencies that compose it and estimates how much power is present in each of them.

This procedure was established to analyze the electrical signal of the electrocardiogram (ECG) from the intervals between beats. In the app, the same spectral analysis principle is applied, but using inter-pulse intervals obtained via PPG instead of RR intervals derived from ECG.

2. The Zaragoza study and the missing-beats problem

To size how much trust can be placed in LF and HF when PPG loses beats, the work of Cajal and colleagues (University of Zaragoza / I3A, 2022) on the effect of missing data on HRV metrics was used as a reference. In that study, clean signals are subjected to controlled losses and common corrections are compared—from leaving gaps unfilled to linear and nonlinear interpolations (including Hermite)—together with spectral estimates by FFT (Welch) and by Lomb–Scargle.

In the frequency domain, filling gaps in a reasonable way is usually preferable to analyzing only the surviving beats without reconstruction—even though, in theory, Lomb–Scargle is designed for irregular cases.

A practical criterion for a tolerable metric is that the third quartile of the relative error with respect to the clean signal stays below 20%. Under that framework, the paper places HF band rejection around 15% of missing beats for scattered losses, while long continuous bursts invalidate the segment with duration thresholds on the order of tens of seconds.

The application uses that same criterion, which is explained further below with three methods tested on 16 clean PPG signals.

In the app, the scattered regime is assumed to be the most frequent in real use. Continuous bursts are treated as a case for discarding the recording, not as a scenario to “rescue” with aggressive interpolation.

3. 120-second window and stationarity

The two-minute (120 s) window from the Zaragoza study is not arbitrary: it matches the minimum duration that the 1996 Task Force associates with a usable estimate of the slower part of LF (≈ 0.04 Hz). At that frequency, one cycle lasts 25 s; in 120 s there are on the order of four to five cycles—the minimum commonly accepted. That is why LensHRV fixes 120 s as the standard duration for spectral analysis.

In Zaragoza, stationarity was assumed in short segments of controlled rest. In real captures, even two minutes can show slow drift. How that non-stationarity is mitigated in the product is described later.

4. Validation and choice of a practical loss limit

To avoid adopting the 15% limit solely from a literature reference, the spirit of the Zaragoza simulation was reproduced through a numerical evaluation. The goal was to compare the behavior of Fourier-based methods, using the classical Welch method, and of Lomb–Scargle under different levels of pulse loss.

In particular, the aim was to determine which method provided more accurate results as missing data increased, and to check whether Lomb–Scargle—by working directly with irregularly spaced data—kept higher fidelity to the physiological behavior of the signal in the presence of losses.

16 PPG signals were used—sessions in which the detector and quality filter did not remove beats due to artifact—and, on each of them, the paper’s methodology was replicated. Artificial losses were generated through independent Bernoulli trials: each beat is assigned a fixed deletion probability (for example, 10%)—like flipping a coin on every beat with a 10% chance of being erased.

A) Evaluation at 10% loss (p = 0.10)

As an initial stress scenario at 10% scattered loss, the 16 clean sessions were evaluated by running 10 independent random repetitions per session (160 simulations in total). In each simulation, three analysis arms were run simultaneously: Lomb OR (trimmed series without interpolation), Lomb + Hermite, and Welch + Hermite. For each session and arm, percentage errors were sorted from lowest to highest and the third quartile (Q3 / 75th percentile) was extracted, applying the acceptance rule Q3 < 20%.

id OR_L OR_H LH_L LH_H W_L W_H
13.6(P)7.7(P)4.2(P)9.9(P)4.0(P)14.0(P)
215.1(P)18.7(P)5.0(P)9.3(P)8.3(P)15.0(P)
36.4(P)8.0(P)4.0(P)9.3(P)5.1(P)15.0(P)
49.4(P)12.8(P)6.9(P)11.9(P)9.0(P)12.6(P)
59.9(P)29.3(F)1.4(P)8.1(P)4.3(P)11.1(P)
69.0(P)44.6(F)3.2(P)17.0(P)4.1(P)19.1(P)
717.1(P)6.2(P)10.9(P)12.4(P)8.8(P)13.0(P)
812.8(P)8.5(P)10.8(P)10.4(P)13.2(P)13.7(P)
99.3(P)13.5(P)7.8(P)15.9(P)11.4(P)16.6(P)
1014.8(P)12.2(P)6.6(P)8.4(P)7.5(P)12.6(P)
1110.2(P)15.6(P)7.0(P)9.9(P)7.6(P)9.6(P)
1210.8(P)13.2(P)6.2(P)17.1(P)9.3(P)14.7(P)
137.5(P)14.0(P)3.4(P)7.6(P)4.5(P)8.9(P)
1417.3(P)14.1(P)6.7(P)8.8(P)11.7(P)9.4(P)
159.2(P)57.4(F)3.5(P)4.2(P)2.3(P)6.3(P)
1614.7(P)6.6(P)11.7(P)14.6(P)19.6(P)16.2(P)

OR = Lomb without interpolation · LH = Lomb + Hermite · W = Welch + Hermite · L = LF · H = HF · (P) pass · (F) fail · Q3 relative error (%)

At 10% loss, Lomb + Hermite passed all 16 subjects with no failures (100% success) and was numerically more accurate than Welch + Hermite in 14 of the 16 sessions. On average, Lomb + Hermite error in HF was lower (10.8%) than Welch + Hermite (13.1%). Lomb OR failed in 3 of the 16 sessions, with spectral over-oscillation peaks of up to 57.4% in HF.

B) Evaluation at 15% loss (p = 0.15)

id OR_L OR_H LH_L LH_H W_L W_H
19.9(P)10.1(P)4.9(P)18.3(P)9.5(P)21.2(F)
216.8(P)22.1(F)4.7(P)17.9(P)5.6(P)22.9(F)
39.3(P)9.5(P)4.3(P)16.4(P)7.6(P)20.9(F)
412.1(P)16.5(P)7.9(P)16.8(P)11.1(P)22.0(F)
514.7(P)36.5(F)3.5(P)14.2(P)5.3(P)14.5(P)
613.6(P)60.5(F)4.8(P)17.1(P)6.8(P)21.1(F)
712.6(P)5.9(P)15.0(P)16.3(P)14.3(P)19.7(P)
813.8(P)11.2(P)5.4(P)14.0(P)10.2(P)19.7(P)
918.2(P)24.0(F)7.7(P)19.6(P)14.3(P)22.3(F)
1015.5(P)16.8(P)8.3(P)13.5(P)11.1(P)18.3(P)
1112.7(P)19.6(P)7.4(P)14.5(P)9.4(P)18.0(P)
1213.8(P)20.0(F)6.7(P)21.3(F)12.3(P)16.0(P)
1317.2(P)21.9(F)3.5(P)9.1(P)4.3(P)12.7(P)
1420.9(F)17.0(P)5.2(P)13.4(P)11.6(P)12.0(P)
159.1(P)62.2(F)4.2(P)7.9(P)3.3(P)12.7(P)
1618.2(P)7.6(P)16.9(P)17.8(P)24.2(F)21.1(F)

OR = Lomb without interpolation · LH = Lomb + Hermite · W = Welch + Hermite · L = LF · H = HF · (P) pass · (F) fail · Q3 relative error (%)

Raising loss to 15% confirmed that the HF band is the most fragile part of the spectrum. Lomb + Hermite remained the only stably operational method: it preserved the LF band intact (100% success) and in HF passed 15 of the 16 sessions (93.8% success), with its only failure slightly off at 21.3%.

By contrast, Welch + Hermite collapsed in HF by failing in 7 of the 16 sessions (43.8% failure rate) due to rigid resampling distortion. Lomb OR failed in 6 HF sessions, with uncontrolled explosions of up to 62.2% error.

Lomb + Hermite proved about 7 times more stable than Welch + Hermite at the 15% loss threshold, keeping a 93.8% pass rate versus 56.3% for Welch, and reducing average error in the critical HF band by 17% in a consistent way.

C) Evaluation at 20% loss (p = 0.20) and design conclusion

id OR_L OR_H LH_L LH_H W_L W_H
19.9(P)17.8(P)7.1(P)20.8(F)10.7(P)24.8(F)
218.5(P)29.6(F)7.7(P)21.1(F)10.0(P)27.4(F)
37.2(P)9.5(P)6.8(P)21.8(F)11.9(P)23.5(F)
420.8(F)21.0(F)11.4(P)19.3(P)15.3(P)24.8(F)
518.3(P)43.4(F)4.1(P)18.1(P)7.9(P)19.8(P)
622.6(F)82.8(F)5.0(P)23.3(F)6.7(P)27.8(F)
79.3(P)8.4(P)21.5(F)23.6(F)24.6(F)26.3(F)
816.5(P)12.7(P)11.8(P)20.9(F)19.2(P)28.8(F)
918.0(P)29.9(F)12.7(P)23.7(F)16.6(P)26.7(F)
1014.4(P)21.0(F)10.1(P)19.2(P)12.0(P)23.1(F)
1122.7(F)22.1(F)8.1(P)21.0(F)9.6(P)24.5(F)
1217.6(P)27.7(F)6.6(P)25.7(F)13.3(P)21.5(F)
1316.5(P)24.9(F)4.9(P)16.0(P)9.8(P)21.9(F)
1419.6(P)19.4(P)10.3(P)16.1(P)17.4(P)15.7(P)
1514.2(P)90.4(F)3.9(P)10.2(P)3.7(P)13.0(P)
1616.6(P)10.2(P)16.5(P)27.8(F)41.5(F)27.8(F)

OR = Lomb without interpolation · LH = Lomb + Hermite · W = Welch + Hermite · L = LF · H = HF · (P) pass · (F) fail · Q3 relative error (%)

Raising loss to 20%, the LF band under Lomb + Hermite remains extraordinarily stable (15 of 16 sessions passed). However, in the fragile HF band there is a generalized estimator failure: Lomb + Hermite exceeds the Q3 < 20% contract in 10 of the 16 sessions (62.5% failure), while Welch + Hermite failed in 13 of the 16 sessions (81.3% failure) and Lomb OR reached distortions of up to 90.4% error.

This drop confirms empirically that above 15% missing data, the temporal structure of high frequencies degrades physically to a point where no reconstruction algorithm or spectral estimator can guarantee fidelity.

For these reasons, the LensHRV frequency-metrics pipeline uses the Lomb + Hermite combination, with a maximum operational limit of 15% missing data in the 120 s window. If the fraction of synthetic or missing beats exceeds that 15%, the recording is automatically invalidated for LF/HF—guaranteeing the best available stability and precision relative to the other alternatives.

Additionally, to check at which artifact levels error is still far more acceptable inside the valid range, a lighter evaluation was run at 5% artifact loss. In empirical evaluations at 5% artifact loss, relative errors in frequency metrics remained strictly bounded below 9.8% in the worst-case scenario (averaging ~5%). That result supports two quality indicators on top of the hard operational cut: excellent grade below 5% artifacts, and good grade below 15% artifacts. The same grade language is aligned with the time-domain quality story documented next.

5. Signal conditioning: Slow-drift suppression

In the Zaragoza study, strict stationarity was assumed when working with short segments of controlled rest. In real captures with commercial PPG sensors, however, the signal often shows low-frequency slow drift and non-autonomic physiological trends that introduce pink noise (1/f). If left uncorrected, these trends artificially inflate spectral energy, mainly contaminating the LF band.

To address this and stabilize the calculation in LensHRV, the Smoothness Priors detrending method (Tarvainen et al., 2002) was implemented, solving the regularization matrix with a weight parameter λ = 500.

After analysis, this matrix filtering was shown to systematically remove—across 16 tests—between 5% and up to 45% of the raw non-autonomic energy caused by drift. This ensures that the resulting signal is truly stationary and that LF and HF power reflect only autonomic nervous system activity (sympathetic and parasympathetic), not mechanical artifacts or sensor shifts.

6. Parseval’s theorem calibration and normalization to milliseconds squared (ms²)

The final technical challenge was to standardize the Lomb–Scargle periodogram output so that the resulting metrics would be directly comparable with classical ECG-based clinical literature, expressed in milliseconds squared (ms²).

Because Lomb–Scargle operates on unevenly spaced time series, raw power spectral density (PSD) values lack a direct absolute physical scale. To guarantee mathematical fidelity, the following calibration procedure was developed in LensHRV:

Reference SDNN calculation: The standard deviation of the intervals (SDNN) is computed directly on the RR series after drift has been removed with the Tarvainen matrix.

Total variance extraction: The signal variance (σ² = SDNN²) is set as the coefficient of real physical energy of the recording.

Scaling by Parseval’s theorem: An adjustment based on Parseval’s theorem is applied inside the Lomb–Scargle algorithm, ensuring that the integral of the power spectral density over the full spectrum is identical to the temporal variance of the signal (∫ S(f) df = SDNN²).

As a result, the ms² units provided by LensHRV maintain high consistency and repeatability, resisting the typical volatility of PPG signals on mobile devices and offering a physically faithful reflection of the user’s autonomic variability.

With the spectrum calibrated to physical units, the standard Task Force bands are integrated from the Lomb–Scargle PSD: LF as power between 0.04 and 0.15 Hz, and HF as power between 0.15 and 0.40 Hz (both in ms²), together with the LF/HF ratio. Only after this full conditioning chain— gap handling, detrending, spectral estimation, and Parseval scaling—are the reported frequency metrics considered valid.

7. Coherence score (always reported)

In parallel with LF and HF, every valid spectral session also reports a coherence score, inspired by the HeartMath approach to cardiac resonance. It is an indicator of how concentrated spectral power is around a single peak in the low-frequency resonance region.

On the calibrated Lomb–Scargle spectrum, the algorithm finds the maximum PSD peak between 0.04 and 0.12 Hz (the LF peak frequency shown in the app). Power is then integrated in a narrow window around that peak (±0.015625 Hz). With total power defined as LF + HF, the coherence ratio is:

coherence = peak power / (total power − peak power)

Higher values mean more energy is concentrated at the resonance peak relative to the rest of the LF+HF band. Practical reference ranges used in the product:

0.0 – 0.5: Completely normal and expected in daily life.

0.5 – 2.0: Good resonance state—often from guided breathing.

> 2.0: Excellent.

Internal tests have shown that a score of 3.6 is fully achievable under strong resonance conditions.

Conclusions

The practical takeaway is:

Method of choice: Lomb–Scargle with Hermite gap filling. At the operating limit of 15% scattered missing beats in a 120 s window, it stayed reliable (≈ 94% pass on HF) where Welch and raw Lomb often did not.

Hard quality gate: operational limit at 15% missing data—above that are invalidated. Inside the valid range: excellent grade below 5% artifacts, and good grade below 15%.

Window: 120 s, the Task Force minimum for usable slow LF (≈ 0.04 Hz).

Clean spectrum: Smoothness Priors detrending (λ = 500) removes slow drift before spectral analysis; Parseval scaling locks power to SDNN² so LF/HF come out in ms².

Bands: LF 0.04–0.15 Hz, HF 0.15–0.40 Hz. Plus an always-on HeartMath-inspired coherence score.

In one line: if the take is clean enough, you get stable, physically scaled LF/HF and a coherence reading; if too many beats are missing, the app alerts the screen results.