Synthesizing Electrocardiogram (ECG) from Photoplethysmogram(PPG) using Generative Adversarial Networks
Note: I hereby declare that I do not own the rights to any of the images or information used in generating this story. All rights belong to the owner. No Copyright Infringement Intended. All resources were strictly used for educational purposes only.
Image source: USCF Health
What is all about the prominence of Electrocardiogram(ECG) and Photoplethysmogram(PPG) in the health sector?
Electrocardiogram commonly known as ECG is an electrical procedure that captures the activity of a functioning heart. It is used to measure the heart rate(HR), any damage caused by the effects of drugs, and also the size & position of chambers.
Next in line comes the Photoplethysmogram(PPG) technique which can measure only the blood volume changes under the skin. There are many industry-standard wearable devices that can record and capture the PPG information because of their low-cost and simple application but bringing ECG to everyday wearable devices for continuous monitoring is still a challenge.
Image source: polar.com
What’s all about CardioGAN?
To address the above-mentioned problem of unavailability of enough ECG monitoring devices in the market, Pritam Sarkar and Ali Atemad from Queen’s University, Kingston, Canada proposed a deep learning approach(Link here)that is basically an adversarial model which can take PPG as input and generate equivalent ECG signals.
They saw great potential in this experiment as it can bring down the cost and complexity of ECG monitoring in the field of medicine if successful.
To carry out this experiment, they have used the CycleGAN architecture to train in an unpaired manner and incorporated attention-based generators along with dual discriminators so that the network learns to focus better on the significant parts of the waveforms rather than on everything. They called this model CardioGAN.
Now there are a lot of new terms we came across, didn’t we? CycleGAN, generators, discriminators, attention, etc. Let’s look at what each of them means briefly.
What is a CycleGAN structure?
Commonly used in image-to-image translation, CycleGAN is a type of GAN structure that is used for generating synthetic images from a given image. The input for this network requires a large corpus of images that need not be paired, unlike the general GAN networks. The model is trained in an unsupervised fashion for image-to-image translation.
Image source: Hadrickbansal
Attention mechanism in deep neural networks
We have always known the fact that neural networks try to mimic the cognitive abilities of a human brain. Just like us, a neural network tries to remember what’s important to learn from given data and which weights to ignore. This mechanism is simply called attention.
Attention mechanism came as a solution to the drawbacks possessed by the Seq2Seq models in deep learning which included complications in the “context vector” that is generated in the encoder-decoder context.
Now that we have looked into the details, let’s look into the proposed architecture:
- Dataset collection and Preparation:
- Four datasets were used for this purpose namely BIDMC, CAPNO, DALIA, and WESAD. All the ECG-PPG data were combined to form a large multi-corpus.
- Each of these datasets had a different number of attributes, patient information and variable sampling, and recording lengths.
- All the combined corpus of data was resampled using an interpolation technique where the sampling rate for all ECG-PPG records became 128 Hz.
- As a next step, a bandpass FIR-filter, as well as Butter worth filter, were applied to the PPG signals.
- Then, Z-score normalization was performed on both the ECG and PPG data.
- This normalized data is split into intervals of 4 seconds each with some degree of overlapping to avoid losing any data.
- Finally, a min-max normalization was applied to ensure that the input being to the network all lie within the same range.
- As a generator, an Attention-based U-Net was used with self-gated soft attention in usage to filter those features that pass through skip connections.
- Dual discriminators were used to classifying the time and frequency components of a PPG signal correctly from the fake data.
- CardioGAN was then trained in an unpaired fashion where ECG and PPG signals were shuffled and were given as input to the network with a batch size of 128.
- With adam optimizer in action, the model has shown improvement with increased batch size and training time.
Performance and Results
- CardioGAN produced generated ECG and generated PPG signals as the main outputs.
- Considering our end goal to generate the best ECG signal from the PPG signal, qualitative and quantitative results have been analyzed to put forward a conclusion.
- It was understood that the Heart rate measure from generated output was more precise than the original ECG signal itself.
- CardioGAN was able to generate the shape of the original ECG signal from a given PPG signal.
Image source: CardioGAN: Attentive Generative Adversarial Network with Dual Discriminators for Synthesis of ECG from PPG, “Pritam Sarkar”,” Ali Etemad”
Conclusion and critique of the paper
The overall quality of the paper: The idea proposed in the paper is pretty straightforward. Details about CardioGAN were well described but there could have been more graphical representations of the GAN and generator structures used to explain the inputs and outputs of the network.
Also, the interpretation of the results has been clear but the paper didn’t throw enough light on the failed cases i.e. on those few instances where the CardioGAN failed to generate ECG signals in close reference to the PPG.
Critique of the paper: The drawbacks of giving low-quality PPG signals as input to the network have not been discussed in detail.
Future directions and suggestions: Apart from the AI community, this experiment has the potential to create an impact on the medical field in a positive way. Regular monitoring of cardiac activity is very important and is often neglected due to human negligence, busy life schedules, or even due to a lack of sufficient resources. A low-cost solution is of utmost necessity in such a scenario whether in the form of wearable devices or compact devices.
This model can be integrated with any wearable device like a wristwatch to put it to real-time use to test its authenticity and reliability. With proper refinement and reduced noise in the generated signal strengths, this low-cost experiment can not only be path-breaking but also noble.