TL;DR
This paper presents a novel, automated method for extracting usable ECG signal data from PDF documents, a common but challenging format. This approach overcomes limitations of existing methods by directly processing vectorized graphics, enabling accurate signal reconstruction and paving the way for large-scale machine learning applications in adult congenital heart disease (ACHD) research.
What Problem Does This Paper Address?
Adult congenital heart disease (ACHD) patients require lifelong monitoring, with 12-lead electrocardiograms (ECGs) being a crucial diagnostic tool. However, these ECGs are often stored and reviewed as static PDF documents, which are visually represented and not easily amenable to direct analysis by powerful machine learning (ML) algorithms. Existing ML approaches for ECG analysis often struggle with the lack of large, standardized, and accessible datasets. While some methods exist for digitizing ECGs, they typically treat them as images, leading to quality loss and requiring manual intervention. This paper addresses the critical need for a robust, automated method to convert these PDF-based ECGs into a format suitable for advanced ML analysis, thereby unlocking their potential for risk prediction and early prevention of adverse events in ACHD.
Methods
The authors developed a novel, automated "pipeline" to digitize ECG signals from PDF documents. This process involves:
- Vectorized Graphics Extraction: Unlike image-based approaches, their method leverages open-source Python libraries (specifically PyMuPDF) to extract vectorized graphical information directly from the PDF. This allows for the reconstruction of the ECG signal with higher fidelity.
- ECG Lead and Scale Identification: The algorithm automatically locates the 12 ECG leads on the PDF page and identifies the scale indicator to determine timing and amplitude intervals.
- Signal Reconstruction and Alignment: Extracted line points are used to digitize each lead. The digitized signals are then scaled to mV and synchronized by aligning the R-wave peaks, ensuring that QRS complexes are precisely aligned across all leads. This alignment is crucial for subsequent ML analysis.
- Validation: The accuracy of the digitized signals was validated by comparing key ECG parameters (PR interval, QRS duration, ventricular rate) calculated from the digitized data against those provided by the vendor's analysis software.
- ML Model Application: A Support Vector Machine (SVM) model was employed to demonstrate the utility of the digitized dataset for predicting anatomic diagnoses in ACHD.
Datasets
The study utilized a dataset of 4153 ECG PDF documents from 436 patients with adult congenital heart disease (ACHD). These patients were selected based on the 5 most prevalent congenital heart diagnoses in their practice: Tetralogy of Fallot (ToF), Atrial Septal Defect (ASD), Pulmonary Atresia (PA), Fontan procedure, and Mustard procedure. The data was linked to electronic health records (EHR) for demographic information and diagnoses.
Key Insights and Ideas
- Direct Vector Graphics Processing is Key: The core innovation lies in moving beyond treating ECG PDFs as mere images. By directly processing the underlying vector graphics, the authors achieve a more accurate and robust signal reconstruction, overcoming common artefacts.
- Automation Reduces Barriers: The automated nature of the pipeline significantly reduces the manual effort typically required for ECG digitization, making large-scale research more feasible.
- Alignment is Crucial for ML: Synchronizing ECG leads by aligning R-wave peaks is demonstrated to be critical for improving the performance of ML models in classification tasks.
- PDFs as a Rich Data Source: This work highlights that even seemingly static PDF documents can serve as a valuable source of raw signal data for advanced computational analysis, provided the right extraction methods are used.
Key Results
- High Correlation with Vendor Data: The digitized ECG parameters showed a strong correlation with vendor-measured values:
- PR interval: R = 0.941, P < 0.05
- QRS duration: R = 0.949, P < 0.05
- Ventricular rate: R = 0.971, P < 0.05
- Accurate Diagnosis Prediction: The SVM model, trained on the digitized ECG data, demonstrated the ability to accurately predict anatomic diagnoses in ACHD. For example, it achieved an AUC of 0.946 for ASD and 0.959 for Mustard procedures.
- Artefact Correction: The algorithm successfully corrected common artefacts found in PDF ECGs, such as overlapping QRS complexes, baseline drift, and text overlaying signals.
- Classification Performance: The study reported classification metrics (precision, sensitivity, specificity, F1 score) for the different diagnostic groups, with ASD showing the highest accuracy (88% in the confusion matrix).
Limitations and Future Work
- Manual Data Input: The current process still requires manual deposition of ECG PDF documents into an analysis folder, which could be further automated.
- Limited Dataset Size: While 4153 ECGs is a substantial dataset, the authors acknowledge that a larger cohort would be beneficial for more robust ML training, especially for rarer conditions or more complex physiologies.
- Vectorized Format Dependency: The method is optimized for PDFs that encode ECG waveforms in a vectorized format. It may not perform as well on ECGs digitized as pixelated images.
- Future Directions: The authors propose using this digitized ECG data for risk stratification of mortality, cardiovascular hospitalizations, and cardiovascular worsening in larger patient cohorts. They also suggest exploring deep learning models for improved classification performance.
Summary updated