Abstract
12-lead ECGs form an essential part of the late follow-up of adults with congenital heart disease (ACHD). Such ECGs are most frequently reviewed by clinicians in paper or PDF formats. These visual representations of the original vector data do not easily lend themselves to be directly analysed with the increasingly powerful Machine Learning algorithms that hold promise in risk prediction and early prevention of adverse events. In this work, we set out to recreate the original digital signals from ECG PDF documents by a series of data processing steps, validate accuracy of the process, and demonstrate its potential utility in research. Using 4153 ECG PDF documents from 436 ACHD patients, we created a “pipeline” to successfully digitise the visually represented ECG vector datasets. We then proceed with the validation of the digitised ECG dataset using several features that are also calculated by the vendor, such as QRS duration, PR interval and ventricular rate, on all the patients. We confirmed a strong correlation with the vendor measured ECG parameters including PR interval ($R = 0.941, P < 0.05$), QRS duration ($R = 0.949, P < 0.05$) and ventricular rate ($R = 0.971, P < 0.05$). Further, using Support Vector Machine (SVM), a well-established Machine Learning (ML) model we demonstrate the ability of the digitised ECG dataset to accurately predict anatomic diagnosis in ACHD. Digitisation of PDF formatted ECG signal data can be accomplished with good accuracy and can be used in clinical research in ACHD.
Introduction
In modern cardiology, the 12-lead ECG is a cornerstone of patient monitoring. However, much of this data is effectively "trapped" in visual formats. While original machines capture high-frequency digital signals, hospitals often store these records as printed papers or PDF documents. For a clinician, a PDF is sufficient for visual inspection; however, for Machine Learning (ML) researchers, it presents a significant barrier.
Most existing digitisation tools treat PDFs as images (pixels), which leads to quality loss, especially when ECG leads overlap or text obscures the waveform. Furthermore, proprietary vendor software often makes it difficult to export the "raw" signal data needed for advanced risk prediction. This paper addresses the challenge of unlocking high-quality signal data from existing PDF archives to enable large-scale research in Adult Congenital Heart Disease (ACHD).
Methodology
The proposed approach utilizes a "stepwise pipeline" that treats the PDF not as a static image, but as a collection of geometric instructions. This allows for the extraction of high-fidelity digital signals by bypassing the resolution limits of pixel-based methods.
The Digitisation Pipeline
As detailed in Algorithm 1, the process involves several key stages:
- Vector Extraction: Using the
PyMuPDFlibrary, the algorithm extracts the exact coordinates of the vector drawings (the lines) within the PDF. This captures the signal with mathematical precision. - Signal Reconstruction: Extracted coordinates are converted back into millivolts (mV) and time (seconds) based on the scale indicators found in the document.
- Artifact Correction: The algorithm is designed to automatically handle common PDF "noise," such as overlapping leads (where a large QRS complex from one lead bleeds into the one below it) and baseline shifts.
- Peak Alignment: To prepare the data for ML, signals are standardized by aligning the R-peaks of the heartbeats, ensuring features are synchronized across all leads.
Dataset and Classification
The study utilized 4,153 ECG PDF documents from 436 ACHD patients at the NHS Golden Jubilee National Hospital. The dataset focused on five common conditions: Tetralogy of Fallot (ToF), Pulmonary Atresia (PA), Fontan procedures, Atrial Septal Defects (ASD), and Mustard procedures. As a proof of concept, a Support Vector Machine (SVM) with a Radial Basis Function (RBF) kernel was employed to predict anatomical diagnoses from the digitised signals.
Results and Discussion
Validation against Gold Standards
The digitised signals showed a near-perfect correlation with the original vendor-calculated metrics, confirming the fidelity of the extraction process:
- PR Interval: $R = 0.941$
- QRS Duration: $R = 0.949$
- Ventricular Rate: $R = 0.971$
Machine Learning Performance
The SVM model achieved impressive results in identifying specific anatomical conditions, demonstrating that the ECG acts as a structural fingerprint:
- ASD: 88% accuracy.
- Mustard Procedure: 76% accuracy.
- Tetralogy of Fallot: 74% accuracy.
The model struggled most with Fontan patients (34% accuracy), likely due to the massive anatomical variety inherent in single-ventricle physiology, which creates inconsistent electrical signatures.
Conclusion
This research demonstrates that medical PDFs often contain valuable vector data that can be extracted to maintain signal integrity. The algorithm proved superior to existing open-source tools at handling lead overlaps by understanding the "path" of the vector rather than just pixel intensity.
A primary limitation is that this method is restricted to vector-based PDFs; it cannot be applied to scanned-in paper records. Future work aims to automate file management and move beyond diagnosis to use these digitized "digital twins" for predicting mortality and major adverse cardiovascular events in larger patient cohorts.
Summary updated