ECG Adaptive-Compute Switch Research Demo

A blind switch between a cheap adaptive filter and a compact neural refiner — runs entirely in your browser

1. Signal & Noise Source MIT-BIH Database

Both records were held out of training for the network and switch shown below (record-disjoint fold A).

Input SNR: -10.0 dB
-20 dB -10 dB 0 dB +10 dB
2. Filter Engine Adaptive Stage
Switch threshold (τ): 0.65

Invoke the network only if the switch's predicted mixing weight α̂ ≥ τ. 0.65 is the paper's peak operating point (38% invocation).

Step-Size (μ): 0.010
Leaky Memory Factor (λL): 0.995
ΔSNR (Improvement) +11.67 dB
Output SNR +1.46 dB
PRD Error 84.5 %
Correlation (ρ) 0.9842
Client Latency 3.8 ms
Est. Compute 698 MAC/smp
Lead Time-Domain Trace (Showing 0.00s to 10.00s @ 360 Hz)
Time:
Gain:
C-DSAF Blending Dynamics λ(n) 1.0 = Fast, 0.0 = Slow
Zoomed Single-Beat (P-QRS-T Inspection) 1 Cardiac Cycle

System Architecture & Mathematical Formulations

Comprehensive mathematical specifications for each processing stage in the single-channel pipeline.

Stage 1.1

Baseline Wander Removal

In accordance with IEC 60601-2-25 telemetry guidelines, baseline respiration drift (< 0.7 Hz) is suppressed prior to adaptive stages via a 4th-order Butterworth high-pass filter ($f_c = 0.5\text{ Hz}$):

y(n) = ∑ b_k x(n-k) - ∑ a_k y(n-k)

Forward-backward filtering guarantees zero phase distortion, inducing an ST-segment deviation of only $42.1\ \mu\text{V}$ (safe within the $100\ \mu\text{V}$ ischemia boundary).

Stage 1.2

60 Hz Quadrature Notch (PLI)

To remove powerline interference without an auxiliary sensor, orthogonal quadrature sinusoids are synthesized internally:

x_PLI(n) = [sin(ω_0 n), cos(ω_0 n)]^T

A 2-tap adaptive LMS filter updates weights to subtract the narrow-band interference, achieving $>16\text{ dB}$ attenuation without attenuating high-frequency QRS components.

Stage 2.0

C-DSAF Adaptive Architecture

Combines a fast-tracking short filter ($L_1 = 6$) and a high-precision slow filter ($L_2 = 16$) blended through a dynamic sigmoid logit $a(n)$:

v_hat(n) = λ(n) v_1(n) + [1 - λ(n)] v_2(n)

Decoupled filter updates guarantee mean-square convergence, allowing immediate adaptation (<25 ms) during abrupt motion artifacts.

Paper's Record-Disjoint Evaluation (Table, wide grid: 10 noise types × 8 SNRs × 3 held-out-record folds, 3,600 pooled segments)
Policy Network invocation rate Mean ΔSNR (wide grid)
Never invoke (Stage 1 alone) 0% +3.75 dB
Always invoke (SE4 network on every segment) 100% +1.69 dB
Switch (this demo, τ=0.65) 38% +4.95 dB
Oracle switch (upper bound, true weight) ≈45% +5.71 dB

These four rows are the paper's numbers, not something this page computes -- they come from proof scripts in the repository (proofs/ecg-v2-switch.py) over a much larger evaluation than any single record, and include a fix to Stage 1's line canceller (it now auto-detects 50 vs.\ 60 Hz mains instead of assuming 60 Hz -- see the "Unseen 50 Hz Mains" noise option above). Restricted to the composite noise, -10/-5/0 dB range the network was actually designed for, always-invoking it reaches +11.55 dB -- the switch reproduces this automatically without being told which regime it's in.

The metrics ribbon above is different: it is computed live, in your browser, on whichever single record/noise/SNR combination and threshold you have selected -- it will not match the pooled numbers in this table, which average over many more conditions. This demo's switch and network were also fit only on fold A's 3 held-out records (not the leave-one-record-out protocol the paper uses), so treat this page as an illustration of the mechanism, not a restatement of the paper's results.

Model-Based Average Compute per Input Sample
Policy MAC/sample Reduction
Always-on, larger network (15,169 params) 3,923 —
Always-on, this demo's SE4 network (2,313 params) 698 —
Switched, 38% invocation (this demo) 299 −57% / −92%

Arithmetic on analytic MAC counts, not a hardware measurement; does not include the switch's own six-feature Welch-spectrum computation (also run client-side above, but not benchmarked in the paper).