Skip to main content
Scientific Reports logoLink to Scientific Reports
. 2025 Dec 1;16:183. doi: 10.1038/s41598-025-29181-1

Learning to compress electrocardiogram signals on a quick response code

Apoorva Srivastava 1,✉,#, Dipayan Dewan 1,#, Amit Patra 1, Debdoot Sheet 1,
PMCID: PMC12764787  PMID: 41326550

Abstract

The electrocardiogram (ECG) is a widely acknowledged clinical tool for diagnosis of cardiovascular diseases (CVDs). In low and middle income countries (LMICs), the lack of connected health (CH) systems often results in ECG data being shared via paper records, risking privacy breaches. One potential solution is embedding ECG data within a quick response (QR) code, enabling secure transmission of clinically essential information while preserving patient privacy. In this paper, we propose a learning-based compression method that preserves essential clinical information which is further encoded losslessly using the Brotli algorithm for QR code embedding. We have experimentally validated our approach on publicly available dataset containing ECG recordings from healthy individuals and with 26 distinct CVD pathologies. Key performance is assessed using Percentage Root-Mean-Square Difference (PRD), Structural Similarity Index (SSIM), and Compression Factor (CF) along with morphological features comparisons between original and decompressed lead-II ECG signals. At CF of 82.37, we have attained PRD of 2.70%, SSIM of 0.94 for lead-II ECG signal, and PRD of 2.80%, SSIM of 0.94 for lead-I ECG signal. Our method outperforms state-of-the-art approaches, enabling secure, efficient, and scalable ECG integration into CH systems for continuous monitoring and early detection of CVDs.

Subject terms: Biomedical engineering, Cardiovascular diseases

Introduction

Cardiovascular diseases (CVDs) are responsible for about 32% (18.5 million deaths) of all deaths worldwide1. Clinical evidence indicates that arrhythmia is a key contributor of CVDs. Cardiovascular conditions are of paramount importance in low- and middle-income countries (LMICs) due to high mortality rates and costly care2. Electrocardiography (ECG) is a non-invasive and low-cost technique to diagnose structural abnormality of the heart, as well as other cardiac pathologies viz. coronary blockage, myocardial infarction, etc.3. Moreover, recent research is focused on improving the recording of ECG signals using contactless methods4,5. However, these studies have largely overlooked secure transmission and storage considerations. It is imperative to continuously monitor, store, and subsequently transfer ECG signals to specialized practitioners for subsequent analysis in smart healthcare6. Prior studies have indicated that integrating ECG into connected health (CH) systems enables continuous cardiac monitoring, utilizing digital technologies like wearable devices, EHRs, mobile apps, and telemedicine for efficient, accessible care2,7.

In hospital settings of LMICs, ECG recordings are often printed for use and later digitized through scanning or photography. Moreover, paper-based ECG records present potential risks of breach in patient confidentiality, being highly vulnerable to unauthorized access. Additionally, the accessibility of medical information during handover communication between healthcare providers and patients may compromise the patient’s privacy8.

Embedding ECG signal data in Quick Response (QR) codes offers a method to seamlessly integrate ECG information into smart healthcare systems, enhancing connectivity and health monitoring while significantly reducing data storage requirements and ensuring the preservation of data privacy. The utilization of QR codes is experiencing a notable surge, particularly in the context of secure and privacy preserving data dissemination with physical tokens, including authentication and verification, etc.9,10. Notably, QR codes present themselves as a convenient tool for mobile phone users, allowing individuals to capture the code effortlessly via their smartphone camera and subsequently decode it utilizing smartphone applications. The heightened adoption of QR codes can be attributed to their significant data capacity, error-correction functionality, rapid decoding capabilities, and other advantageous features11. However, the maximum capacity of the highest version of QR-Code, which is version 40 with ’L’ error-correction capacity, is limited to accommodating 4296 alphanumeric characters, 7089 numeric data, 2953 binary data, and 1817 kanji data. This limitation poses challenges in storing information of a single lead ECG comprising negative and floating values within a QR code.

This paper aims to address these challenges by proposing a learning-based approach for embedding ECG signal in QR code. Figure 1 illustrates the overview of the approach. Aiming to achieve the ability to develop a clinically acceptable compression mechanism for ECG signals, we have implemented the two-stage compression. In the First stage we define the architecture of Inline graphic, which is trained to achieve the desired compression factor. Further, in Second stage the signal compression engine is implemented consisting of (i) a compressor made up of, (a) the DNN compressor obtained in First stage, followed by, (b) a lossless compressor block, (c) a Base-64 encoder, and (ii) a decompressor made up of, (i) Base-64 decoder, (ii) lossless decompressor block, and (iii) DNN decompressor obtained in First stage.

Fig. 1.

Fig. 1

Overall pipeline for embedding ECG signal to QR-code is shown here. Let Inline graphic show the ECG signal which passes through the signal compression engine to compress the signal to the QR code. The QR code enables efficient transmission and scanning to retrieve compressed bits, which are decoded by a signal decompression engine to reconstruct Inline graphic.

Related work

The first stage to accommodate the information of the ECG signal in the QR code is signal compression. The ECG compression algorithms can be categorized based on (1) input type encompassing ECG as 1-D signal and 2-D images, and (2) algorithm approach spanning from conventional methods to deep learning approaches.

The 1-D ECG signal is traditionally compressed using methods such as template matching, linear prediction models, entropy coding, and redundancy reduction, which rely on expert knowledge for accurate QRS complex demarcation. While these approaches achieve higher compression ratios, the reconstructed signals often fail to meet cardiological standards1214.

The 1-D ECG signal is transformed into 2-D representations via techniques like 2-D DCT, DWT, and Stockwell transform enables the application of 2-D compression methods such as JPEG2000, differential coding, and run-length coding, yielding improved compression efficiency but at the cost of increased computational and spatial complexity1520. Mathivanan et al. in21,22 converted beat-wise 1-D ECG signals to 2-D images, applied DWT, and embedded high-frequency sub-band coefficients into QR codes. However, the user-defined thresholds compromise signal quality, limiting its utility for automated ECG encoding. The utilization of deep neural network-based automated and adaptive learning processes contributes to better signal compression.

Kannan et al.23 used a fully connected neural network (NN) with Huffman encoding to compress 1-D ECG signals, but the floating-point hidden layer outputs increased dictionary size, complicating QR code encoding. Zhang et al.24 combined wavelet transform with NNs for higher compression ratios to compress ECG beat-wise signal, while Yildirim et al.25 employed a 27-layer CNN autoencoder to compress ECG signals lasting 5.5 s, though decompressed signals lost morphological features. In26, a total of 1000 samples were embedded into a QR code, undergoing quantization through modulus division, resulting in information loss. Furthermore, in another study11, the author proposed generating 17 QR codes to store 6 s of ECG signals from a single subject subsequent to quantization. Encoding hidden layer information in floating-point format values within a QR code presents considerable challenges.

Exposition to the solution

We propose to develop a deep learning-based model followed by lossless compression technique that can compress single lead ECG signals enabling their encryption into QR-Code format. The model is trained and tested on a dataset with signals from subjects who exhibit upto 26 multi-labeled disease classes, and also contain normal sinus rhythm subjects. The optimized compressor model compresses the ECG signal, enabling it to be represented in a QR code, and the optimized decompressor enables the retrieval of the ECG signal. The workflow pipeline is illustrated in Fig. 2.

Fig. 2.

Fig. 2

Overall pipeline for compressing ECG signal to QR code is shown here. The model is trained on Inline graphic8 s of ECG signal from two independent datasets used in this study. After training, the optimized deep learning model (Inline graphic) is evaluated on an unseen independent dataset. The optimised compressor Inline graphic convert the signal to a floating-point-represented tensor. The Inline graphic further compress the tensor using the lossless compressor to provide compressed bits. Inline graphic facilitates the encoding of compressed bits into a string representation suitable for QR code generation. Upon scanning the QR code the strings are retrieved and passed through Inline graphic to obtain the compressed bit. These compressed bits pass through lossless decoder Inline graphic to obtain compressed tensor. The reconstructed ECG signal is obtained by passing the tensor to optimised Inline graphic, which is evaluated by quantitative analysis.

Methodology

Formal definition

Let us denote the Inline graphic digital floating-point sample of the Inline graphic ECG lead as Inline graphic. When the ECG signal is acquired at sampling frequency of 500 Hz and for a duration of 8 s, then the total number of samples is Inline graphic, such that Inline graphic. The B sequence long, Inline graphic lead for Inline graphic subject can be denoted as Inline graphic. Given that we have a dataset with N number of subjects with Inline graphic lead available it can be denoted as, Inline graphic.

Our goal is to develop a non-linear function F : Inline graphic , where Inline graphic. Here the ECG data Inline graphic is compressed to Inline graphic such that it contains the essential information which can be used to reconstruct the ECG data represented as Inline graphic. It is expected that on training of the DNN and passing through lossless compressor and decompressor we would obtain Inline graphic, where Inline graphic.

We have implemented the two-stage compression. In the first stage, we train the proposed DNN model to achieve the compressed tensor for a given 1-D ECG signal. The compressed tensor is achieved by,

graphic file with name d33e451.gif 1
graphic file with name d33e455.gif 2

Inline graphic and Inline graphic are the DNN which are together denoted as Inline graphic. Inline graphic shows the output tensor of Inline graphic. Inline graphic denote the output tensor of Inline graphic, and input tensor of Inline graphic. Once the compressed tensor is achieved, it is combined with the Second stage process to obtain Inline graphic by,

graphic file with name d33e500.gif 3
graphic file with name d33e504.gif 4
graphic file with name d33e508.gif 5
graphic file with name d33e512.gif 6
graphic file with name d33e516.gif 7
graphic file with name d33e520.gif 8

where, the Inline graphic sample of Inline graphic lead in Inline graphic is denoted as Inline graphic. The Inline graphic and Inline graphic are lossless compression and decompression techniques respectively. Inline graphic is the bit stream obtained after passing the output of Inline graphic through Base-64 coder denoted as Inline graphic. The Inline graphic is the input to Inline graphic, obtained by passing the bit stream through Inline graphic followed by Inline graphic.

Architecure

The proposed Inline graphic is a encoder-decoder based architecture and can be defined as:

graphic file with name d33e587.gif 9

where, Inline graphic is the compressor and Inline graphic is the decompressor unit.

Given a input of Inline graphic, the output of the Inline graphic is defined as:

graphic file with name d33e610.gif 10

The reconstructed signal Inline graphic is then produced by giving Inline graphic to the Inline graphic and can be defined as:

graphic file with name d33e628.gif 11

Inline graphic has multiple Inline graphic blocks which are made of three components: Inline graphic, Inline graphic, and Inline graphic.

graphic file with name d33e653.gif 12
graphic file with name d33e658.gif 13

here, Inline graphic represents the layer index, starting from Inline graphic. Each subsequent layer output denoted by Inline graphicis obtained by applying Eq. (13) to the previous layer’s feature map Inline graphic. Let Inline graphic, Inline graphic shows the Inline graphic element of Inline graphic and L shows total elements in Inline graphic which is the depth of the Inline graphic. The initial feature map Inline graphic, and Inline graphic can be obtained by following equations:

graphic file with name d33e719.gif 14
graphic file with name d33e723.gif 15

The Eq. (14) serves as the base case, where the raw signal is transformed into the first-level feature map. The process continues recursively Eq. (15) until the final output (Inline graphic) is reached. The Inline graphic defined in Eq. (13), and (14) can be represented as:

graphic file with name d33e750.gif 16
graphic file with name d33e754.gif 17

The Eq. (16) follows a standard pattern of applying two convolutional layers with ReLU activation and batch normalization. The downsampling operation is defined as follows:

graphic file with name d33e763.gif 18
graphic file with name d33e767.gif 19

here, Eq. (19) describes the Dilated Attention Module (DAM), which combines the feature projection Inline graphic with the attention mask (Inline graphic). The Inline graphic can be described as:

graphic file with name d33e788.gif 20

The attention mask block (Inline graphic) has multiple dilated convolution (Inline graphic), Downsampling (Inline graphic), Upsampling (Inline graphic), and skip connection (Inline graphic). For a given input Inline graphic, output of Inline graphic can be represented as:

graphic file with name d33e823.gif 21

where Inline graphic is defined as,

graphic file with name d33e832.gif 22

In Eq. (22), for Inline graphic become Inline graphic, which is same as Inline graphic.

graphic file with name d33e853.gif 23

The variables Inline graphic in Eq. (23) represent intermediate feature outputs that will be concatenated (or added) back at later stages. Next, we define Inline graphic, Inline graphic, Inline graphic, and Inline graphic used in Eq. (22).

graphic file with name d33e886.gif 24
graphic file with name d33e890.gif 25
graphic file with name d33e894.gif 26
graphic file with name d33e898.gif 27

The Inline graphic consists of Inline graphic. The details of the architecture of these blocks are given below:

graphic file with name d33e912.gif 28
graphic file with name d33e916.gif 29
graphic file with name d33e920.gif 30
graphic file with name d33e924.gif 31

Similar to compressor, Inline graphic represents the layer index, starting from Inline graphic. Each subsequent layer output denoted by Inline graphicis obtained by applying Eq. (30) to the previous layer’s feature map Inline graphic. similar to the Inline graphic we define Inline graphic.

Data preperation

The raw ECG signal undergoes the following preprocessing steps such that model is trained on inherent patterns of properly captured ECG signals. Let the raw ECG signal for Inline graphic subject with B samples is denoted as Inline graphic.

  • Step 1: A morphological-based signal quality assessment27 Inline graphic evaluates raw ECG signals and selects those of acceptable quality.
    graphic file with name d33e988.gif 32
  • Step 2: The good-quality signals undergo a 3rd-order Butterworth high-pass filter (0.5 Hz cut-off) for baseline correction and a notch filter (50 Hz) to remove power-line interference28, denoted as Inline graphic.
    graphic file with name d33e1003.gif 33
  • Step 3: The filtered signals are resampled to a consistent 250 Hz frequency, denoted as Inline graphic,
    graphic file with name d33e1014.gif 34
  • Step 4: The resampled signal is normalized to standardize amplitude variations, focusing the model on key ECG morphological features.
    graphic file with name d33e1021.gif 35
    where, Inline graphic shows the Inline graphic lead of Inline graphic subject after the signal is passed through steps 1-3. Following step 4 all leads signal with B samples gives us the final Inline graphic which is used as input for Inline graphic. In this study, Inline graphic, which results in a signal of 8.192 seconds with a sampling frequency of 250 Hz.

Training of neural compressor and decompressor

Figure 3 shows the overall pipeline for the training phase. At this stage, the Inline graphic takes single lead ECG signal Inline graphic and generates a tensor Inline graphic using Eqs. (1) and (2). The loss at this stage is,

graphic file with name d33e1081.gif 36

where Inline graphic is evaluated using structural similarity index measure (SSIM) loss29.

Fig. 3.

Fig. 3

Overview of the proposed method: We first train the convolution neural network base Inline graphic on a single lead ECG signal (Inline graphic). After training the compressed representation of the signal (Inline graphic) is passed through Inline graphic which is an encoder of lossless coding (LLC) for further compression. The compressed bits are represented in a QR code after passing through the Base-64 encoder (Inline graphic) and using QR code generator. The decompressed signal is obtained by first decrypting the QR code to obtain the decrypted bits. The bits are passed through Base-4 decoder (Inline graphic) followed by LLC decoder (Inline graphic) which is fed to Inline graphic to obtain the decompressed signal (Inline graphic).

Final stage

Compression: During deployment, given a single lead ECG signal Inline graphic, we obtain a lossy compressed tensor as Inline graphic, using Eq. (3). The QR code from the compressed tensor Inline graphic is achieved by following the steps described below.

  • Step 1: The compressed tensor is further compressed using a Brotli compression algorithm. This is achieved by Eq. (4), where Inline graphic is Brotli compressor30 which gives an output as Inline graphic where Inline graphic is compressed bitstream.

  • Step 2: The compressed bits are encoded using Base-64 encoder. This is achieved by Eq. (5), where Inline graphic shows Base-64 encoder which gives an output as Inline graphic. Here, Inline graphic and l shows the length of string. Inline graphic is passed through QR code generator to generate the QR code.

Decompression: The QR code decryptor, extracts the decompressed bit (Inline graphic) from QR code. ECG signal is reconstructed from the QR code by following the steps described below.

  • Step 1: The decompressed Inline graphic obtained from the QR code is passed through Base-64 decoder denoted as Inline graphic using Eq. (6) to obtain compressed bitstream Inline graphic.

  • Step 2: The compressed tensors are obtained by using Eq. (7). Here, the retrieved compressed bits are passed through Brotli decompressor to obtain decompressed tensor denoted as Inline graphic. Unlike Huffman Encoding31, Brotli features a static dictionary that requires no encoding within each compressed bit stream for individual subjects30. Also, it is embedded in Brotli’s decompressor, aiding in the recovery of compressed bits.

  • Step 3: The ECG signals are reconstructed by passing Inline graphic through Inline graphic using Eq. (8) to obtain Inline graphic. The procedural sequence to reconstruct the ECG signal from the decompressed bit stream can be represented as,
    graphic file with name d33e1277.gif 37

Inference manifest

During inference, the raw single lead ECG signal of a subject denoted as Inline graphic is pre-processed using Eqs. (32)–(35) defined as,

graphic file with name d33e1296.gif 38

where Inline graphic is send as an input to the trained Inline graphic defined in Eqs. (3)–(5) to give the compressed bit denoted as Inline graphic.

graphic file with name d33e1320.gif 39

The Inline graphic is sent to the QR code generator to generate a 2-dimensional QR-code denoted as (Inline graphic) and transmitted to the clinicians or stored. Aiming to retrieve back the signal, the QR code is scanned to get the bitstream denoted as Inline graphic which is passed through Inline graphic defined in Eqs. (6)–(8) to give Inline graphic.

graphic file with name d33e1353.gif 40

Experimental evaluation

Dataset description

The ECG signals considered for this work are taken from a publicly available dataset for ’Will two do? Varying dimension in electrocardiography’ 2021 challenge32,33. The dataset comprises subjects from disparate demography (China, Georgia, and Germany). Figure 4 shows the circos plot of the data distribution of ECG data collected from China, Georgia, and Germany. In this work, in total 88,179 ECG recordings are considered which include 26 multi-labeled disease and sinus rhythm (NSR) subjects. These 26 diseases are atrial fibrillation (AF), atrial flutter (AFL), bundle branch block (BBB), bradycardia (Brady), 1st-degree AV block (IAVB), incomplete right bundle branch block (IRBBB), left axis deviation (LAD), left anterior fascicular block (LAnFB), left bundle branch block (LBBB), low QRS voltages (LQRSV), nonspecific intraventricular conduction disorder (NSIVCD), pacing rhythm (PR), premature atrial contraction (PAC), poor R wave Progression (PRWP), prolonged PR interval (LPR), prolonged QT interval (LQT), Q-wave abnormal (QAb), right axis deviation (RAD), right bundle branch block (RBBB), sinus arrhythmia (SA), sinus bradycardia (SB), sinus tachycardia (STach), T wave abnormal (TAb), T wave inversion (TInv) and ventricular premature beats (VPB). The ECG recordings range from 10 s to 30 min with a varying sampling frequency of 500–1000 Hz based on the medical device settings.

Fig. 4.

Fig. 4

Circos plot depicting the data distribution of ECG signals collected from (a) China, (b) Georgia, and (c) Germany. The colored arcs and connecting lines represent the co-occurrence relationships among different cardiac arrhythmia.

Train and test split

The combined ECG data of China and Georgia is denoted as Inline graphic. However, subjects from Germany display a distinct data distribution, hence serving as a hidden held-out test dataset denoted as Inline graphic.

The ECG data in Inline graphic, with T number of subjects is split into two sets: training set (Inline graphic) and testing (Inline graphic). The Inline graphic and Inline graphic, consist of Inline graphic and Inline graphic number of subjects respectively, and Inline graphic. Aiming to maintain the data distribution in Inline graphic and Inline graphic similar to Inline graphic, the following steps are executed. The sample from Inline graphic is selected using uniform distribution. The selected data point from Inline graphic to be included in set Inline graphic and Inline graphic is determined using the Bernoulli’s distribution with the probabilities of 0.7 and 0.3, respectively. The circos plot of the train and validation set is shown in Figure 5a,b respectively. Notably, the distribution of the train and validation set closely mirrors the data distribution observed in the ECG data acquired from China and Georgia.

Fig. 5.

Fig. 5

Circos plot illustrating the data distribution of the (a) training set and (b) validation set, formed from the combined ECG datasets acquired from China and Georgia.

Training details

The Inline graphic is implemented and trained on a server equipped with 2Inline graphicIntel Xeon 4110 CPUs, 12 Inline graphic 8 GB DDR4 ECC Registered RAM, 2 Inline graphic 4 TB HDD, 4Inline graphic Nvidia GTX 1080Ti GPUs each with 11 GB DDR5 RAM, and with Ubuntu 20.04 LTS operating system. The algorithms are implemented using Python 3.7 with PyTorch 1.11 and CUDA 11.2. The Inline graphic is trained using the SGD optimizer for 50 epochs, with a learning rate of 0.01. The Inline graphic is evaluated for the loss function defined in Eq. (36).

In this study, the optimized parameters were determined through a systematic hyperparameter tuning process. The learning rate was varied across a range from Inline graphic to 0.1, and the choice of optimizer was evaluated between two popular algorithms: SGD and Adam. The Inline graphic is trained using SGD optimizer for 50 epochs, with a batch size of 256, a learning rate of 0.01.

Quantitative evaluation

Compression performance analysis

To evaluate the performance of the compression algorithm, compression factor (CF) is computed. Let the ECG signal with B samples be represented with p bits per sample. So, for Inline graphic subject with Inline graphic lead and B samples we have Inline graphic where Inline graphic shows the size of tensor in bits. The CF can be computed as,

graphic file with name d33e1568.gif 41

Signal quality analysis

In order to evaluate the performance of Inline graphic percentage root-mean-square difference (PRD)34, and structural similarity index measure (SSIM)29 between the decompressed and original ECG signals are calculated. The averaged PRD for Inline graphic lead with B samples is computed as,

graphic file with name d33e1596.gif 42

SSIM evaluate the similarity between original and decompressed for a given lead for Inline graphic lead is evaluated by,

graphic file with name d33e1606.gif 43

where Inline graphic and Inline graphic denote the average, Inline graphic and Inline graphic shows the variance of Inline graphic lead of Inline graphic subject of the original and the decompressed ECG signals respectively with B samples. Inline graphic shows the covariance of original and generated ECG signals. Inline graphic and Inline graphic are use to stabilize the weak denominator. We prefer to keep them as Inline graphic and Inline graphic similar to the origianl work35.

Results and discussion

Comparison with state-of-the-art

We have compared the efficiency of Inline graphic for compressing and decompressing lead-II ECG signal with state-of-the-art (SOTA) methods. It is evident from Table 1 that most of the algorithms are proposed utilizing 4 s or lesser duration ECG signal data. However, such a small duration ECG signal is insufficient for reliable arrhythmia diagnosis. Conversely, Inline graphic outperforms SOTA in ECG signal compression and decompression, particularly when applied to 4 s or longer duration signals. These results validate that our method can compress the ECG signal into a QR code and decompress the signal without losing important morphological features.

Table 1.

Prior art comparison on lead-II ECG compression and decompression. Here, Ref. shows the reference, YoP shows the year of publication, CF shows the compression factor and PRD shows the percentage root-mean-square difference.

Ref, YoP Performance Input type Evaluation on hidden dataset Generate QR code
Mathivanan et al., 201921 CF = 2.70, PRD = 0.346% 1 s image
Mathivanan et al., 201922 CF = 9.41, PRD = 3.43% 3.8 s signal
Mathivanan et al., 201926 CF = 3.39, PRD = 3.43% 2.7 s signal
This work CF = 82.37, PRD = 2.70% 8 s Signal

Looking through the lens of a clinician, for cardiac health monitoring, lead-II is widely used where the morphological changes are pivotal36. Further, in order to validate the clinical efficacy of reconstructed ECG signal, the amplitude-based features like P amplitude, R amplitude, T amplitude, and interval-based features like RR interval, PR interval, and QR interval are computed for both Inline graphic and Inline graphic. The difference in morphological features is computed by,

graphic file with name d33e1775.gif 44
graphic file with name d33e1779.gif 45

where Inline graphic denotes the amplitude or time interval-based features extracted from the Inline graphic ECG cycle in a signal. Inline graphic shows the total number of ECG cycles presents in the Inline graphic subject’s lead-II ECG signal.

Utilizing Inline graphic, the error between actual and decompressed RR interval, PR interval, and QR interval of lead-II ECG signals are 0.0001 s, 0.0003 s, and 0.0098 s respectively. Furthermore, the errors between the P amplitude, R amplitude, and T amplitude are 0.096, 0.11, and 0.0175 respectively. The SSIM value achieved while comparing actual and decompressed lead-II ECG signals is 0.9423.

Ablation study

Concerning the effectiveness of the model, CF, PRD, and SSIM are evaluated. In order to validate a good decompressed ECG signal from compressed bits, it is presumed to have a high CF value with a low PRD. It is expected to have PRD value close to Inline graphic, and SSIM values close to 1.

The different components of Inline graphic such as kernel size (Inline graphic), latent vector dimension (Inline graphic), and upscaling algorithm in Inline graphic are modified to justify the contribution of each component in improving the decompressed ECG signal quality. The ablation studies utilize the lead-I signal from the China and Georgia dataset, commonly used for wearable devices. Lead-I undergoes the process of compression and decompression. The models are trained on Inline graphic and evaluated on Inline graphic. The comparative analysis is performed as shown in Tables 2, 3, 4 and 5.

Table 2.

Ablation study of (Inline graphic to find the optimum Inline graphic) with different latent vector dimension.

Latent vector (Inline graphic Inline graphic CF SSIM PRD(%)
1 Inline graphic 8 3 173.34 0.91 8.1
7 0.90 8.69
15 0.91 8.37
2 Inline graphic 8 3 120.57 0.93 5.95
7 0.92 6.73
15 0.93 6.72
3 Inline graphic 8 3 97.85 0.93 5.09
7 0.93 4.91
15 0.93 4.93
4 Inline graphic 8 3 82.37 0.94 3.29
7 0.94 3.05
15 0.94 3.13
5 Inline graphic 8 3 71.11 0.94 3.27
7 0.94 3.49
15 0.94 3.06
6 Inline graphic 8 3 63.08 0.94 3.06
7 0.94 2.66
15 0.94 2.94
7 Inline graphic 8 3 55.83 0.94 3.05
7 0.94 2.75
15 0.94 2.85
8 Inline graphic 8 3 50.42 0.94 2.84
7 0.94 2.88
15 0.94 2.75

Table 3.

Ablation study of Inline graphic to find the optimum latent vector dimension. Bold values represent the best performance.

Latent vector dimension SSIM PRD (%)
8Inline graphic4 0.93 3.05
4Inline graphic8 0.94 3.15
2Inline graphic16 0.94 3.19
1Inline graphic32 0.94 2.80

Table 4.

Ablation study of Inline graphic to find the optimum upsampling technique. Bold values represent the best performance.

Upsampling methods CF SSIM PRD(%)
Pixel shuffle 82.37 0.94 2.80
Convtranspose 0.94 2.86
Upsample 1d 0.94 2.91

Table 5.

Ablation study of Inline graphic to find the supreme lossless compress technique. Bold values represent the best performance.

Method CF SSIM PRD(%)
Inline graphic 39.73 0.94 2.80
Inline graphic with Brotli30 82.37 0.94 2.80
Inline graphic with Huffman31 27.18 0.94 2.80
Inline graphic with zlib37 76.51 0.94 2.80
Inline graphic with LZ38 54.01 0.94 2.80

The parameter Inline graphic is varied among the values Inline graphic corresponding to different element values of Inline graphic (which defined the network layers). This variation results in changes to the dimensionality of the latent vector (Inline graphic) and Inline graphic. The Inline graphic is defined as Inline graphic for Inline graphic. The dimension of Inline graphic is varied to Inline graphic, Inline graphic, Inline graphic, Inline graphic, Inline graphic, Inline graphic, and Inline graphic, by varying the Inline graphic element of Inline graphic to Inline graphic = 2, 3, 4, 5, 6, 7,  and 8 respectively. The ablation study is shown in Table 2. It is evident from Table 2, that the performance with a Inline graphic = 7 and Inline graphic is sufficiently good. As the kernel size and latent dimension are increased, no substantial improvement is observed in SSIM values, nor is there a significant reduction in PRD. Additionally, the visual analysis revealed that the primary enhancement is limited to the reconstruction of the high-frequency components of the signal.

Further, the model performance is evaluated by varying the number of channels in latent vector (Inline graphic) dimension in between Inline graphic while keeping the kernel size of 7. The Inline graphic is varied to Inline graphic, Inline graphic, Inline graphic, and Inline graphic by varying Inline graphic, Inline graphic, Inline graphic and Inline graphic respectively. The Table 3 shows the comparative analysis and it is evident that with Inline graphic performs well.

Inline graphic with Inline graphic and Inline graphic, the upsampling algorithms such as pixel shuffle39, transposed convolution40, and 1-D upsample, in the decoder is varied in Inline graphic aiming to obtain a high quality decompressed signal. Further, the lossless compression and decompression techniques defined in Eqs. (4) and (7) are varied as Brotli30 Huffman31, zlib37, and Lempel-Ziv (LZ)38. Table 4 exhibits that the utilization of pixel shuffle enhances the quality of the decompressed ECG signal by reducing the artifacts. Additionally, Table 5 shows that utilizing Brotli compressor and decompressor results in highest CF score.

Result analysis

Utilization of Inline graphic without quantization such as float to integer conversion, with Inline graphic, Inline graphic, upsampling algorithms as pixel shuffle in Inline graphic, and Brotli as lossless compression algorithms, SSIM and PRD achieved on lead-I signal of hidden data set are 0.9417 and 2.798% respectively. The SSIM and PRD achieved for different single labeled cardiac arrhythmia and NSR are presented in Table 6.

Table 6.

SSIM and PRD achieved for CF of 82.37 for different single-labeled cardiac arrhythmia and NSR ECG data present in the hidden dataset.

Disease name SSIM PRD (%)
Atrial Fibrillation (AF) 0.96 2.48
Atrial Flutter (AFL) 0.94 2.61
Bundle Branch Block (BBB) 0.95 2.84
Bradycardia (Brady) 0.95 3.06
1st-degree AV block (IAVB) 0.98 1.59
Incomplete Right Bundle Branch Block (IRBBB) 0.97 2.28
Left Axis Deviation (LAD) 0.93 3.15
Left Anterior Fascicular Block (LAnFB) 0.96 1.67

Left Bundle Branch

Block (LBBB)

0.94 3.02
Low QRS Voltages (LQRSV) 0.93 3.20
Nonspecific Intraventricular Conduction Disorder (NSIVCD) 0.96 2.19
Normal Sinus Rhythm (NSR) 0.99 1.03
Pacing Rhythm (PR) 0.90 5.57
Premature Atrial Contraction (PAC) 0.95 2.16
Poor R Wave Progression (PRWP) 0.96 4.84
Prolonged PR Interval (LPR) 0.97 2.57
Prolonged QT Interval (LQT) 0.97 2.82
Q-wave Abnormal (QAb) 0.94 3.58
Right Axis Deviation (RAD) 0.94 2.99
Right Bundle Branch Block (RBBB) 0.97 2.22
Sinus Arrhythmia (SA) 0.95 3.13
Sinus Bradycardia (SB) 0.98 2.44
Sinus Tachycardia (STach) 0.97 2.70
T Wave Abnormal (TAb) 0.96 2.99
T wave Inversion (TInv) 0.96 2.99
Ventricular Premature Beats (VPB) 0.95 2.93

The lead-I signal of the hidden dataset is compressed to the QR code represented in Fig. 6. The QR code is decrypted and passed through Inline graphic, followed by Inline graphic and Inline graphic to obtain Inline graphic. The actual and decompressed signal is shown in Figure 7. Additionally, the SSIM and PRD achieved on the lead-II ECG signal of the hidden dataset are 0.9423 and 2.702% respectively. The error between actual and decompressed RR interval, PR interval, QR interval P amplitude, R amplitude, and T amplitude are 0.0001s, 0.0002s, 0.0001s, 0.061, 0.095, and 0.0251 respectively. Furthermore, the compression and decompression time for different lengths of signals on the hardware and software setting mentioned in ‘Training details’ are presented in Table 7.

Fig. 6.

Fig. 6

QR code representing the compressed bits of the lead-I ECG signal from a hidden dataset, generated using Inline graphic followed by Inline graphic, and Inline graphic.

Fig. 7.

Fig. 7

Actual and decompressed lead-I ECG signals from a hidden dataset. Decompressed signal is reconstructed from the QR code presented in Fig. 6.

Table 7.

Compression and decompression time for different lengths of signal.

Signal length Compression time Decompression time
1.024 s 21.31 ms 20.53 ms
4.096 s 25.7 ms 23.7 ms
8.192 s 32.23 ms 28.08 ms

Conclusion

In this work, we propose an end-to-end deep learning model for compression of the single lead ECG signal to the QR code. An exhaustive ablation study is done to obtain a good-performing model. The present study is different than the other studies as we have compressed a Inline graphic8-second long ECG signal to a single QR code without losing the essential morphological features. Furthermore, we have validated our method across a broad spectrum of subjects, including those with healthy/ sinus rhythms as well as subjects diagnosed with 26 different cardiovascular arrhythmias. This enables the usage of Inline graphic to compress ECG signals into QR codes, thereby enabling efficient data transmission and storage while ensuring privacy preservation. Also, the model is validated on a hidden dataset which makes it robust for use in the real world. By facilitating the seamless integration of ECG signal compression into healthcare workflows, our proposed method supports the transition towards non-invasive, continuous, efficient, and secure health data management practices in LMICs.

Author contributions

A.S. contributed to conceptualization, formal analysis, visualization, and writing the original draft of the manuscript. D.D. contributed to the conceptualization, visualization, and reviewing of the manuscript. A.P and D.S. provided supervision. All authors reviewed the manuscript.

Data availability

The utilized dataset in the current study is available in the Physionet challenge repository https://moody-challenge.physionet.org/2021/#rules.

Code availability

The code for this study will be released at https://github.com/apoorva-srivastava5/ECG2QR following the acceptance of the manuscript.

Declarations

Competing interests

The authors declare no competing interests.

Footnotes

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Apoorva Srivastava and Dipayan Dewan contributed equally to this work.

Contributor Information

Apoorva Srivastava, Email: apoorva.s.2311@gmail.com.

Debdoot Sheet, Email: debdoot@ee.iitkgp.ac.in.

References

  • 1.Vos, T. et al. Global burden of 369 diseases and injuries in 204 countries and territories, 1990–2019: A systematic analysis for the global burden of disease study 2019. Lancet396, 1204–1222 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 2.Alabdaljabar, M. S. et al. Machine learning in cardiology: a potential real-world solution in low-and middle-income countries. J. Multidiscip. Healthcare. 285–295 (2023). [DOI] [PMC free article] [PubMed]
  • 3.Dohare, A. K., Kumar, V. & Kumar, R. Detection of myocardial infarction in 12 lead ecg using support vector machine. Appl. Soft Comput.64, 138–147 (2018). [Google Scholar]
  • 4.Majumder, S. et al. Noncontact wearable wireless ecg systems for long-term monitoring. IEEE Rev. Biomed. Eng.11, 306–321 (2018). [DOI] [PubMed] [Google Scholar]
  • 5.Chen, J. et al. Contactless electrocardiogram monitoring with millimeter wave radar. IEEE Trans. Mobile Comput.23, 270–285 (2022). [Google Scholar]
  • 6.Kim, H., Yazicioglu, R. F., Merken, P., Van Hoof, C. & Yoo, H.-J. Ecg signal compression and classification algorithm with quad level vector for ecg holter system. IEEE Trans. Inform. Technol. Biomed.14, 93–100 (2009). [DOI] [PubMed] [Google Scholar]
  • 7.Kasoju, N. et al. Digital health: Trends, opportunities and challenges in medical devices, pharma and bio-technology. CSI Trans. ICT. 1–20 (2023).
  • 8.Joseph, L. et al. Systematic review on the use of patient-held health records in low-income and middle-income countries. BMJ Open11, e046965 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Shiu, H.-J., Lin, B.-S., Huang, C.-H., Chiang, P.-Y. & Lei, C.-L. Preserving privacy of online digital physiological signals using blind and reversible steganography. Computer Methods Programs Biomed.151, 159–170 (2017). [DOI] [PubMed] [Google Scholar]
  • 10.Wu, W.-C., Lin, Z.-W. & Wong, W.-T. Application of qr-code steganography using data embedding technique. In Information Technology Convergence: Security, Robotics, Automations and Communication, 597–605 (Springer, 2013).
  • 11.Mathivanan, P., Ganesh, A. B. & Venkatesan, R. Qr code-based ecg signal encryption/decryption algorithm. Cryptologia43, 233–253 (2019). [Google Scholar]
  • 12.Cárdenas-Barrera, J. L. & Lorenzo-Ginori, J. V. Mean-shape vector quantizer for ecg signal compression. IEEE Trans. Biomed. Eng.46, 62–70 (1999). [DOI] [PubMed] [Google Scholar]
  • 13.Kumar, V., Saxena, S. C., Giri, V. & Singh, D. Improved modified aztec technique for ecg data compression: Effect of length of parabolic filter on reconstructed signal. Computers Electr. Eng.31, 334–344 (2005). [Google Scholar]
  • 14.Rajankar, S. O. & Talbar, S. N. An electrocardiogram signal compression techniques: A comprehensive review. Analog Integr. Circ. Signal Process.98, 59–74 (2019). [Google Scholar]
  • 15.Jha, C. K. & Kolekar, M. H. Electrocardiogram data compression using dct based discrete orthogonal stockwell transform. Biomed. Signal Process. Control46, 174–181 (2018). [Google Scholar]
  • 16.Chagnon, J. & Rebollo-Neira, L. Mixed-transform based codec for 2d compression of ecg signals. Biomed. Signal Process. Control62, 102067 (2020). [Google Scholar]
  • 17.Melek, M. & Khattab, A. Ecg compression using wavelet-based compressed sensing with prior support information. Biomed. Signal Process. Control68, 102786 (2021). [Google Scholar]
  • 18.Gusev, M., Jovanov, M., Shekerov, A. & Temelkov, G. Ecg compression based on successive differences. In 2023 46th MIPRO ICT and Electronics Convention (MIPRO), 379–384 (IEEE, 2023).
  • 19.Banerjee, S. & Singh, G. K. A new real-time lossless data compression algorithm for ecg and ppg signals. Biomed. Signal Process. Control79, 104127 (2023). [Google Scholar]
  • 20.Manikandan, M. S. & Dandapat, S. Wavelet-based electrocardiogram signal compression methods and their performances: A prospective review. Biomed. Signal Process. Control14, 73–107 (2014). [Google Scholar]
  • 21.Mathivanan, P., Edward Jero, S., Ramu, P. & Balaji Ganesh, A. Qr code based patient data protection in ecg steganography. Aust. Phys. Eng. Scie. Med. 41, 1057–1068 (2018). [DOI] [PubMed]
  • 22.Mathivanan, P., Edward Jero, S. & Balaji Ganesh, A. Qr code-based highly secure ecg steganography. In International Conference on Intelligent Computing and Applications: Proceedings of ICICA 2018, 171–178 (Springer, 2019).
  • 23.Kannan, R. & Eswaran, C. Lossless compression schemes for ecg signals using neural network predictors. EURASIP J. Adv. Signal Process.2007, 1–20 (2007). [Google Scholar]
  • 24.Zhang, B., Zhao, J., Chen, X. & Wu, J. Ecg data compression using a neural network model based on multi-objective optimization. PloS One12, e0182500 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Yildirim, O., San Tan, R. & Acharya, U. R. An efficient compression of ecg signals using deep convolutional autoencoders. Cognit. Syst. Res. 52, 198–211 (2018).
  • 26.Mathivanan, P. & Balaji Ganesh, A. Qr code based color image cryptography for the secured transmission of ecg signal. Multimed. Tools Appl. 78, 6763–6786 (2019).
  • 27.Agrawal, A., Dash, A., Ghosh, N. & Patra, A. Morphological event based signal quality assessment of electrocardiogram. In 2022 44th Annual International Conference of the IEEE Engineering in Medicine & Biology Society (EMBC), 2021–2024 (IEEE, 2022). [DOI] [PubMed]
  • 28.Jagtap, S. K. & Uplane, M. The impact of digital filtering to ecg analysis: Butterworth filter application. In 2012 International Conference on Communication, Information & Computing Technology (ICCICT), 1–6 (IEEE, 2012).
  • 29.Wang, Z., Bovik, A. C., Sheikh, H. R. & Simoncelli, E. P. Image quality assessment: From error visibility to structural similarity. IEEE Trans. Image Process.13, 600–612 (2004). [DOI] [PubMed] [Google Scholar]
  • 30.Alakuijala, J. et al. Brotli: A general-purpose data compressor. ACM Trans. Inform. Syst. (TOIS)37, 1–30 (2018). [Google Scholar]
  • 31.Moffat, A. Huffman coding. ACM Comput. Surveys (CSUR)52, 1–35 (2019). [Google Scholar]
  • 32.Alday, E. A. P. et al. Classification of 12-lead ecgs: The physionet/computing in cardiology challenge 2020. Physiol. Meas.41, 124003 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33.Reyna, M. A. et al. Will two do? varying dimensions in electrocardiography: The Physionet/computing in Cardiology Challenge 2021. In 2021 Computing in Cardiology (CinC), vol. 48, 1–4 (IEEE, 2021).
  • 34.Kale, S. B. & Gawali, D. H. Review of ecg compression techniques and implementations. In 2016 International Conference on Global Trends in Signal Processing, Information Computing and Communication (ICGTSPICC), 623–627 (IEEE, 2016).
  • 35.Kumar, V. et al. Learning to generate missing pulse sequence in mri using deep convolution neural network trained with visual turing test. In 2021 43rd Annual International Conference of the IEEE Engineering in Medicine & Biology Society (EMBC), 3419–3422 (IEEE, 2021). [DOI] [PubMed]
  • 36.Kenny, B. J. & Brown, K. N. Ecg t wave (StatPearls Publishing LLC, Treasure Island, FL, 2022).
  • 37.Deutsch, P. & Gailly, J.-L. Zlib compressed data format specification version 3.3. Tech. Rep. (1996).
  • 38.Ziv, J. & Lempel, A. A universal algorithm for sequential data compression. IEEE Trans. Inform. Theory23, 337–343 (1977). [Google Scholar]
  • 39.Shi, W. et al. Real-time single image and video super-resolution using an efficient sub-pixel convolutional neural network. In Proceedings of the IEEE conference on computer vision and pattern recognition, 1874–1883 (2016).
  • 40.Dumoulin, V. & Visin, F. A guide to convolution arithmetic for deep learning. stat1050, 23 (2016).

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

The utilized dataset in the current study is available in the Physionet challenge repository https://moody-challenge.physionet.org/2021/#rules.

The code for this study will be released at https://github.com/apoorva-srivastava5/ECG2QR following the acceptance of the manuscript.


Articles from Scientific Reports are provided here courtesy of Nature Publishing Group

RESOURCES