When the 2024 topic was announced, I was already studying ECG image classification during my PhD at the University of São Paulo and InCor. Many hospital ECGs were stored as images, while most models expected time-series signals. That mismatch was central to my research.
I led AIMED in the challenge. We used what I had already tested during my PhD to choose the training strategy. The organizers then evaluated our code on unseen data. We finished first in classification.
Award presentation at Computing in Cardiology 2024 in Karlsruhe, Germany. From left to right: Matthew Reyna, Felipe Dias, Marco Antônio Gutierrez and Gari Clifford. Photo: SBIS.
What is the PhysioNet Challenge?
The PhysioNet Challenge is an annual research competition organized by PhysioNet and Computing in Cardiology since 2000. Each year, teams work on the same clinical or physiological problem. The organizers provide the data and evaluation rules, test the algorithms and make the code available so other researchers can study and reproduce the methods.
The 2024 problem: ECGs on paper
The 2024 topic was Digitization and Classification of ECG Images. There were two tasks, with separate awards. Teams could enter either task or both:
Digitization
Reconstruct the lead time series from an image of the ECG.
Classification
Identify ECG categories from the image, either directly or using reconstructed signals.
Teams submitted their code, and the organizers ran the training and evaluation. Each team selected a final version for testing on hidden data. We focused on classifying the images directly.
Why we chose to classify the image
Digitizing an ECG means recovering the signal from the image. It involves separating each lead from the grid, recovering the time and amplitude scales, and dealing with overlapping traces, shadows, perspective and noise. Errors can carry through to the classifier that uses the reconstructed signal.
I had already tested CNNs for ECG image classification, so we decided to focus on that task. The model analyzes the image directly, without first reconstructing the signal.
Doctoral experiments
During my PhD, I used synthetic images generated from public ECG signals and real ECGs from InCor's outpatient and emergency departments. I compared ConvNeXt, EfficientNet-B3, ResNet50, ViT and Swin Transformer, and tested different ways to train them.
I tested data augmentation and different image resolutions.
I compared ImageNet initialization, ECG pretraining and the combination of both.
I tested adding age and sex, and using a loss function that combined BCE and MCC.
I ran ablation studies to assess individual choices, and tested the models on photographed and scanned ECGs.
Our challenge entry built on some of these experiments. The training strategy we submitted is outlined below.
Pretraining
We started with ImageNet weights, but ECGs look very different from the photographs in that dataset. Before fine-tuning for the challenge, we trained the network on synthetic and real ECG images.
In my thesis, I also tested random initialization followed by ECG-only pretraining. Macro F1 was lower than with ImageNet initialization. Combining ImageNet initialization with ECG pretraining gave the best result among the three configurations below. We used that combination in the competition.
Our paper, Image-Based Electrocardiogram Classification Using Pre-trained ConvNext, describes the training strategy we used in the challenge:
AIMED’s final method, reproduced from Figure 1 of the CinC 2024 paper.
ImageNet
We started with a ConvNeXt pretrained on general images.
CODE15 and InCor-AMB
We adapted the network to synthetic images generated with ECG-Image-Kit and real outpatient ECGs.
InCor-EMG
We performed an additional fine-tuning stage on emergency ECG images.
PTB-XL
We fine-tuned for the 11 challenge categories using 5-fold cross-validation and combined the five models into an ensemble.
We used grayscale images at 224 × 224 resolution for pretraining and 384 × 384 for final fine-tuning. Training included data augmentation, AdamW, class-weighted BCE and early stopping. The 11 categories covered normal ECGs, infarction, ST/T changes, conduction disturbances and arrhythmias.
We left CINC21 out of pretraining because it contains PTB-XL. We also reduced cross-validation from 10 to 5 folds to stay within the challenge computing limits.
Code and models
I reorganized the AIMED code into a public repository with tutorials for installation, inference and training, plus a manifest of the weights and inference configuration.
AIMED finished first among the 16 official classification entries, with a macro F1 of 0.817. These were the top three results published by the organizers:
The ranking was based on color and black-and-white scans of paper ECGs. The extended evaluation also tested phone photos, stained or damaged paper and monitor screenshots. Our average score across the eight scenarios was 0.733. Scores were lower on photographs.
First-place classification certificate, team AIMED. Karlsruhe, September 11, 2024.
Team
I led AIMED and was the paper's first author. The team included Estela Ribeiro, Quenaz B. Soares, José E. Krieger and Marco A. Gutierrez at InCor's Biomedical Informatics Laboratory. Foxconn Brazil and the Zerbini Foundation supported the work.