VinDigitizer: A Hybrid Approach to Digitize Paper-based ECG Records

Cuong V. Nguyen1, Hieu Xuan Nguyen2, Nhat Duong Anh3, Cuong Do1
1VinUniversity, 2Mr, 3Vin University


Abstract

The dominance of traditional paper-based ECG records in clinical settings poses a barrier to the integration of AI for cardiovascular disease detection. The shift towards digital ECG is imperative yet hindered by the lack of reliable digitization tools. In this work, we propose a hybrid digitization approach merging Deep Learning and image processing algorithms. Our methodology comprises three key phases: lead segmentation, signal extraction, and scale conversion. Initially, we employ perspective transformation on input ECG images, followed by a pre-trained YOLOv8 single-shot detector to capture snapshots of 12 ECG leads. Then, each snapshot undergoes Otsu's technique for RGB to binary conversion, Hough transform for grid detection, and Viterbi's algorithm for sampling and extracting signal values in pixels. Finally, we convert these pixel values to voltage values by estimating grid resolution within the snapshot. To address uneven lengths in the extracted lead signals, we use cubic spline interpolation to horizontally scale the signals to align with a predetermined target length while preserving their waveform. Subsequently, digitized ECG signals are used in the classification task. We introduce a novel approach leveraging the Matrix Profile Algorithm, integrating ECG morphological features into a multi-scale convolution. To enhance the classification's robustness and explainability when dealing with noisy and short-duration digitized ECG, a method called Virtual Sample Generation based on Gaussian Distribution and a channel-wise attention module are employed. Our preliminary attempt in the unofficial phase achieved Reconstruction SNR of -0.423 and Classification F-measure of 0.142. We observed that vertically shifting a digitized signal, even if its waveform is identical to that of the ground-truth signal, detrimentally affected the SNR result, thus it is critical to pinpoint an appropriate reference point on the paper ECG. We will focus on resolving this issue in the official phase, since our classification performance heavily relies on the digitization outcomes.