Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.6%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: imics-lab
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 34.5 MB
Statistics
  • Stars: 23
  • Watchers: 2
  • Forks: 3
  • Open Issues: 1
  • Releases: 0
Created over 2 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Citation

README.md

BioDiffusion: A Versatile Diffusion Model for Biomedical Signal Synthesis

Description

This repository serves as the primary codebase for implementing a Diffusion model, specifically designed for the generation of synthetic signals. The model is a pivotal component used in the research paper titled "BioDiffusion: A Versatile Diffusion Model for Biomedical Signal Synthesis" (accessible here).

Setup

Before running the code, ensure that you have the following prerequisites installed:

  • Python 3.x
  • PyTorch
  • Nvidia CUDA toolkit and cuDNN (for GPU acceleration)

bash pip install torch torchvision conda install cudatoolkit

Conda Virtual Environment

Create the Conda virtual environment using the environment file: ```bash conda env create -f environment.yml

dynamically set python path for the environment

conda activate BioDiffusion conda env config vars set PYTHONPATH=$(pwd):$(pwd)/src ```

Training

In order to use our model first you will need to retrain it:

Unconditional diffusion model for 3 channel data:

python ddpm.py

Conditional diffusion model for 3 channel data:

python ddpm_conditional.py

Classifier-free diffusion model for 1 channel data:

cd signal/ python load_dataset.py #KaggleKey #KaggleName python ddpm1d_cls_free.py

Signal conditional diffusion model for 1 channel data:

cd signal/ python load_dataset.py #KaggleKey #KaggleName python ddpm1d_sign_cond.py

Sampling

After training, you can sample from the trained model using the following steps:

Unconditional Diffusion Model for 3 Channel Data:

```python

Set device and load the pre-trained UNet model

device = "cuda:2" model = UNet().to(device) ckpt = torch.load("../../src/models/DDPMUnconditional/ckpt.pt") model.loadstate_dict(ckpt)

Create a Diffusion model instance and sample from it

diffusion = Diffusion(img_size=32, device=device) x = diffusion.sample(model, 10) ```

Conditional Diffusion Model for 3 Channel Data:

```python

Set the number of samples and device

n = 10 device = "cuda:3"

Create a Diffusion model instance and load the trained model checkpoint

diffusion = Diffusion(imgsize=32, device=device) diffusion.load("../../src/models/DDPMconditional")

Prepare labels and sample from the diffusion model

labels = torch.full((n,), 1).long().to(diffusion.device) sampledimages = diffusion.sample(useema=False, labels=labels) ```

Classifier-Free Diffusion Model for 1 Channel Data:

```python

Set the number of samples, device, and create the Unet1Dclsfree model

n = 10 device = "cuda:3" model = Unet1Dclsfree( dim=64, dimmults=(1, 2, 4, 8), numclasses=5, conddropprob=0.5, channels=1 )

Load the pre-trained model checkpoint

ckpt = torch.load("../../src/signal/checkpoint/DDPM1DclsfreeMITBIH/checkpoint.pt") model.loadstatedict(ckpt['modelstate_dict']) model = model.to(device)

Create the GaussianDiffusion1Dclsfree model and sample from it

diffusion = GaussianDiffusion1Dclsfree( model, seqlength=128, timesteps=1000 ).to(device) y = torch.Tensor([0] * n).long().to(device) x = diffusion.sample(classes=y, condscale=3.) ```

Self-Conditional Diffusion Model for 1 Channel Data:

```python

Set the device and create the Unet1D model with self-conditioning

device = "cuda:3" model = Unet1D( dim=64, selfcondition=True, dimmults=(1, 2, 4, 8), channels=1 )

Load the pre-trained model checkpoint

ckpt = torch.load("../../src/signal/checkpoint/DDPM1DSelfconditionalmaskedCond/checkpoint.pt") model.loadstatedict(ckpt['modelstatedict']) model = model.to(device)

Create the GaussianDiffusion1D model and sample from it

seqlength must be able to be divided by dimmults

diffusion = GaussianDiffusion1D( model, seqlength=128, timesteps=1000, objective='predv' ).to(device) ```

Make sure to adjust the file paths and model names as needed.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Citation

Feel free to cite our paper using this .bibtex or .cff formats in this repository.

bibtex @misc{li2024biodiffusion, title={BioDiffusion: A Versatile Diffusion Model for Biomedical Signal Synthesis}, author={Xiaomin Li and Mykhailo Sakevych and Gentry Atkinson and Vangelis Metsis}, year={2024}, eprint={2401.10282}, archivePrefix={arXiv}, primaryClass={eess.SP} }

Owner

  • Name: Intelligent Multimodal Computing and Sensing Laboratory (IMICS Lab) - Texas State University
  • Login: imics-lab
  • Kind: organization
  • Location: United States of America

This is the public GitHub page of the Intelligent Multimodal Computing and Sensing Laboratory (IMICS Lab)

Citation (CITATION.cff)


# See GiHub's Doc on citation files: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

# Below is the citation for this template repository. Replace it with your own!

### REPLACE ME >>>

cff-version: 1.2.0
title: >-
  Research Project Template
message: >-
  If you find this project or code useful, please consider citing it as below!
type: software
authors:
  - given-names: Ellis L
    family-names: Brown
    name-suffix: II
    email: ellisbrown@cmu.edu
    affiliation: Carnegie Mellon University 
    orcid: 'https://orcid.org/0000-0002-8117-0778 '

### REPLACE ME <<<

GitHub Events

Total
  • Watch event: 8
  • Fork event: 3
Last Year
  • Watch event: 8
  • Fork event: 3

Issues and Pull Requests

Last synced: about 2 years ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • chuzheng88 (1)
  • OmegaAsh (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/conda-test.yml actions
  • actions/cache v2 composite
  • actions/checkout v3 composite
  • conda-incubator/setup-miniconda v2 composite
environment.yml pypi