Segment-Aware Hierarchical ECG Classification with Robust Automatic Delineation and Foundation Model Embeddings

Diogo Tuler Chaves1, Pedro Robles Dutenhefner2, Turi Vasconcelos Rezende2, JOAO MARCOS TOMAZ SILVA CAMPOS1, Rafael Martins Gomes2, Gabriela Paixão3, Gisele Pappa1, Tom Ribeiro2, Wagner Meira Jr2
1UFMG, 2Universidade Federal de Minas Gerais, 3Doctor


Abstract

Recent ECG foundation models provide transferable representations, but most downstream pipelines still compress the waveform into a global embedding and apply classifiers that ignore waveform structure and the clinical hierarchy of ECG abnormalities. We propose a segment-aware framework for hierarchical ECG classification that combines robust automatic delineation, pretrained ECG foundation model embeddings, and a lightweight hierarchy-aware classification head. The method is designed for large-scale 12-lead datasets without manual annotations and is evaluated on CODE-15, a cohort of 345,779 ECGs from 233,770 patients.

ECG delineation remains an open problem in real-world recordings due to noise, morphology variability, lead-dependent visibility of waveform components, and scarcity of large annotated corpora. To address this, we adopt a two-stage delineation pipeline that first localizes QRS complexes and then estimates P-wave, QRS, and T-wave boundaries, enabling scalable physiological decomposition without relying on manual segmentation. Each delineated segment is independently encoded by a pretrained ECG foundation model, preserving morphology-specific information before classification.

Instead of heavily adapting the full encoder, we learn only a lightweight hierarchy-aware classifier on top of the segment representations. This parameter-efficient design retains the generalization ability of the pretrained model while structuring predictions across broad diagnostic groups and fine-grained abnormalities. It also yields a clinically intelligible decision process: rather than producing diffuse saliency over the entire signal, the model decomposes diagnostic evidence across physiologically meaningful waveform components, making it possible to inspect whether a prediction is primarily supported by atrial activity, ventricular depolarization, or repolarization patterns.

On CODE-15, the proposed framework achieved performance comparable to a strong, well-established ResNet baseline previously reported for hierarchical ECG classification (macro-F1 0.760), while providing richer physiological explanations of how each diagnosis is supported. These findings suggest that robust automatic delineation, combined with foundation-model representations and lightweight hierarchical prediction, is a practical path toward scalable and interpretable ECG AI.