FMM-Head: Enhancing Autoencoder-based ECG anomaly detection with prior knowledge

Giacomo Verardo, Magnus Boman, Samuel Bruchfeld, Marco Chiesa, Sabine Koch, Dejan Kostic, Gerald Q. Maguire Jr. · Submission to ICLR 2024 · Withdrawn

TL;DR

Standard autoencoders for electrocardiogram (ECG) anomaly detection act as unexplainable black boxes and ignore the underlying physiology of cardiac cycles. FMM-Head replaces conventional neural decoders with a structured, explainable reconstruction module based on Frequency Modulated Möbius (FMM) waveforms. This domain-informed prior improves anomaly detection by up to +0.31 AUROC while cutting model size by up to ~50% and extracting physiological parameters over 20,000× faster than classical iterative solvers.

What Problem Does This Paper Address?

Electrocardiograms (ECGs) measure the rhythmic electrical activity of the heart across characteristic wave components: the P wave, the QRS complex, and the T wave. Autoencoders (AEs) are widely used for unsupervised anomaly detection by training strictly on healthy rhythms; during deployment, high reconstruction errors signal abnormalities.

However, existing AEs have significant flaws:

  1. Black-box decoders: Latent spaces and reconstructed features lack physiological interpretability.
  2. Ignored domain structure: Generic neural layers disregard known cardiac waveform shapes and struggle with variable-length heartbeats caused by changing heart rates.
  3. Computational bottlenecks: Mathematical frameworks like Frequency Modulated Möbius (FMM) decompose heartbeats into explainable parameters (amplitude, location, width, direction), but standard iterative optimization takes tens of seconds per beat—far too slow for real-time monitoring on wearables.

Methods

The authors introduce FMM-Head, a drop-in replacement for the decoder in standard autoencoders:

  • Adapter Pooling & Parameter Regression: Encoded latent vectors are mapped via an architecture-specific pooling layer and two fully connected layers into the mathematical parameters for five FMM waves ($\text{P}, \text{Q}, \text{R}, \text{S}, \text{T}$).
  • Domain-Specific Constraints:
  • Circular variables (wave position $\alpha$ and direction $\beta \in [0, 2\pi)$) are predicted as sine and cosine components and recovered via atan2 to respect angular continuity.
  • Wave width $\omega$ is bounded by a sigmoid-like activation with an upper bound $\omega_{max}$ to prevent degenerate, overly wide waves.
  • Softplus activations enforce non-negative amplitudes.
  • FMM Waveform Synthesis: The final ECG signal is reconstructed using the parametric FMM formulation over the normalized interval $[0, 2\pi)$ and rescaled back to the original time duration.
  • Two-Phase Training: The network undergoes an initial warm-up regression phase trained against pre-extracted FMM parameters (with an extra $10\times$ weight on the R-peak). Once aligned, it transitions to standard unsupervised reconstruction-based anomaly detection.
Input ECG ──► [Encoder] ──► [Pooling + Dense] ──► [FMM Parameters (A, α, β, ω, M)] ──► [FMM Equation] ──► Reconstructed ECG

Datasets

The authors evaluated FMM-Head across three established public benchmarks (no new datasets were introduced):

  1. Shaoxing: 12-lead ECG dataset containing 69,663 segmented heartbeats from 10,646 patients, sampled at 500 Hz across 67 conditions.
  2. PTB-XL: Large-scale dataset of 106,709 beats from 18,885 patients, evaluated at 100 Hz.
  3. ECG5000: A benchmark consisting of 5,000 equal-length heartbeats from a single patient.

Key Insights and Ideas

  • Inductive bias beats pure parameter capacity: Replacing dense/LSTM decoders with a fixed mathematical generator forces the encoder to capture true cardiac dynamics rather than memorizing high-frequency noise.
  • Warm-up is vital to prevent wave entanglement: Without the supervised warm-up phase, the network can achieve low reconstruction loss by summing arbitrary, scrambled waves (e.g., three wide waves replacing the QRS complex). Warm-up anchors each head output to its true physiological component.
  • Intrinsic time normalization: Mapping the cardiac cycle to $[0, 2\pi)$ naturally handles variable heart rates and heartbeat lengths—a major challenge for standard fixed-window neural decoders.

Key Results

  • Detection Performance: Incorporating FMM-Head delivered massive AUROC improvements on complex, variable-length datasets:
  • EncDecAD: AUROC increased from 0.384 to 0.695 (+0.311) on PTB-XL and 0.461 to 0.617 (+0.156) on Shaoxing.
  • BertECG: AUROC increased from 0.536 to 0.697 (+0.161) on PTB-XL and 0.545 to 0.650 (+0.105) on Shaoxing.
  • On simple, single-patient datasets (ECG5000), baseline performance was already near-ceiling (~0.98–0.99), showing marginal differences.
  • Inference Speed: FMM-Head predicts FMM coefficients >20,000× faster than classical optimization (which averages ~38 s per beat), reducing inference times to milliseconds and enabling real-time monitoring.
  • Model Footprint: Replacing decoders reduced total parameter footprint by up to 47% to 93% for non-LSTM models and reduced inference latency by 26% to 91% across most architectures.

Limitations and Future Work

  • Single-Lead Only: The current implementation only models single-lead signals (evaluated on Lead 2/Lead 1); extending to 12-lead ECGs with shared inter-lead parameters remains future work.
  • Warm-Up Dependency: The pipeline depends on running expensive classical FMM optimization beforehand on a training subset to initialize the warm-up phase.
  • Overhead on Extremely Simple Models: For minimal baseline architectures (such as DenseAE), FMM-Head increased latency by +168% due to unoptimized trigonometric operations in TensorFlow.

Summary updated

BibTeX
@inproceedings{verardo2024fmm,
  author = {Giacomo Verardo and Magnus Boman and Samuel Bruchfeld and Marco Chiesa and Sabine Koch and Dejan Kostic and Gerald Q. Maguire Jr.},
  title = {{FMM-Head: Enhancing Autoencoder-based ECG anomaly detection with prior knowledge}},
  booktitle = {Icprai},
  year = {2024},
  doi = {10.1007/978-981-97-8702-9\_2},
}
Figure