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
, 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.
Overall pipeline for embedding ECG signal to QR-code is shown here. Let
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
.
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 standards12–14.
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 complexity15–20. 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.
Overall pipeline for compressing ECG signal to QR code is shown here. The model is trained on
8 s of ECG signal from two independent datasets used in this study. After training, the optimized deep learning model (
) is evaluated on an unseen independent dataset. The optimised compressor
convert the signal to a floating-point-represented tensor. The
further compress the tensor using the lossless compressor to provide compressed bits.
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
to obtain the compressed bit. These compressed bits pass through lossless decoder
to obtain compressed tensor. The reconstructed ECG signal is obtained by passing the tensor to optimised
, which is evaluated by quantitative analysis.
Methodology
Formal definition
Let us denote the
digital floating-point sample of the
ECG lead as
. 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
, such that
. The B sequence long,
lead for
subject can be denoted as
. Given that we have a dataset with N number of subjects with
lead available it can be denoted as,
.
Our goal is to develop a non-linear function F :
, where
. Here the ECG data
is compressed to
such that it contains the essential information which can be used to reconstruct the ECG data represented as
. It is expected that on training of the DNN and passing through lossless compressor and decompressor we would obtain
, where
.
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,
![]() |
1 |
![]() |
2 |
and
are the DNN which are together denoted as
.
shows the output tensor of
.
denote the output tensor of
, and input tensor of
. Once the compressed tensor is achieved, it is combined with the Second stage process to obtain
by,
![]() |
3 |
![]() |
4 |
![]() |
5 |
![]() |
6 |
![]() |
7 |
![]() |
8 |
where, the
sample of
lead in
is denoted as
. The
and
are lossless compression and decompression techniques respectively.
is the bit stream obtained after passing the output of
through Base-64 coder denoted as
. The
is the input to
, obtained by passing the bit stream through
followed by
.
Architecure
The proposed
is a encoder-decoder based architecture and can be defined as:
![]() |
9 |
where,
is the compressor and
is the decompressor unit.
Given a input of
, the output of the
is defined as:
![]() |
10 |
The reconstructed signal
is then produced by giving
to the
and can be defined as:
![]() |
11 |
has multiple
blocks which are made of three components:
,
, and
.
![]() |
12 |
![]() |
13 |
here,
represents the layer index, starting from
. Each subsequent layer output denoted by
is obtained by applying Eq. (13) to the previous layer’s feature map
. Let
,
shows the
element of
and L shows total elements in
which is the depth of the
. The initial feature map
, and
can be obtained by following equations:
![]() |
14 |
![]() |
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 (
) is reached. The
defined in Eq. (13), and (14) can be represented as:
![]() |
16 |
![]() |
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:
![]() |
18 |
![]() |
19 |
here, Eq. (19) describes the Dilated Attention Module (DAM), which combines the feature projection
with the attention mask (
). The
can be described as:
![]() |
20 |
The attention mask block (
) has multiple dilated convolution (
), Downsampling (
), Upsampling (
), and skip connection (
). For a given input
, output of
can be represented as:
![]() |
21 |
where
is defined as,
![]() |
22 |
In Eq. (22), for
become
, which is same as
.
![]() |
23 |
The variables
in Eq. (23) represent intermediate feature outputs that will be concatenated (or added) back at later stages. Next, we define
,
,
, and
used in Eq. (22).
![]() |
24 |
![]() |
25 |
![]() |
26 |
![]() |
27 |
The
consists of
. The details of the architecture of these blocks are given below:
![]() |
28 |
![]() |
29 |
![]() |
30 |
![]() |
31 |
Similar to compressor,
represents the layer index, starting from
. Each subsequent layer output denoted by
is obtained by applying Eq. (30) to the previous layer’s feature map
. similar to the
we define
.
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
subject with B samples is denoted as
.
- Step 1: A morphological-based signal quality assessment27
evaluates raw ECG signals and selects those of acceptable quality.
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
.
33 - Step 3: The filtered signals are resampled to a consistent 250 Hz frequency, denoted as
,
34 - Step 4: The resampled signal is normalized to standardize amplitude variations, focusing the model on key ECG morphological features.
where,
35
shows the
lead of
subject after the signal is passed through steps 1-3. Following step 4 all leads signal with B samples gives us the final
which is used as input for
. In this study,
, 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
takes single lead ECG signal
and generates a tensor
using Eqs. (1) and (2). The loss at this stage is,
![]() |
36 |
where
is evaluated using structural similarity index measure (SSIM) loss29.
Fig. 3.
Overview of the proposed method: We first train the convolution neural network base
on a single lead ECG signal (
). After training the compressed representation of the signal (
) is passed through
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 (
) 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 (
) followed by LLC decoder (
) which is fed to
to obtain the decompressed signal (
).
Final stage
Compression: During deployment, given a single lead ECG signal
, we obtain a lossy compressed tensor as
, using Eq. (3). The QR code from the compressed tensor
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
is Brotli compressor30 which gives an output as
where
is compressed bitstream.Step 2: The compressed bits are encoded using Base-64 encoder. This is achieved by Eq. (5), where
shows Base-64 encoder which gives an output as
. Here,
and l shows the length of string.
is passed through QR code generator to generate the QR code.
Decompression: The QR code decryptor, extracts the decompressed bit (
) from QR code. ECG signal is reconstructed from the QR code by following the steps described below.
Step 1: The decompressed
obtained from the QR code is passed through Base-64 decoder denoted as
using Eq. (6) to obtain compressed bitstream
.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
. 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
through
using Eq. (8) to obtain
. The procedural sequence to reconstruct the ECG signal from the decompressed bit stream can be represented as,
37
Inference manifest
During inference, the raw single lead ECG signal of a subject denoted as
is pre-processed using Eqs. (32)–(35) defined as,
![]() |
38 |
where
is send as an input to the trained
defined in Eqs. (3)–(5) to give the compressed bit denoted as
.
![]() |
39 |
The
is sent to the QR code generator to generate a 2-dimensional QR-code denoted as (
) and transmitted to the clinicians or stored. Aiming to retrieve back the signal, the QR code is scanned to get the bitstream denoted as
which is passed through
defined in Eqs. (6)–(8) to give
.
![]() |
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.
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
. However, subjects from Germany display a distinct data distribution, hence serving as a hidden held-out test dataset denoted as
.
The ECG data in
, with T number of subjects is split into two sets: training set (
) and testing (
). The
and
, consist of
and
number of subjects respectively, and
. Aiming to maintain the data distribution in
and
similar to
, the following steps are executed. The sample from
is selected using uniform distribution. The selected data point from
to be included in set
and
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.
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
is implemented and trained on a server equipped with 2
Intel Xeon 4110 CPUs, 12
8 GB DDR4 ECC Registered RAM, 2
4 TB HDD, 4
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
is trained using the SGD optimizer for 50 epochs, with a learning rate of 0.01. The
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
to 0.1, and the choice of optimizer was evaluated between two popular algorithms: SGD and Adam. The
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
subject with
lead and B samples we have
where
shows the size of tensor in bits. The CF can be computed as,
![]() |
41 |
Signal quality analysis
In order to evaluate the performance of
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
lead with B samples is computed as,
![]() |
42 |
SSIM evaluate the similarity between original and decompressed for a given lead for
lead is evaluated by,
![]() |
43 |
where
and
denote the average,
and
shows the variance of
lead of
subject of the original and the decompressed ECG signals respectively with B samples.
shows the covariance of original and generated ECG signals.
and
are use to stabilize the weak denominator. We prefer to keep them as
and
similar to the origianl work35.
Results and discussion
Comparison with state-of-the-art
We have compared the efficiency of
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,
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
and
. The difference in morphological features is computed by,
![]() |
44 |
![]() |
45 |
where
denotes the amplitude or time interval-based features extracted from the
ECG cycle in a signal.
shows the total number of ECG cycles presents in the
subject’s lead-II ECG signal.
Utilizing
, 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
, and SSIM values close to 1.
The different components of
such as kernel size (
), latent vector dimension (
), and upscaling algorithm in
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
and evaluated on
. The comparative analysis is performed as shown in Tables 2, 3, 4 and 5.
Table 2.
Ablation study of (
to find the optimum
) with different latent vector dimension.
Latent vector (
|
![]() |
CF | SSIM | PRD(%) |
|---|---|---|---|---|
1 8 |
3 | 173.34 | 0.91 | 8.1 |
| 7 | 0.90 | 8.69 | ||
| 15 | 0.91 | 8.37 | ||
2 8 |
3 | 120.57 | 0.93 | 5.95 |
| 7 | 0.92 | 6.73 | ||
| 15 | 0.93 | 6.72 | ||
3 8 |
3 | 97.85 | 0.93 | 5.09 |
| 7 | 0.93 | 4.91 | ||
| 15 | 0.93 | 4.93 | ||
4 8 |
3 | 82.37 | 0.94 | 3.29 |
| 7 | 0.94 | 3.05 | ||
| 15 | 0.94 | 3.13 | ||
5 8 |
3 | 71.11 | 0.94 | 3.27 |
| 7 | 0.94 | 3.49 | ||
| 15 | 0.94 | 3.06 | ||
6 8 |
3 | 63.08 | 0.94 | 3.06 |
| 7 | 0.94 | 2.66 | ||
| 15 | 0.94 | 2.94 | ||
7 8 |
3 | 55.83 | 0.94 | 3.05 |
| 7 | 0.94 | 2.75 | ||
| 15 | 0.94 | 2.85 | ||
8 8 |
3 | 50.42 | 0.94 | 2.84 |
| 7 | 0.94 | 2.88 | ||
| 15 | 0.94 | 2.75 |
Table 3.
Ablation study of
to find the optimum latent vector dimension. Bold values represent the best performance.
| Latent vector dimension | SSIM | PRD (%) |
|---|---|---|
8 4 |
0.93 | 3.05 |
4 8 |
0.94 | 3.15 |
2 16 |
0.94 | 3.19 |
1 32 |
0.94 | 2.80 |
Table 4.
Ablation study of
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
to find the supreme lossless compress technique. Bold values represent the best performance.
The parameter
is varied among the values
corresponding to different element values of
(which defined the network layers). This variation results in changes to the dimensionality of the latent vector (
) and
. The
is defined as
for
. The dimension of
is varied to
,
,
,
,
,
, and
, by varying the
element of
to
= 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
= 7 and
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 (
) dimension in between
while keeping the kernel size of 7. The
is varied to
,
,
, and
by varying
,
,
and
respectively. The Table 3 shows the comparative analysis and it is evident that with
performs well.
with
and
, the upsampling algorithms such as pixel shuffle39, transposed convolution40, and 1-D upsample, in the decoder is varied in
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
without quantization such as float to integer conversion, with
,
, upsampling algorithms as pixel shuffle in
, 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
, followed by
and
to obtain
. 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.

QR code representing the compressed bits of the lead-I ECG signal from a hidden dataset, generated using
followed by
, and
.
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
8-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
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.
































































