Diffusion Models and Masked Training Helps Digitization and Classification of Multiple Layout ECG Images

Zhi‐Shan Liang, S Zhang, 可鑫 王, D.s. Zhang, Shijia Geng, Jun Li, Qiong Zhao, Yuxi Zhou, Shenda HongComputing 2024

Abstract

Recent advancements have led to the development of algorithms for interpreting ECG time series. However, the continued prevalence of ECG images highlights the urgent need for digitization and affordable data analysis. This is essential to ensure comprehensive cardiac care and to capture the diverse manifestations of cardiovascular diseases worldwide. As part of the George B. Moody PhysioNet Challenge 2024, our goal is to propose a series of pragmatic components for the digitization and classification of ECG images. First, we generate training samples with the ECG-Image-Kit and refine them using diffusion models for data augmentation. Then, we employ a U-net architecture to perform ECG digitization, utilizing this large scale ECG images paired with their corresponding ground-truth time series. Next, we pre-train a RegNet model for ECG classification using a large scale ECG time series data from open-source datasets. This pre-trained classifier is then further fine-tuned with the digitized ECG time series derived from ECG images. Additionally, we devise an adaptable meta-model and a masked training strategy to address issues related to varying lengths and asynchronization when digitizing diverse ECG image layouts. Our team, PKU NIHDS, reported a SNR of -1.103 on the reconstruction task and an F-measure of 0.421 on the classification task for the hidden test set.

Introduction

While modern cardiology relies on digital signals, billions of historical and active electrocardiograms (ECGs) exist only as printed paper or scanned images. To apply state-of-the-art deep learning for diagnosis, these images must first be "digitized"—converted back into accurate time-series data. This process is complicated by the wide variety of ECG layouts (e.g., 12x1 vs. 3x4 grids), paper quality, and physical conditions such as folds, stains, or poor lighting. This paper addresses these challenges by proposing a robust pipeline for digitization and classification as part of the 2024 George B. Moody PhysioNet Challenge.

Proposed Framework

The authors developed a multi-stage framework designed to bridge the gap between physical paper and digital analysis.

The proposed pipeline for ECG digitization and classification, featuring the ECG-Image-Kit, UNet segmentation, and a Meta Model for layout prediction.

1. Diffusion-Enhanced Data Synthesis

To train the models, a massive dataset of "dirty" ECG images paired with "clean" digital ground truths was required. The team used the ECG-Image-Kit to generate basic synthetic images and then applied Diffusion Models to add realistic textures, such as wrinkles, stains, and natural scene backgrounds. This approach demonstrated that purely synthetic data can be sufficient for training digitization tasks if it contains enough variety.

2. Digitization and Meta-Modeling

A UNet architecture was employed to segment ECG leads from the background. A specialized digitization module then converted pixel coordinates into voltage-over-time signals. Simultaneously, a Meta-Model was trained to predict image metadata, including sampling frequency, layout type, and overall quality. This allows the system to adapt its parameters to specific image characteristics rather than using a fixed approach.

3. Classification with Masked Training

For cardiovascular disease diagnosis, a RegNet model was pre-trained on large-scale time-series data (like PTB-XL) and fine-tuned on digitized signals. To handle varying signal lengths and asynchronization across different layouts, the team implemented a masked training strategy, randomly hiding parts of the signal to ensure the model remains robust to incomplete data.

Results and Discussion

The PKU_NIHDS team evaluated their system on the official PhysioNet Challenge hidden test set. The meta-model proved exceptionally accurate, achieving 1.000 accuracy for layout prediction and 0.995 for sampling frequency.

Comparison of F1 scores across different classification strategies, highlighting the superior performance of using background-removed images.

As shown in the results, the use of background-removed images significantly improved classification performance compared to end-to-end image processing. On the hidden test set, the team achieved an F-measure of 0.421 and a Signal-to-Noise Ratio (SNR) of -1.103. While local test results were higher (SNR of 4.031), the performance on the hidden set underscores the difficulty of generalizing to unseen real-world artifacts.

Conclusion

This work highlights the potential of diffusion-based augmentation and masked training for processing "in-the-wild" ECG images. Future research will focus on narrowing the gap between synthetic and real-world data through more advanced diffusion techniques and cascaded processing to better handle the complex domain shifts found in clinical environments.

Summary updated

BibTeX
@inproceedings{liang2024diffusion,
  author = {Zhi‐Shan Liang and S Zhang and 可鑫 王 and D.S. Zhang and Shijia Geng and Jun Li and Qiong Zhao and Yuxi Zhou and Shenda Hong},
  title = {{Diffusion Models and Masked Training Helps Digitization and Classification of Multiple Layout ECG Images}},
  booktitle = {Computing},
  year = {2024},
  doi = {10.22489/cinc.2024.326},
}
Figure