Giter Club home page Giter Club logo

fecg_cgan's Introduction

Fetal ECG Extraction on Time-Frequency Domain using Pix2Pix GAN

This repository contains code and data for implementing a method to extract fetal electrocardiogram (ECG) signals from a maternal ECG signal on the time-frequency domain using Pix2Pix GAN.

1 Background

Fetal ECG extraction from maternal ECG signals is important in clinical settings, as it can provide crucial information about fetal health. However, fetal ECG signals are typically much weaker than maternal ECG signals, making it challenging to extract them directly from the raw signal.

2 Method

In this repository, we present a method for fetal ECG extraction on the time-frequency domain using Pix2Pix GAN. We train Pix2Pix to learn the mapping between maternal ECG spectrograms (domain A) and corresponding fetal ECG spectrograms (domain B). During testing, we apply the trained Pix2Pix to a maternal ECG spectrogram to obtain the corresponding fetal ECG spectrogram.

3 Running instructions

3.1 Getting started

Create virtual environment

First, create a virtual environment for the repository

conda create -n fecg python=3.8

then activate the environment

conda activate fecg

Clone the repository

Download or clone the repository:

git clone https://github.com/dustin-nguyen-qil/fECG_cGAN.git

Next, install the dependencies by running ...

pip install -r requirements.txt

Evaluation results

If you want to see the results without retraining the model, refer to evaluate.ipynb to directly see the comparison with conventional method.

If you want to run the code cells again, download the fECG spectrograms produced by conventional method and our proposed model trained with 125 epochs from here. Then unzip and put results folder at the outermost level in the code folder.

results
---> fecg_p2p
    ---> spectrogram_conventional
    ---> test_latest

3.2 Data Preparation

Dataset

  • Download the spectrograms generated from Abdominal and Direct dataset from here.
  • Unzip the data, put into folder data as following
data
---> adbecg
---> ...

Pix2Pix requires to align the data for pairs of training images

$ python datasets/combine_A_and_B.py --fold_A data/adbecg/spectrogram/A --fold_B data/adbecg/spectrogram/A --fold_AB datasets/adbecg

3.3 Training Pix2Pix

Run the following command for training (here I set --n_epochs 5 and --n_epochs_decay 5 to save training time if you only want to validate the training phase works fine)

python train.py --dataroot ./datasets/adbecg --name fecg_p2p --model pix2pix --direction AtoB --n_epochs 5 --n_epochs_decay 5

Training results will be saved in checkpoints. To see more intermediate results, check out ./checkpoints/fecg_p2p/web/index.html

3.3 Testing Pix2Pix

If you have download the results from here, make sure you remove the results folder before running testing.

Run the following command for testing

python test.py --dataroot ./datasets/adbecg --name fecg_p2p --model pix2pix --direction AtoB

The test results will be saved to a html file here: ./results/fecg_p2p/test_latest/index.html.

3.4 Evaluation

After you have run testing, you will see the results folder is automatically created. You can download the fECG spectrograms generated by conventional method from here

Then unzip and put conventional folder in results as following.

results
---> fecg_p2p
    ---> conventional
    ---> test_latest

Acknowledgement

This repository was based on the following repository: Pix2PixGAN. We would like to thank the authors for a contributing work.

fecg_cgan's People

Contributors

adnanegdihi avatar dustin-nguyen-qil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.