This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

\newfloatcommand

capbtabboxtable[][\FBwidth]

CardioGAN: Attentive Generative Adversarial Network with Dual Discriminators for Synthesis of ECG from PPG

Pritam Sarkar, Ali Etemad
Abstract

Electrocardiogram (ECG) is the electrical measurement of cardiac activity, whereas Photoplethysmogram (PPG) is the optical measurement of volumetric changes in blood circulation. While both signals are used for heart rate monitoring, from a medical perspective, ECG is more useful as it carries additional cardiac information. Despite many attempts toward incorporating ECG sensing in smartwatches or similar wearable devices for continuous and reliable cardiac monitoring, PPG sensors are the main feasible sensing solution available. In order to tackle this problem, we propose CardioGAN, an adversarial model which takes PPG as input and generates ECG as output. The proposed network utilizes an attention-based generator to learn local salient features, as well as dual discriminators to preserve the integrity of generated data in both time and frequency domains. Our experiments show that the ECG generated by CardioGAN provides more reliable heart rate measurements compared to the original input PPG, reducing the error from 9.749.74 beats per minute (measured from the PPG) to 2.892.89 (measured from the generated ECG).

1 Introduction

According to the World Health Organization (WHO) in 2017, Cardiovascular Deceases (CVDs) are reported as the leading causes of death worldwide (WHO 2017). The report indicates that CVDs cause 31%31\% of global deaths, out of which at least three-quarters of deaths occur in the low or medium-income countries. One of the primary reasons behind this is the lack of primary healthcare support and the inaccessible on-demand health monitoring infrastructure. Electrocardiogram (ECG) is considered as one of the most important attributes for continuous health monitoring required for identifying those who are at serious risk of future cardiovascular events or death. Vast amount of research is being conducted with the goal of developing wearable devices capable of continuous ECG monitoring and feasible for daily life use, largely to no avail. Currently, very few wearable devices provide wrist-based ECG monitoring, and those who do, require the user to stand still and touch the watch with both hands in order to close the circuit in order to record an ECG segment of limited duration (usually 30 seconds), making these solutions non-continuous and sporadic.

Photoplethysmogram (PPG), an optical method for measuring blood volume changes at the surface of the skin, is considered as a close alternative to ECG, which contains valuable cardiovascular information (Gil et al. 2010; Schäfer and Vagedes 2013). For instance, studies have shown that a number of features extracted from PPG (e.g., pulse rate variability) are highly correlated with corresponding metrics extracted from ECG (e.g., heart rate variability) (Gil et al. 2010), further illustrating the mutual information between these two modalities. Yet, through recent advancements in smartwatches, smartphones, and other similar wearable and mobile devices, PPG has become the industry standard as a simple, wearable-friendly, and low-cost solution for continuous heart rate (HR) monitoring for everyday use. Nonetheless, PPG suffers from inaccurate HR estimation and several other limitations in comparison to conventional ECG monitoring devices (Bent et al. 2020) due to factors like skin tone, diverse skin types, motion artefacts, and signal crossovers among others. Moreover, the ECG waveform carries important information about cardiac activity. For instance, the P-wave indicates the sinus rhythm, whereas a long PR interval is generally indicative of a first-degree heart blockage (Ashley and Niebauer 2004). As a result, ECG is consistently being used by cardiologists for assessing the condition and performance of the heart.

Based on the above, there is a clear discrepancy between the need for continuous wearable ECG monitoring and the available solutions in the market. To address this, we propose CardioGAN, a generative adversarial network (GAN) (Goodfellow et al. 2014), which takes PPG as inputs and generates ECG. Our model is based on the CycleGAN architecture (Zhu et al. 2017) which enables the system to be trained in an unpaired manner. Unlike CycleGAN, CardioGAN is designed with attention-based generators and equipped with multiple discriminators. We utilize attention mechanisms in the generators to better learn to focus on specific local regions such as the QRS complexes of ECG. To generate high fidelity ECG signals in terms of both time and frequency information, we utilize a dual discriminator strategy where one discriminator operates on signals in the time domain while the other uses frequency-domain spectrograms of the signals. We show that the generated ECG outputs are very similar to the corresponding real ECG signals. Finally, we perform HR estimation using our generated ECG as well as the input PPG signals. By comparing these values to the HR measured from the ground-truth ECG signals, we observe a clear advantage in our proposed method. While to demonstrate the efficacy of our solution we focus on single-lead ECG, we believe our approach can be used for multi-lead ECG through training the system on other desired leads. Our contributions in this paper are summarised below:

  • We propose a novel framework called CardioGAN for generating ECG signals from PPG inputs. We utilize attention-based generators and dual time and frequency domain discriminators along with a CycleGAN backbone to obtain realistic ECG signals. To the best of our knowledge, no other studies have attempted to generate ECG from PPG (or in fact any cross-modality signal-to-signal translation in the biosignal domain) using GANs or other deep learning techniques.

  • We perform a multi-corpus subject-independent study, which proves the generalizability of our model to data from unseen subjects and acquired in different conditions.

  • The generated ECG obtained from the CardioGAN provides more accurate HR estimation compared to HR values calculated from the original PPG, demonstrating some of the benefits of our model in the healthcare domain. We make the final trained model publicly available111https://code.engineering.queensu.ca/17ps21/ppg2ecg-cardiogan.

The rest of this paper is organized as follows. Section 2 briefly mentions the prior studies on ECG signal generation. Next, our proposed method is discussed in Section 3. Section 4 discusses the details of our experiments, including datasets and training procedures. Finally, the results and analyses are presented in Section 5, followed by a summary of our work in Section 6.

2 Related Work

2.1 Generating synthetic ECG Signal

The idea of synthesizing ECG has been explored in the past, utilizing both model-driven (e.g. signal processing or mathematical modelling) and data-driven (machine learning and deep learning) techniques. As examples of earlier works, (McSharry et al. 2003; Sayadi, Shamsollahi, and Clifford 2010) proposed solutions based on differential equations and Gaussian models for generating ECG segments.

Despite deep learning being employed to process ECG for a wide variety of different applications, for instance biometrics (Zhang, Zhou, and Zeng 2017), arrhythmia detection (Hannun et al. 2019), emotion recognition (Sarkar and Etemad 2020a, b), cognitive load analysis (Sarkar et al. 2019; Ross et al. 2019), and others, very few studies have tackled synthesis of ECG signals with deep neural networks (Zhu et al. 2019a; Golany and Radinsky 2019; Golany et al. 2020). Synthesizing ECG with GANs was first studied in (Zhu et al. 2019a), where a bidirectional LSTM-CNN architecture was proposed to generate ECG from Gaussian noise. The study performed by (Golany and Radinsky 2019), proposed PGAN or Personalized GAN to generate patient-specific synthetic ECG signals from input noise. A special loss function was proposed to mimic the morphology of ECG waveforms, which was a combination of cross-entropy loss and mean squared error between real and fake ECG waveforms.

A few other studies have targeted this area, for example, EmotionalGAN was proposed in (Chen et al. 2019), where synthetic ECG was used to augment the available ECG data in order to improve emotion classification accuracy. The proposed GAN generated the new ECG based on input noise. Lastly, in a similar study performed by (Golany et al. 2020), ECG was generated from input noise to augment the available ECG training set, improving the performance for arrhythmia detection.

2.2 ECG Synthesis from PPG

With respect to the very specific problem of PPG-to-ECG translation, to the best of our knowledge, only (Zhu et al. 2019b) has been published. This work did not use deep learning, instead used discrete cosine transformation (DCT) technique to map each PPG cycle to its corresponding ECG cycle. First, onsets of the PPG signals were aligned to the R-peaks of the ECG signals, followed by a de-trending operation in order to reduce noise. Next, each cycle of ECG and PPG was segmented, followed by temporal scaling using linear interpolation in order to maintain a fixed segment length. Finally, a linear regression model was trained to learn the relation between DCT coefficients of PPG segments and corresponding ECG segments. In spite of several contributions, this study suffers from few limitations. First, the model failed to produce reliable ECG in a subject-independent manner, which limits its application to only previously seen subject’s data. Second, often the relation between PPG segments and ECG segments are not linear, therefore in several cases, this model failed to capture the non-linear relationships between these 22 domains. Lastly, no experiments have been performed to indicate any performance enhancement gained from using the generated ECG as opposed to the available PPG (for example a comparison of measured HR).

3 Method

3.1 Objective and Proposed Architecture

In order to not be constrained by paired training where both types of data are needed from the same instance in order to train the system, we are interested in an unpaired GAN, i.e. CycleGAN-based architectures. We propose CardioGAN whose main objective is to learn to estimate the mapping between PPG (PP) and ECG (EE) domains. In order to force the generator to focus on regions of the data with significant importance, we incorporate an attention mechanism into the generator. We implement generator GE:PEG_{E}:P\rightarrow E to learn forward mapping, and GP:EPG_{P}:E\rightarrow P to learn the inverse mapping. We denote generated ECG and generated PPG from CardioGAN as EE^{\prime} and PP^{\prime} respectively, where E=GE(P)E^{\prime}=G_{E}(P) and P=GP(E)P^{\prime}=G_{P}(E). According to (Penttilä et al. 2001) and a large number of other studies, cardiac activity is manifested in both time and frequency domains. Therefore, in order to preserve the integrity of the generated ECG in both domains, we propose the use of a dual discriminator strategy, where DtD^{t} is employed to classify time domain and DfD^{f} is used to classify the frequency domain response of real and generated data.

Figure 1 shows our proposed architecture, where GEG_{E} takes PP as an input and generates EE^{\prime} as the output. Similarly, EE is given as an input to GPG_{P} where PP^{\prime} is generated as the output. We employ DEtD^{t}_{E} and DPtD^{t}_{P} to discriminate EE versus EE^{\prime}, and PP versus PP^{\prime}, respectively. Similarly, DEfD^{f}_{E} and DPfD^{f}_{P} are developed to discriminate f(E)f(E) versus f(E)f(E^{\prime}), as well as f(P)f(P) versus f(P)f(P^{\prime}), respectively, where ff denotes the spectrogram of the input signal. Finally, EE^{\prime} and PP^{\prime} are given as inputs to GPG_{P} and GEG_{E} respectively, in order to complete the cyclic training process.

In the following subsections, we expand on the dual discriminator, the notion of integrating an attention mechanism into the generator, and the loss functions used to train the overall architecture. The details and architectures of each of the networks used in our proposed solution are provided in Section 4.3.

Refer to caption
Figure 1: The architecture of the proposed CardioGAN is presented. The original ECG (EE) and PPG (PP) signals are shown in the color ‘orange’; the generated outputs (EE^{\prime} and PP^{\prime}) are represented with the color ‘green’; and the reconstructed or cyclic outputs (E′′E^{\prime\prime} and P′′P^{\prime\prime}) are marked with the color ‘black’ for better visibility. Moreover, connections to the generators are marked with solid lines, whereas, connections to the discriminators are marked with dashed lines.

3.2 Dual Discriminators

As mentioned above, to preserve both time and frequency information in the generated ECG, we use a dual discriminator approach. Dual discriminators have been used earlier in (Nguyen et al. 2017), showing improvements in dealing with mode collapse problems. To leverage the concept of dual discriminators, we perform Short-Time Fourier Transformation (STFT) on the ECG/PPG time series data. Let’s denote x[n]x[n] as a time-series, then STFT(x[n])STFT(x[n]) can be denoted as X(m,ω)=n=x[n]w[nm]ejωnX(m,\omega)=\sum^{\infty}_{n=-\infty}x[n]w[n-m]e^{-j\omega n}, where mm is the step size and w[n]w[n] denotes Hann window function. Finally, the spectrogram is obtained by f(x[n])=log(|X(m,ω)|+θ)f(x[n])=log(|X(m,\omega)|+\theta), where we use θ=1e10\theta=1e^{-10} to avoid infinite condition. As shown in Figure 1 the time-domain and frequency-domain discriminators operate in parallel, and as we will discuss in Section 3.4, to aggregate the outcomes of these two networks, the loss terms of both of these networks are incorporated into the adversarial loss.

3.3 Attention-based Generators

We adopt Attention U-Net as our generator architecture, which has been recently proposed and used for image classification (Oktay et al. 2018; Jetley et al. 2018). We chose attention-based generators to learn to better focus on salient features passing through the skip connections. Let’s assume xlx^{l} are features obtained from the skip connection originating from layer ll, and gg is the gating vector that determines the region of focus. First, xlx^{l} and gg are mapped to an intermediate-dimensional space Fint\mathbb{R}^{F_{int}} where FintF_{int} corresponds to the dimensions of the intermediate-dimensional space. Our objective is to determine the scalar attention values (αil\alpha_{i}^{l}) for each temporal unit xilFlx^{l}_{i}\in\mathbb{R}^{F_{l}}, utilizing gating vector giFgg_{i}\in\mathbb{R}^{F_{g}}, where FlF_{l} and FgF_{g} are the number of feature maps in xlx^{l} and gg respectively. Linear transformations are performed on xlx^{l} and gg as θx=Wxxil+bx\theta_{x}=W_{x}x^{l}_{i}+b_{x} and θg=Wggi+bg\theta_{g}=W_{g}g_{i}+b_{g} respectively, where WxFl×FintW_{x}\in\mathbb{R}^{F_{l}\times F_{int}}, WgFg×FintW_{g}\in\mathbb{R}^{F_{g}\times F_{int}}, and bxb_{x}, bgb_{g} refer to the bias terms. Next, non-linear activation function ReLu (denoted by σ1\sigma_{1}) is applied to obtain the sum feature activation f=σ1(θx+θg)f=\sigma_{1}(\theta_{x}+\theta_{g}), where σ1(y)\sigma_{1}(y) is formulated as max(0,y)\max(0,y). Next we perform a linear mapping of ff onto the Fint\mathbb{R}^{F_{int}} dimensional space by performing channel-wise 1×11\times 1 convolutions, followed by passing through a sigmoid activation function (σ2)(\sigma_{2}) in order to obtain the attention weights in the range of [0,1][0,1]. The attention map corresponding to xlx^{l} is obtained by αil=σ2(ψf)\alpha_{i}^{l}=\sigma_{2}(\psi*f) where σ2(y)\sigma_{2}(y) can be formulated as 11+expy\frac{1}{1+exp^{-y}}, ψFint\psi\in\mathbb{R}^{F_{int}} and * denotes convolution. Next, we perform element-wise multiplication between xilx^{l}_{i} and αil\alpha^{l}_{i} to obtain the final output from the attention layer.

3.4 Loss

Our final objective function is a combination of an adversarial loss and a cyclic consistency loss as presented below.

Adversarial Loss

We apply adversarial loss in both forward and inverse mappings. Let’s denote individual PPG segments as pp and the corresponding ground-truth ECG segments as ee. For the mapping function GE:PEG_{E}:P\rightarrow E, and discriminators DEtD^{t}_{E} and DEfD^{f}_{E}, the adversarial losses are defined as:

adv(GE,DEt)=𝔼eE[log(DEt(e))]+𝔼pP[log(1DEt(GE(p)))]\begin{split}\mathcal{L}_{adv}(G_{E},D^{t}_{E})&=\mathbb{E}_{e\sim E}[\log{(D^{t}_{E}(e))}]\\ &+\mathbb{E}_{p\sim P}[\log{(1-D^{t}_{E}(G_{E}(p)))}]\end{split} (1)
adv(GE,DEf)=𝔼eE[log(DEf(f(e)))]+𝔼pP[log(1DEf(f(GE(p))))]\begin{split}\mathcal{L}_{adv}(G_{E},D^{f}_{E})&=\mathbb{E}_{e\sim E}[\log{(D^{f}_{E}(f(e)))}]\\ &+\mathbb{E}_{p\sim P}[\log{(1-D^{f}_{E}(f(G_{E}(p))))}]\end{split} (2)

Similarly, for the inverse mapping function GP:EPG_{P}:E\rightarrow P, and discriminators DPtD^{t}_{P} and DPfD^{f}_{P}, the adversarial losses are defined as:

adv(GP,DPt)=𝔼pP[log(DPt(p))]+𝔼eE[log(1DPt(GP(e)))]\begin{split}\mathcal{L}_{adv}(G_{P},D^{t}_{P})&=\mathbb{E}_{p\sim P}[\log{(D^{t}_{P}(p))}]\\ &+\mathbb{E}_{e\sim E}[\log{(1-D^{t}_{P}(G_{P}(e)))}]\end{split} (3)
adv(GP,DPf)=𝔼pP[log(DPf(f(p)))]+𝔼eE[log(1DPf(f(GP(e))))]\begin{split}\mathcal{L}_{adv}(G_{P},D^{f}_{P})&=\mathbb{E}_{p\sim P}[\log{(D^{f}_{P}(f(p)))}]\\ &+\mathbb{E}_{e\sim E}[\log{(1-D^{f}_{P}(f(G_{P}(e))))}]\end{split} (4)

Finally, the adversarial objective function for the mapping GE:PEG_{E}:P\rightarrow E is obtained as minGEmaxDEtadv(GE,DEt)\min_{G_{E}}\max_{D^{t}_{E}}\mathcal{L}_{adv}(G_{E},D^{t}_{E}) and minGEmaxDEfadv(GE,DEf)\min_{G_{E}}\max_{D^{f}_{E}}\mathcal{L}_{adv}(G_{E},D^{f}_{E}). Similarly, for the mapping GP:EPG_{P}:E\rightarrow P, can be calculated as minGPmaxDPtadv(GP,DPt)\min_{G_{P}}\max_{D^{t}_{P}}\mathcal{L}_{adv}(G_{P},D^{t}_{P}) and minGPmaxDPfadv(GP,DPf)\min_{G_{P}}\max_{D^{f}_{P}}\mathcal{L}_{adv}(G_{P},D^{f}_{P}).

Cyclic Consistency Loss

The other component of our objective function is the cyclic consistency loss or reconstruction loss as proposed by (Zhu et al. 2017). In order to ensure that forward mappings and inverse mappings are consistent, i.e., pGE(p)GP(GE(p))pp\rightarrow G_{E}(p)\rightarrow G_{P}(G_{E}(p))\approx p, as well as eGP(e)GE(GP(e))ee\rightarrow G_{P}(e)\rightarrow G_{E}(G_{P}(e))\approx e, we minimize the cycle consistency loss calculated as:

cyclic(GE,GP)=𝔼eE[GE(GP(e))e1]+𝔼pP[GP(GE(p))p1]\begin{split}\mathcal{L}_{cyclic}(G_{E},G_{P})&=\mathbb{E}_{e\sim E}[||G_{E}(G_{P}(e))-e||_{1}]\\ &+\mathbb{E}_{p\sim P}[||G_{P}(G_{E}(p))-p||_{1}]\end{split} (5)

Final Loss

The final objective function of CardioGAN is computed as:

CardioGAN=αadv(GE,DEt)+αadv(GP,DPt)+βadv(GE,DEf)+βadv(GP,DPf)+λcyclic(GE,GP),\begin{split}\mathcal{L}_{CardioGAN}&=\alpha\mathcal{L}_{adv}(G_{E},D^{t}_{E})+\alpha\mathcal{L}_{adv}(G_{P},D^{t}_{P})\\ &+\beta\mathcal{L}_{adv}(G_{E},D^{f}_{E})+\beta\mathcal{L}_{adv}(G_{P},D^{f}_{P})\\ &+\lambda\mathcal{L}_{cyclic}(G_{E},G_{P}),\end{split} (6)

where α\alpha and β\beta are adversarial loss coefficients corresponding to DtD^{t} and DfD^{f} respectively, and λ\lambda is the cyclic consistency loss coefficient.

4 Experiments

In this section, we first introduce the datasets used in this study, followed by the description of the data preparation steps. Next, we present our implementation and architecture details.

4.1 Datasets

We use 44 very popular ECG-PPG datasets, namely BIDMC (Pimentel et al. 2016), CAPNO (Karlen et al. 2013), DALIA (Reiss et al. 2019), and WESAD (Schmidt et al. 2018). We combine these 44 datasets in order to enable a multi-corpus approach leveraging large and diverse distributions of data for different factors such as activity (e.g. working, driving, walking, resting), age (e.g. 2929 children, 9696 adults), and others. The aggregate dataset contains a total of 125125 participants with a balanced male-female ratio.

BIDMC

(Pimentel et al. 2016) was obtained from 5353 adult ICU patients (3232 females, 2121 males, mean age of 64.8164.81) where each recording was 88 minutes long. PPG and ECG were both sampled at a frequency of 125125 Hz. It should be noted this dataset consists of three leads of ECG (II, V, AVR). However, we only use lead II in this study.

CAPNO

(Karlen et al. 2013) consists of data from 4242 participants, out of which 2929 were children (median age of 8.78.7) and 1313 were adults (median age of 52.452.4). The recordings were collected while the participants were under medical observation. Single-lead ECG and PPG recordings were sampled at a frequency of 300300 Hz and were 88 minutes in length.

DALIA

(Reiss et al. 2019) was recorded from 1515 participants (88 females, 77 males, mean age of 30.6030.60), where each recording was approximately 22 hours long. ECG and PPG signals were recorded while participants went through different daily life activities, for instance sitting, walking, driving, cycling, working and so on. Single-lead ECG signals were recorded at a sampling frequency of 700700 Hz while the PPG signals were recorded at a sampling rate of 6464 Hz.

WESAD

(Schmidt et al. 2018) was created using data from 1515 participants (1212 male, 33 female, mean age of 27.527.5), while performing activities such as solving arithmetic tasks, watching video clips, and others. Each recording was over 11 hour in duration. Single-lead ECG was recorded at a sampling rate of 700700 Hz while PPG was recorded at a sampling rate of 6464 Hz.

4.2 Data Preparation

Since the above-mentioned datasets have been collected at different sampling frequencies, as a first step we re-sampled (using interpolation) both the ECG and PPG signals with a sampling rate of 128128 Hz. As the raw physiological signals contain a varying amounts and types of noise (e.g. power line interference, baseline wandering, motion artefacts), we perform very common filtering techniques on both the ECG and PPG signals. We apply a band-pass FIR filter with a pass-band frequency of 33 Hz and stop-band frequency of 4545 Hz on the ECG signals. Similarly, a band-pass Butterworth filter with a pass-band frequency of 11 Hz and a stop-band frequency of 88 Hz is applied on the PPG signals. Next, person-specific z-score normalization is performed on both ECG and PPG. Then, the normalized ECG and PPG signals are segmented into 44-second windows (128128 Hz ×4\times 4 seconds =512=512 samples), with a 10%10\% overlap to avoid missing any peaks. Finally, we perform min-max [1,1][-1,1] normalization on both ECG and PPG segments to ensure all the input data are in a specific range.

4.3 Architecture

Generator

As mentioned earlier an Attention U-Net architecture is used as our generator, where self-gated soft-attention units are used to filter the features passing through the skip connections. GEG_{E} and GPG_{P} take 1×5121\times 512 data points as input. The encoder consists of 66 blocks, where the number of filters is gradually increased (64,128,256,512,512,51264,128,256,512,512,512) with a fixed kernel size of 1×161\times 16 and a stride of 22. We apply layer normalization and leaky-ReLu activation after each convolution layers except the first layer, where no normalization is used. A similar architecture is used in the decoder, except de-convolutional layers with ReLu activation functions are used and the number of filters is gradually decreased in the same manner. The final output is then obtained from a de-convolutional layer with a single-channel output followed by tanh activation.

Discriminator

Dual discriminators are used to classify real and fake data in time and frequency domains. DEtD^{t}_{E} and DPtD^{t}_{P} take time-series signals of size 1×5121\times 512 as inputs, whereas, spectrograms of size 128×128128\times 128 are given as inputs to DEfD^{f}_{E} and DPfD^{f}_{P}. Both DtD^{t} and DfD^{f} use 44 convolution layers, where the number of filters are gradually increased (64,128,256,51264,128,256,512) with a fixed kernel of 1×161\times 16 for DtD^{t} and 7×77\times 7 for DfD^{f}. Both networks use a stride of 2. Each convolution layer is followed by layer normalization and leaky ReLu activation, except the first layer where no normalization is used. Finally, the output is obtained from a single-channel convolutional layer.

4.4 Training

Our proposed CardioGAN network is trained from scratch on an Nvidia Titan RTX GPU, using TensorFlow 2.2. We divide the aggregated dataset into a training set and test set. We randomly select 80%80\% of the users from each dataset (a total of 101101 participants, equivalent to 5858K segments) for training, and the remaining 20%20\% of users from each dataset (a total of 2424 participants, equivalent to 1515K segments) for testing. The training time was approximately 5050 hours. To enable CardioGAN to be trained in an unpaired fashion, we shuffle the ECG and PPG segments from each dataset separately eliminating the couplings between ECG and PPG followed by a shuffling of the order of datasets themselves for ECG and PPG separately. We use a batch size of 128128, unlike the original CycleGAN where a batch size of 11 is used. We notice performance gain with a larger batch size. Adam optimizer is used to train both the generators and discriminators. We train our model for 1515 epochs, where the learning rate (1e41e^{-4}) is kept constant for the initial 1010 epochs and then linearly decayed to 0. The values of α\alpha, β\beta, and λ\lambda are empirically set to 33, 11 and 3030 respectively.

5 Performance

CardioGAN produces two main signal outputs, generated ECG (EE^{\prime}) and generated PPG (PP^{\prime}). As our goal is to generate the more important and elusive ECG, we utilize EE^{\prime} and ignore PP^{\prime} in the following experiments. In this section, we present the quantitative and qualitative results of our proposed CardioGAN network. Next, we perform an ablation study in order to understand the effects of the different components of the model. Further, we perform several analyses, followed by a discussion of potential applications using our proposed solution.

5.1 Quantitative Results

Heart rate is measured as number of beats per minutes (BPM) by dividing the length of ECG or PPG segments in seconds by the average of the peak intervals multiplied by 60 (seconds). Let’s define the mean absolute error (MAE) metric for the heart rate (in BPM) obtained from a given ECG or PPG signal (HRQHR^{Q}) with respect to a ground-truth HR (HRGTHR^{GT}) as MAEHR(Q)=1Ni=1N|HRiGTHRiQ|MAE_{HR}(Q)={\frac{1}{N}}\sum_{i=1}^{N}|HR^{GT}_{i}-HR^{Q}_{i}|, where NN is the number of segments for which the HR measurements have been obtained. In order to investigate the merits of CardioGAN, we measure MAEHR(E)MAE_{HR}(E^{\prime}), where EE^{\prime} is the ECG generated by CardioGAN. We compare these MAE values to MAEHR(P)MAE_{HR}(P) (where PP denotes the available input PPG) as reported by other studies on the 4 datasets. The results are presented in Table 1 where we observe that for 33 of the 44 datasets, the HR measured from the ECG generated by CardioGAN is more accurate than the HR measured from the input PPG signals. For CAPNO dataset in which our ECG shows higher error compared to other works based on PPG, the difference is quite marginal, especially in comparison to the performance gains achieved across the other datasets.

Different studies in this area have used different window sizes for HR measurement which we report in Table 1. To evaluate the impact of our solution based on different window sizes, we measure MAEHR(E)MAE_{HR}(E^{\prime}) over different 4,8,16,324,8,16,32, and 6464 second windows and present the results in comparison to MAEHR(P)MAE_{HR}(P) across all the subjects available in the 44 datasets in Table 2. In these experiments, we utilize two popular algorithms for detecting peaks from ECG (Hamilton 2002) and PPG (Elgendi et al. 2013) signals. We observe a clear advantage in measuring HR from EE^{\prime} as opposed to PP. We notice a very consistent performance gain across different window sizes, which further demonstrates the stability of the results produce by CardioGAN.

Dataset Method Window (sec.) MAEHRMAE_{HR}
BIDMC (Nilsson et al. 2005) 6464 4.64.6
(Shelley et al. 2006) 2.32.3
(Fleming et al. 2007) 5.55.5
(Karlen et al. 2013) 5.75.7
(Pimentel et al. 2016) 2.72.7
CardioGAN 0.7
CAPNO (Nilsson et al. 2005) 6464 10.210.2
(Shelley et al. 2006) 2.22.2
(Fleming et al. 2007) 1.41.4
(Karlen et al. 2013) 1.2
(Pimentel et al. 2016) 1.91.9
CardioGAN 2.02.0
Dalia (Schäck et al. 2017) 88 20.520.5
(Reiss et al. 2019) 15.615.6
(Reiss et al. 2019) 11.111.1
CardioGAN 8.3
WESAD (Schäck et al. 2017) 88 19.919.9
(Reiss et al. 2019) 11.511.5
(Reiss et al. 2019) 9.59.5
CardioGAN 8.6
Table 1: We compare the MAEHRMAE_{HR} calculated from the generated ECG with MAEHRMAE_{HR} calculated from the real input PPG.
Window (sec.) MAEHR(E)MAE_{HR}(E^{\prime}) MAEHR(P)MAE_{HR}(P)
4 4.864.86 10.6710.67
8 3.543.54 10.2310.23
16 3.273.27 10.0010.00
32 3.083.08 9.779.77
64 2.892.89 9.749.74
Table 2: A comparison of MAEHRMAE_{HR} between generated ECG and real PPG is presented for different window sizes.
Refer to caption
Figure 2: We present ECG samples generated by our proposed CardioGAN. We show 22 different samples from each dataset to better demonstrate the qualitative performance of our method.

5.2 Qualitative Results

In Figure 2 we present a number of samples of ECG signals generated by CardioGAN, clearly showing that our proposed network is able to learn to reconstruct the shape of the original ECG signals from corresponding PPG inputs. Careful observation shows that in some cases, the generated ECG signals exhibit a small time lag with respect to the original ECG signals. The root cause of this time delay is the Pulse Arrival Time (PAT), which is defined as the time taken by the PPG pulse to travel from the heart to a distal site (from where PPG is collected, for example, wrist, fingertip, ear, or others) (Elgendi et al. 2019). Nonetheless, this time-lag is consistent for all the beats across a single generated ECG signal as a simple offset, and therefore does not impact HR measurements or other cardiovascular-related metrics. This is further evidenced by the accurate HR measurements presented earlier in Tables 1 and 2.

5.3 Ablation Study

The proposed CardioGAN consists of attention-based generators and dual discriminators, as discussed earlier. In order to investigate the usefulness of the attention mechanisms and dual discriminators, we perform an ablation study of 22 variations of the network by removing each of these components individually. To evaluate these components, we perform the same MAEHRMAE_{HR} along with a number of other metrics to quantify the quality of ECG waveforms. We use metrics similar to those used in (Zhu et al. 2019a), which are Root Mean Squared Error (RMSE), Percentage Root Mean Squared Difference (PRD), and Fréchet Distance (FD). We briefly defined these metrics as follows:

RMSE: In order to understand the stability between EE and EE^{\prime}, we calculate RMSE=1Ni=1N(EiEi)2RMSE=\sqrt{{\frac{1}{N}}\sum_{i=1}^{N}(E_{i}-E^{\prime}_{i})^{2}} where EiE_{i} and EiE^{\prime}_{i} refer to the ithi^{th} point of EE and EE^{\prime} respectively.

PRD: To quantify the distortion between EE and EE^{\prime}, we calculate PRD=i=1N(EiEi)2i=1N(Ei)2×100PRD=\sqrt{\frac{\sum_{i=1}^{N}(E_{i}-E^{\prime}_{i})^{2}}{\sum_{i=1}^{N}(E_{i})^{2}}\times 100}.

FD: Fréchet distance (Alt and Godau 1995) is calculated to measure the similarity between the EE and EE^{\prime}. While calculating the distance between two curves, this distance considers the location and order of the data points, hence, giving a more accurate measure of similarity between two time-series signals. Let’s assume EE, a discrete signal, can be expressed as a sequence of {e1,e2,e3,,eN}\{e_{1},e_{2},e_{3},\dots,e_{N}\}, and similarly EE^{\prime} can be expressed as {e1,e2,e3,,eN}\{e^{\prime}_{1},e^{\prime}_{2},e^{\prime}_{3},\dots,e^{\prime}_{N}\}. We can create a 22-D matrix MM of corresponding data points by preserving the order of sequence EE and EE^{\prime}, where M{(e,e)|eE,eE}M\subseteq\{(e,e^{\prime})|e\in E,e^{\prime}\in E^{\prime}\}. The discrete Fréchet distance of EE and EE^{\prime} is calculated as FD=minMmax(e,e)Md(e,e)FD=\min_{M}\max_{(e,e^{\prime})\in M}d(e,e^{\prime}), where d(e,e)d(e,e^{\prime}) denotes the Euclidean distance between corresponding samples of ee and ee^{\prime}.

The results of our ablation study are presented in Table 3. We present the performance of different variants of CardioGAN for all the subjects across all 44 datasets. CardioGAN w/o DD is the variant with only the time domain discriminator and no change in the generator architecture. CardioGAN w/o attn is the variant where the generator does not contain an attention mechanism. The results presented in the table evidently show the benefit of using the proposed CardioGAN over it’s ablation variants.

Method RMSE PRD FD MAEHRMAE_{HR}
CardioGAN w/o DD 0.3960.396 8.7428.742 0.7170.717 9.579.57
CardioGAN w/o Attn 0.3860.386 8.3938.393 0.7730.773 9.679.67
CardioGAN (proposed) 0.364 8.356 0.694 4.77
Table 3: Performance comparison of CardioGAN and it’s ablation variations across all the subjects of the 44 datasets are presented.

5.4 Analysis

Attention Map

In order to better understand what has been learned through the attention mechanism in the generators, we visualize the attention maps applied to the very last skip connection of the generator (GEG_{E}). We choose the attention applied to the last skip connection since this layer is the closest to the final output and there more interpretable. For better visualization, we superimpose the attention map on top of the output of the generator as shown in Figure 3. This shows that our model learns to generally focus on the PQRST complexes, which in turn helps the generator to learn the shapes of ECG waveform better as evident from qualitative and quantitative results presented earlier.

Refer to caption
Figure 3: Visualization of attention maps are presented where the brighter parts indicate regions to which the generator pays more attention compared to the darker regions. We present 44 samples of generated ECG segments corresponding to different subjects.

Unpaired Training vs. Paired Training

We further investigate the performance of CardioGAN while training with paired ECG-PPG inputs as opposed to our original approach which is based on unpaired training. To train CardioGAN in a paired manner, we follow the same training process mentioned in Section 4.4, except we keep the coupling between the ECG and PPG pairs intact in the input data. The results are presented in Table 4, and a few samples of generated ECG are shown in Figure 4. By comparing these results to those presented in Table 4, we observe that unpaired training of CardioGAN shows superior performance compared to paired training. In particular, we notice that while CardioGAN-Paired does learns well to generate ECG beats from PPG inputs, it fails to learn the exact shape of the original ECG waveforms. This might be because an unpaired training scheme forces the network to learn stronger user-independent mappings between PPG and ECG, compared to user-dependant paired training. While it can be argued that utilizing paired data using other GAN architectures might perform well, it should be noted that the goal of this experiment is to evaluate the performance when paired training is performed without any fundamental changes to the architecture. We design CardioGAN with the aim of being able to leverage datasets that do not necessarily contain both ECG and PPG, hence, unpaired training, even though we resort to datasets that do contain both (ECG and PPG) so that ground-truth measurements can be used for evaluation purposes.

Table 4: The results obtained from CardioGAN-Paired are presented.
Method RMSE PRD FD MAEHRMAE_{HR}
CardioGAN-Paired 0.4370.437 9.3159.315 0.7480.748 5.045.04
Refer to caption
Figure 4: Samples obtained from paired training of CardioGAN are presented.
Refer to caption
Figure 5: Few failed ECG examples generated by CardioGAN are presented.

Failed Cases

We notice there are instances where CardioGan fails to generate ECG samples that resemble the original ECG data very closely. Such cases arise only when the PPG input signals are of very poor quality. We show a few examples in Figure 5 where for highly noisy PPG inputs, the generated ECG samples also exhibit very low quality.

5.5 Potential Applications and Demonstration

Apart from the interest to the AI community, we believe our proposed solution has the potential to make a larger impact in the healthcare and wearable domains, notably for continuous health monitoring. Monitoring cardiac activity is an essential part of continuous health monitoring systems, which could enable early diagnosis of cardiovascular diseases, and in turn, early preventative measures that can lead to overcoming severe cardiac problems. Nonetheless, as discussed earlier, there are no suitable solutions for every-day continuous ECG monitoring. In this study we bridge this gap by utilizing PPG signals (which can be easily collected from almost every wearable devices available in the market) in our proposed CardioGAN to capture the cardiac information of users and generate accurate ECG signals. We perform a multi-corpus subject-independent study, where the subjects have gone through a wide range of activities including daily-life tasks, which assures us of the usability of our proposed solution in practical settings. Most importantly, our proposed solution can be integrated into an existing PPG-based wearable device to extract ECG data without any required additional hardware. To demonstrate this concept, we have implemented our model to perform in real-time and used a wrist-based wearable device to feed it with PPG data. The video222https://youtu.be/z0Dr4k24t7U presented as supplementary material demonstrates CardioGAN producing realistic ECG from wearable PPG in real-time.

6 Summary and Future Work

In this paper, we propose CardioGAN, a solution for generating ECG signals from input PPG signals to aid with continuous and reliable cardiac monitoring. Our proposed method takes 44-second PPG segments and generates corresponding ECG segments of equal length. Self-gated soft-attention is used in the generator to learn important regions, for example the QRS complexes of ECG waveforms. Moreover, a dual discriminator strategy is used to learn the mapping in both time and frequency domains. Further, we evaluate the merits of the generated ECG by calculating HR and comparing the results to HR obtained from the real PPG. The analysis shows a clear advantage of using CardioGAN as more accurate HR values are obtained as a result of using the model.

For future work, the advantages of using the generated ECG data in other areas where the use of PPG is limited may be evaluated. These areas include identification of cardiovascular diseases, detection of abnormal heart rhythms, and others. Furthermore, generating multi-lead ECG can also be studied in order to extract more useful cardiac information often missing in single-channel ECG recordings. Finally, we hope our research can open a new path towards cross-modality signal-to-signal translation in the biosignal domain, allowing for less available physiological recording to be generated from more affordable and readily available signals.

References

  • Alt and Godau (1995) Alt, H.; and Godau, M. 1995. Computing the Fréchet distance between two polygonal curves. International Journal of Computational Geometry & Applications 5(01n02): 75–91.
  • Ashley and Niebauer (2004) Ashley, E.; and Niebauer, J. 2004. Conquering the ECG. London: Remedica.
  • Bent et al. (2020) Bent, B.; Goldstein, B. A.; Kibbe, W. A.; and Dunn, J. P. 2020. Investigating sources of inaccuracy in wearable optical heart rate sensors. NPJ Digital Medicine 3(1): 1–9.
  • Chen et al. (2019) Chen, G.; Zhu, Y.; Hong, Z.; and Yang, Z. 2019. EmotionalGAN: Generating ECG to Enhance Emotion State Classification. In Proceedings of the International Conference on Artificial Intelligence and Computer Science, 309–313.
  • Elgendi et al. (2019) Elgendi, M.; Fletcher, R.; Liang, Y.; Howard, N.; Lovell, N. H.; Abbott, D.; Lim, K.; and Ward, R. 2019. The use of photoplethysmography for assessing hypertension. NPJ Digital Medicine 2(1): 1–11.
  • Elgendi et al. (2013) Elgendi, M.; Norton, I.; Brearley, M.; Abbott, D.; and Schuurmans, D. 2013. Systolic peak detection in acceleration photoplethysmograms measured from emergency responders in tropical conditions. PLoS One 8(10): e76585.
  • Fleming et al. (2007) Fleming, S. G.; et al. 2007. A comparison of signal processing techniques for the extraction of breathing rate from the photoplethysmogram. International Journal of Biological and Medical Sciences 2(4): 232–236.
  • Gil et al. (2010) Gil, E.; Orini, M.; Bailon, R.; Vergara, J. M.; Mainardi, L.; and Laguna, P. 2010. Photoplethysmography pulse rate variability as a surrogate measurement of heart rate variability during non-stationary conditions. Physiological Measurement 31(9): 1271.
  • Golany et al. (2020) Golany, T.; Lavee, G.; Yarden, S. T.; and Radinsky, K. 2020. Improving ECG Classification Using Generative Adversarial Networks. In Proceedings of the AAAI Conference on Artificial Intelligence, 13280–13285.
  • Golany and Radinsky (2019) Golany, T.; and Radinsky, K. 2019. PGANs: Personalized generative adversarial networks for ECG synthesis to improve patient-specific deep ECG classification. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, 557–564.
  • Goodfellow et al. (2014) Goodfellow, I.; Pouget-Abadie, J.; Mirza, M.; Xu, B.; Warde-Farley, D.; Ozair, S.; Courville, A.; and Bengio, Y. 2014. Generative adversarial nets. In Advances in Neural Information Processing Systems, 2672–2680.
  • Hamilton (2002) Hamilton, P. 2002. Open source ECG analysis. In Computers in Cardiology, 101–104. IEEE.
  • Hannun et al. (2019) Hannun, A. Y.; Rajpurkar, P.; Haghpanahi, M.; Tison, G. H.; Bourn, C.; Turakhia, M. P.; and Ng, A. Y. 2019. Cardiologist-level arrhythmia detection and classification in ambulatory electrocardiograms using a deep neural network. Nature Medicine 25(1): 65.
  • Jetley et al. (2018) Jetley, S.; Lord, N. A.; Lee, N.; and Torr, P. 2018. Learn to Pay Attention. In International Conference on Learning Representations.
  • Karlen et al. (2013) Karlen, W.; Raman, S.; Ansermino, J. M.; and Dumont, G. A. 2013. Multiparameter respiratory rate estimation from the photoplethysmogram. IEEE Transactions on Biomedical Engineering 60(7): 1946–1953.
  • McSharry et al. (2003) McSharry, P. E.; Clifford, G. D.; Tarassenko, L.; and Smith, L. A. 2003. A dynamical model for generating synthetic electrocardiogram signals. IEEE Transactions on Biomedical Engineering 50(3): 289–294.
  • Nguyen et al. (2017) Nguyen, T.; Le, T.; Vu, H.; and Phung, D. 2017. Dual discriminator generative adversarial nets. In Advances in Neural Information Processing Systems, 2670–2680.
  • Nilsson et al. (2005) Nilsson, L.; et al. 2005. Respiration can be monitored by photoplethysmography with high sensitivity and specificity regardless of anaesthesia and ventilatory mode. Acta Anaesthesiologica Scandinavica 49(8): 1157–1162.
  • Oktay et al. (2018) Oktay, O.; Schlemper, J.; Folgoc, L. L.; Lee, M.; Heinrich, M.; Misawa, K.; Mori, K.; McDonagh, S.; Hammerla, N. Y.; Kainz, B.; et al. 2018. Attention u-net: Learning where to look for the pancreas. arXiv preprint arXiv:1804.03999 .
  • Penttilä et al. (2001) Penttilä, J.; Helminen, A.; Jartti, T.; Kuusela, T.; Huikuri, H. V.; Tulppo, M. P.; Coffeng, R.; and Scheinin, H. 2001. Time domain, geometrical and frequency domain analysis of cardiac vagal outflow: effects of various respiratory patterns. Clinical Physiology 21(3): 365–376.
  • Pimentel et al. (2016) Pimentel, M. A.; Johnson, A. E.; Charlton, P. H.; Birrenkott, D.; Watkinson, P. J.; Tarassenko, L.; and Clifton, D. A. 2016. Toward a robust estimation of respiratory rate from pulse oximeters. IEEE Transactions on Biomedical Engineering 64(8): 1914–1923.
  • Reiss et al. (2019) Reiss, A.; Indlekofer, I.; Schmidt, P.; and Van Laerhoven, K. 2019. Deep PPG: large-scale heart rate estimation with convolutional neural networks. Sensors 19(14): 3079.
  • Ross et al. (2019) Ross, K.; Sarkar, P.; Rodenburg, D.; Ruberto, A.; Hungler, P.; Szulewski, A.; Howes, D.; and Etemad, A. 2019. Toward Dynamically Adaptive Simulation: Multimodal Classification of User Expertise Using Wearable Devices. Sensors 19(19): 4270.
  • Sarkar and Etemad (2020a) Sarkar, P.; and Etemad, A. 2020a. Self-supervised ECG Representation Learning for Emotion Recognition. IEEE Transactions on Affective Computing 1–1.
  • Sarkar and Etemad (2020b) Sarkar, P.; and Etemad, A. 2020b. Self-Supervised Learning for ECG-Based Emotion Recognition. In IEEE International Conference on Acoustics, Speech and Signal Processing, 3217–3221.
  • Sarkar et al. (2019) Sarkar, P.; Ross, K.; Ruberto, A. J.; Rodenbura, D.; Hungler, P.; and Etemad, A. 2019. Classification of Cognitive Load and Expertise for Adaptive Simulation using Deep Multitask Learning. In IEEE International Conference on Affective Computing and Intelligent Interaction, 1–7.
  • Sayadi, Shamsollahi, and Clifford (2010) Sayadi, O.; Shamsollahi, M. B.; and Clifford, G. D. 2010. Synthetic ECG generation and Bayesian filtering using a Gaussian wave-based dynamical model. Physiological Measurement 31(10): 1309.
  • Schäck et al. (2017) Schäck, T.; et al. 2017. Computationally efficient heart rate estimation during physical exercise using photoplethysmographic signals. In European Signal Processing Conference, 2478–2481.
  • Schäfer and Vagedes (2013) Schäfer, A.; and Vagedes, J. 2013. How accurate is pulse rate variability as an estimate of heart rate variability?: A review on studies comparing photoplethysmographic technology with an electrocardiogram. International Journal of Cardiology 166(1): 15–29.
  • Schmidt et al. (2018) Schmidt, P.; Reiss, A.; Duerichen, R.; Marberger, C.; and Van Laerhoven, K. 2018. Introducing wesad, a multimodal dataset for wearable stress and affect detection. In Proceedings of the International Conference on Multimodal Interaction, 400–408.
  • Shelley et al. (2006) Shelley, K. H.; Awad, A. A.; Stout, R. G.; and Silverman, D. G. 2006. The use of joint time frequency analysis to quantify the effect of ventilation on the pulse oximeter waveform. Journal of Clinical Monitoring and Computing 20(2): 81–87.
  • WHO (2017) WHO. 2017. Cardiovascular Diseases. https://www.who.int/news-room/fact-sheets/detail/cardiovascular-diseases-(cvds). (Accessed on 07/10/2020).
  • Zhang, Zhou, and Zeng (2017) Zhang, Q.; Zhou, D.; and Zeng, X. 2017. HeartID: A Multiresolution Convolutional Neural Network for ECG-Based Biometric Human Identification in Smart Health Applications. IEEE Access 5: 11805–11816.
  • Zhu et al. (2019a) Zhu, F.; Ye, F.; Fu, Y.; Liu, Q.; and Shen, B. 2019a. Electrocardiogram generation with a bidirectional LSTM-CNN generative adversarial network. Scientific Reports 9(1): 1–11.
  • Zhu et al. (2017) Zhu, J.-Y.; Park, T.; Isola, P.; and Efros, A. A. 2017. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE International Conference on Computer Vision, 2223–2232.
  • Zhu et al. (2019b) Zhu, Q.; Tian, X.; Wong, C.-W.; and Wu, M. 2019b. Learning Your Heart Actions From Pulse: ECG Waveform Reconstruction From PPG. bioRxiv 815258.