Code Monkey home page Code Monkey logo

synthetic-sleep-eeg-signal-generation-using-latent-diffusion-models's Introduction


[DGM4H Workshop@Neurips 2023] Synthetic Sleep EEG Signal Generation using Latent Diffusion-Models

img.png

This repository is the official implementation of the article presented at the event.

Abstract: Electroencephalography (EEG) is a non-invasive method that allows for recording rich temporal information and is a valuable tool for diagnosing various neurological and psychiatric conditions. One of the main limitations of EEG is the low signal-to-noise ratio and the lack of data availability to train large data-hungry neural networks. Sharing large healthcare datasets is crucial to advancing medical imaging research, but privacy concerns often impede such efforts. Deep generative models have gained attention as a way to circumvent data-sharing limitations and as a possible way to generate data to improve the performance of these models. This work investigates latent diffusion models with spectral loss as deep generative modeling to generate 30-second windows of synthetic EEG signals of sleep stages. The spectral loss is essential to guarantee that the generated signal contains structured oscillations on specific frequency bands that are typical of EEG signals. We trained our models using two large sleep datasets (\emph{Sleep EDFx} and \emph{SHHS}) and used the Multi-Scale Structural Similarity Metric, Frechet inception distance, and a spectrogram analysis to evaluate the quality of synthetic signals. We demonstrate that the latent diffusion model can generate realistic signals with the correct neural oscillation and could, therefore, be used to overcome the scarcity of EEG data.

Disclaimer

This repository contains a workshop paper, a reflex of the work in progress. This repository doesn't propose to be a package or a library, but a collection of scripts and notebooks to reproduce the results. The author understands that the code could be in better shape but is a work in progress. The author is open to any suggestions, and the code will be improved in the future.

As discussed in the paper, the spectral loss is unstable, so depending on the dataset, the loss can explode. We used the last model before the loss exploded to compact the representation of the samples.

How to reproduce the results

  1. Clone this repository
git clone https://github.com/bruAristimunha/Synthetic-Sleep-EEG-Signal-Generation-using-Latent-Diffusion-Models
  1. Install Docker following docker installation guide for your OS. (optional)

  2. Run the following command to build the docker image (optional)

bash cluster/create_runai.sh

  1. Training
python src/train_autoencoderkl.py
python src/train_ldm.py 
  1. Generate the samples

You can generate the samples using the script for this.

  1. Evaluation

You can evaluate the metrics using the testing script for this.

License

This work is present as BSD 3-Clause License, so you can't use it for commercial purposes.

Citation

In latex format:

@inproceedings{
aristimunha2023synthetic,
title={{Synthetic Sleep {EEG} Signal Generation using Latent Diffusion Models}},
author={Bruno Aristimunha and Raphael Yokoingawa de Camargo and Sylvain Chevallier and Oeslle Lucena and Adam Thomas and M. Jorge Cardoso and Walter Lopez Pinaya and Jessica Dafflon},
booktitle={Deep Generative Models for Health Workshop NeurIPS 2023},
year={2023},
}

In plain text:

Aristimunha, B., de Camargo, R.Y., Chevallier, S., Thomas, A.G., Lucena, O., Cardoso, J., Pinaya, W.H.L. and Dafflon, J., 2023, December. Synthetic Sleep EEG Signal Generation using Latent Diffusion Models. In NeurIPS 2023 Workshop DGM4H.

synthetic-sleep-eeg-signal-generation-using-latent-diffusion-models's People

Contributors

bruaristimunha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

synthetic-sleep-eeg-signal-generation-using-latent-diffusion-models's Issues

code release

Hi @bruAristimunha, will you release the code soon? We want to use your paper for our hands-on journal club, without code, I can't add it to the list.

Issue running

Hello I am trying to run your code for sample_trials.py however I am getting an error where there is no module named generative.

Question about train_Idm.py

Hello, where is generative.networks generated, I don't see it in the original folder.
from generative.networks.nets import DiffusionModelUNet
from generative.networks.nets import AutoencoderKL
from generative.networks.schedulers import DDPMScheduler

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.