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

Giacomo Verardo, Magnus Boman, Samuel Bruchfeld, Marco Chiesa, Sabine Koch, Gerald Q. Maguire Jr., Dejan Kostic

TL;DR

FMM-Head is a novel neural network component that integrates domain-specific prior knowledge into Autoencoders for ECG anomaly detection. By replacing generic decoders with a physics-inspired reconstruction head, the authors achieved up to a 0.31 increase in AUROC while simultaneously halving model size and providing explainable features for real-time clinical monitoring.

What Problem Does This Paper Address?

Electrocardiogram (ECG) monitoring is a cornerstone of cardiovascular health, but the sheer volume of data from wearables and hospital monitors has created a processing bottleneck. While Deep Learning (DL) models like Autoencoders (AEs) are great at spotting anomalies, they suffer from two major flaws:

  1. Black-Box Nature: They offer no explanation for why a heartbeat is flagged as abnormal.
  2. Ignorance of Domain Knowledge: Standard AEs treat ECG signals as generic time-series data, ignoring the well-known physiological structure of the P, Q, R, S, and T waves.

Existing mathematical models, like the Frequency Modulated Möbius (FMM) model, can describe these waves beautifully but are computationally expensive, often taking seconds or minutes to solve an optimization problem for a single heartbeat—far too slow for real-time use.

Methods

The authors propose the FMM-Head, a specialized reconstruction layer that replaces the standard decoder in an AE architecture.

Figure 3: (a) Structure of standard AE and (b) AE with the FMM-Head decoder. The FMM-Head is usually smaller than the baseline decoders.

The Architecture

  • Encoder: Any standard architecture (Transformer, LSTM, CNN) that compresses the ECG signal into a latent space.
  • FMM-Head: A pooling layer followed by two fully connected layers. Instead of reconstructing the raw signal directly, this head predicts the parameters ($A, \alpha, \beta, \omega, M$) for five FMM waves that represent the P, Q, R, S, and T components.
  • Reconstruction: These predicted parameters are plugged into the FMM wave equations to synthesize the reconstructed ECG signal.

Training Strategy

The authors use a two-phase approach:

  1. Warm-up Regression: The network is first trained to match the parameters produced by traditional (but slow) FMM optimization. This "steers" the model toward physically meaningful patterns.
  2. Anomaly Detection Training: The model is then trained as a standard AE to minimize reconstruction error on "normal" data.

Datasets

The model was evaluated on three diverse datasets:

  • Shaoxing: A large dataset containing 12-lead ECGs from over 10,000 patients with various labeled rhythms and conditions.
  • PTB-XL: Currently the largest publicly available ECG dataset, featuring 21,837 clinical records.
  • ECG5000: A smaller dataset from a single patient, used primarily to test performance on simpler, less variable data.

Key Insights and Ideas

  • "Weak" Priors are Strong: You don't need a perfect model of every disease. Just knowing that a heartbeat consists of five specific waves (Figure 1) provides enough structure to significantly improve learning.
  • Neural Networks as Fast Optimizers: The FMM-Head essentially learns to approximate a complex optimization problem. It produces parameters 21,000 times faster than traditional iterative solvers, enabling real-time use.
  • Explainability by Design: Because the latent space maps to physical parameters (like wave amplitude or peak position), clinicians can see exactly which part of the heartbeat's structure is deviating from the norm.
  • Circular Variable Handling: The authors explicitly treat the phase parameters ($\alpha$ and $\beta$) as circular variables (using sine and cosine components), which is crucial for periodic signals like heartbeats.
Figure 1: (a) shows the ECG shape, while (b) shows the FMM decomposition of an ECG wave

Key Results

  • Performance Boost: The FMM-Head consistently outperformed baseline models. The most dramatic improvement was seen in LSTM-based models, with an AUROC increase of 0.31.
  • Efficiency: For non-LSTM models, the FMM-Head reduced model size by nearly 50% (and up to 93% for Transformer-based models).
  • Speed: Inference time was reduced by up to 91% compared to baseline decoders.
  • High Fidelity: Despite being optimized for anomaly detection, the parameters extracted by the FMM-Head remained highly correlated with those from the "gold standard" mathematical optimization.
Figure 2: Anomaly detection improvement for a transformer model (0.16) and a Long-short term memory (LSTM)-based model (0.31) when augmented by FMM-Head.

Limitations and Future Work

  • Single-Lead Limitation: The current implementation only handles a single ECG lead (Lead II). Real-world clinical diagnostics often require all 12 leads.
  • Warm-up Dependency: The performance gains are heavily dependent on the initial warm-up regression phase. Without it, the model can struggle to find meaningful wave patterns on complex datasets.
  • Future Directions: The authors plan to extend the model to 12-lead data and further optimize the code for parallel operations in TensorFlow to drive inference times even lower.

Summary updated

BibTeX
@inproceedings{verardo2024fmm,
  author = {Giacomo Verardo and Magnus Boman and Samuel Bruchfeld and Marco Chiesa and Sabine Koch and Gerald Q. Maguire Jr. and Dejan Kostic},
  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