Skip to content

Commit 8b0b55d

Browse files
committed
Major refactorings, plotting notebooks, license change
1 parent 7103022 commit 8b0b55d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2676
-1442
lines changed

LICENSE

Lines changed: 21 additions & 661 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
# Generating realistic neurophysiological time series with denoising diffusion probabilistic models
22

3-
This repository contains research code for the preprint [Generating realistic neurophysiological time series with denoising diffusion probabilistic models](https://www.biorxiv.org/content/10.1101/2023.08.23.554148v1).
3+
Code for [Generating realistic neurophysiological time series with denoising diffusion probabilistic models](https://www.biorxiv.org/content/10.1101/2023.08.23.554148v1).
44

5-
It contains all the scripts to run the experiments presented in the paper.
6-
To run the experiments, first download the datasets (links in the paper) and change the `filepath` parameter in the dataset configuration files in `conf/dataset`. To save all outputs locally, set the `save_path` parameter in `conf/base` to the desired location. Experiment tracking and saving with [Weights & Biases](https://wandb.ai/site) is also supported, but disabled by default.
5+
The repository contains all the scripts to run the experiments presented in the paper.
6+
To run the experiments, first download the datasets (links in the paper) and change the `filepath` parameter in the dataset configuration files in `conf/dataset`. To save all outputs locally, set the `save_path` parameter in `conf/base` to the desired location.
7+
8+
Experiment tracking and saving with [Weights & Biases](https://wandb.ai/site) is also supported, but disabled by default.
79
Finally, use the shell scripts provided in `scripts` to run the experiments!
810

911
Additionally, an example jupyter notebook `example_ner_notebook.ipynb`, where a diffusion model is trained to generate the BCI Challenge @ NER 2015 data, is provided together with the data.
1012

11-
Coming soon: Notebooks for plotting the figures!
12-
13-
14-
## Usage
15-
16-
Install dependencies:
13+
## Installation
14+
Install dependencies via pip:
1715
```shell
1816
git clone https://github.com/mackelab/neural_timeseries_diffusion.git
1917
cd neural_timeseries_diffusion
2018
pip install -e .
2119
```
2220

23-
Run shell scripts:
21+
## Further information
22+
23+
#### How can apply the DDPM to my datasets?
24+
This requires writing a dataloader for your dataset. Example dataloaders (for all the datasets used in paper) can be found in
25+
`datasets.py`.
26+
27+
#### What options do I have for the denoiser architectures?
28+
Two denoiser different denoiser architectures based on [structrured convolutions](https://arxiv.org/abs/2210.09298) are provided, which only differ in the way conditional information is passed to the network.
29+
30+
In general, the architecture using adaptive layer norm (`AdaConv`) is preferable and a good first choice over the one where conitional information is just concatenated (`CatConv`) (see [this paper](https://arxiv.org/abs/2212.09748) for a comparison of both approaches for an image diffusion model).
31+
32+
#### White noise vs. OU process
33+
The standard white noise is a good initial choice. However, using the OU process can improve the quality of the generated power spectra. This requires setting the length scale of the OU process as an additional hyperparameter in the `diffusion_kernel` config files.
34+
35+
## Running the experiments
36+
After downloading the datasets and updating the file paths, run the experiment shell scripts:
2437
```shell
2538
cd scripts
2639
./<name_of_script>.sh
2740
```
28-
29-
Run the example jupyter notebook:
30-
- Make sure that the `jupyter` package is installed
31-
- Open and execute the notebook
32-
33-
41+
This produces result files, which can then be passed to the plotting notebooks.

conf/base/wandb_default.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ run_experiment: True
66
use_cuda_if_available: True
77

88
wandb_mode: disabled
9-
wandb_project: time_series_diffusion
9+
wandb_project: TODO
1010
wandb_entity: TODO
1111
home_path: "TODO" # wandb home path
12-
save_path: null # Local saving
12+
save_path: null # local saving

conf/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defaults:
22
- base: wandb_default
33
- dataset: ner
4-
- network: lconv_ner
4+
- network: ada_conv_ner
55
- diffusion_kernel: white_noise
66
- diffusion: diffusion_linear_200
77
- optimizer: base_optimizer

conf/dataset/ner.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ self: ner
22
filepath: "../data"
33
patient_id: "S02"
44
signal_length: 260
5-
with_time_emb: True
6-
cond_time_dim: 32
75
train_test_split: 1.0
86
split_seed: 0

conf/diffusion/diffusion_cosine_500.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# @package _global_
22
swr_prediction_experiment:
3-
channel: 0 # can be integer or list of integers
3+
channel: 0
44
batch_size: 1000

conf/network/ada_conv_ajile.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
self: ada_conv
2+
signal_channel: 64 # only for P07
3+
cond_dim: 128 # only for P07
4+
hidden_channel: 8
5+
in_kernel_size: 53
6+
out_kernel_size: 53
7+
slconv_kernel_size: 53
8+
num_scales: 4
9+
num_blocks: 3
10+
num_off_diag: 8
11+
padding_mode: circular
12+
use_fft_conv: False
13+
use_pos_emb: False

conf/network/ada_conv_crcns.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
self: ada_conv
2+
signal_channel: 3
3+
cond_dim: 0
4+
hidden_channel: 64
5+
in_kernel_size: 64
6+
out_kernel_size: 64
7+
slconv_kernel_size: 64
8+
num_scales: 5
9+
num_blocks: 4
10+
num_off_diag: 64
11+
padding_mode: circular
12+
use_fft_conv: False
13+
use_pos_emb: False

conf/network/ada_conv_ner.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
self: ada_conv
2+
signal_channel: 56
3+
cond_dim: 0
4+
hidden_channel: 8
5+
in_kernel_size: 65
6+
out_kernel_size: 65
7+
slconv_kernel_size: 65
8+
num_scales: 1
9+
num_blocks: 3
10+
num_off_diag: 8
11+
padding_mode: circular
12+
use_fft_conv: False
13+
use_pos_emb: True

0 commit comments

Comments
 (0)