# patched-Diffusion-Models-UAD
Codebase for the paper [Patched Diffusion Models for Unsupervised Anomaly Detection](https://arxiv.org/abs/2303.03758) accepted at MIDL23.
## Graphical abstract
![Graphical abstract](pDDPM_graph_abstract.png)
## Data
We use the IXI data set, the BraTS21 data set and the MSLUB data set for our experiments.
You can download/request the data sets here:
* IXI: https://brain-development.org/ixi-dataset/
* BraTS21: http://braintumorsegmentation.org/
* MSLUB: https://lit.fe.uni-lj.si/en/research/resources/3D-MR-MS/
## Data Preprocessing
# Warning: The Preprocessing is bugged right now and does not represent the steps taken in the paper. A fix will be pushed asap.
Before processing, you need to extract the downloaded zip files and organize them as follows:
├── IXI
│ ├── t2
│ │ ├── IXI1.nii.gz
│ │ ├── IXI2.nii.gz
│ │ └── ...
│ └── ...
├── MSLUB
│ ├── t2
│ │ ├── MSLUB1.nii.gz
│ │ ├── MSLUB2.nii.gz
│ │ └── ...
│ ├── seg
│ │ ├── MSLUB1_seg.nii.gz
│ │ ├── MSLUB2_seg.nii.gz
│ │ └── ...
│ └── ...
├── Brats21
│ ├── t2
│ │ ├── Brats1.nii.gz
│ │ ├── Brats2.nii.gz
│ │ └── ...
│ ├── seg
│ │ ├── Brats1_seg.nii.gz
│ │ ├── Brats2_seg.nii.gz
│ │ └── ...
│ └── ...
└── ...
We apply several preprocessing steps to the data, including resampling to 1.0 mm, skull-stripping with HD-BET, registration to the SRI Atlas, cutting black boarders and N4 Bias correction.
To run the preprocessing, you need to clone and setup the [HD-BET](https://github.com/MIC-DKFZ/HD-BET) tool for skull-stripping.
For each data set there is an individual bash script that performs the preprocessing in the [preprocessing](preprocessing) directory. To preprocess the data, go to the [preprocessing](preprocessing) directory:
cd preprocessing
execute the bash script:
bash prepare_IXI.sh <input_dir> <output_dir>
the <input_dir> refers to the directory where the downloaded, raw data is stored.
Note, that you need to provide absolute paths and this script will use a GPU for skull-stripping.
Example for the IXI data set:
bash prepare_IXI.sh /raw_data/IXI/ $(pwd)
This will create 4 different folders with the results of the intermediate preprocessing steps. The final scans are located in /processed_data/v4correctedN4_non_iso_cut
After preprocessing, place the data (the folder v4correctedN4_non_iso_cut) in your DATA_DIR.
cp -r <output_dir>/IXI <DATA_DIR>/Train/ixi
cp -r <output_dir>/MSLUB <DATA_DIR>/Test/MSLUB
cp -r <output_dir>/Brats21 <DATA_DIR>/Test/Brats21
The directory structure of <DATA_DIR> should look like this:
<DATA_DIR>
├── Train
│ ├── ixi
│ │ ├── mask
│ │ ├── t2
├── Test
│ ├── Brats21
│ │ ├── mask
│ │ ├── t2
│ │ ├── seg
│ ├── MSLUB
│ │ ├── mask
│ │ ├── t2
│ │ ├── seg
├── splits
│ ├── Brats21_test.csv
│ ├── Brats21_val.csv
│ ├── MSLUB_val.csv
│ ├── MSLUB_test.csv
│ ├── IXI_train_fold0.csv
│ ├── IXI_train_fold1.csv
│ └── ...
└── ...
You should then specify the location of <DATA_DIR> in the pc_environment.env file. Additionally, specify the <LOG_DIR>, where runs will be saved.
## Environment Set-up
To download the code type
git clone git@github.com:FinnBehrendt/patched-Diffusion-Models-UAD.git
In your linux terminal and switch directories via
cd patched-Diffusion-Models-UAD
To setup the environment with all required packages and libraries, you need to install anaconda first.
Then, run
conda env create -f environment.yml -n pddpm-uad
and subsequently run
conda activate pddpm-uad
pip install -r requirements.txt
to install all required packages.
## Run Experiments
To run the training and evaluation of the pDDPM, simply execute
python run.py experiment=MIDL23_DDPM/DDPM_patched
in your terminal.
## Citation
If you make use of our work, we would be happy if you cite it via
@article{behrendt2023patched,
title={Patched diffusion models for unsupervised anomaly detection in brain mri},
author={Behrendt, Finn and Bhattacharya, Debayan and Kr{\"u}ger, Julia and Opfer, Roland and Schlaefer, Alexander},
journal={arXiv preprint arXiv:2303.03758},
year={2023}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目致力于基于深度学习扩散模型的医学图像中的无监督异常检测。医学图像中的异常检测对于疾病的早期发现和治疗具有重要意义,而无监督异常检测能够在不依赖人工标注的情况下发现潜在的疾病特征。 我们采用深度学习算法,通过分析医学图像,实现对异常区域的自动识别和分类。项目使用的数据集包括公开的医学图像数据集,如Human Connectome Project、ABIDE等,并进行了预处理,包括图像裁剪、大小调整和归一化等。 在运行环境方面,我们使用Python编程语言,基于TensorFlow、PyTorch等深度学习框架进行开发。为了提高计算效率,我们还使用了GPU加速计算。此外,我们还采用了Docker容器技术,确保实验结果的可重复性。 项目完成后,将实现对医学图像中异常的无监督检测,为疾病的诊断和治疗提供有力支持。同时,项目成果也可应用于其他医学影像分析领域。
资源推荐
资源详情
资源评论
收起资源包目录
基于深度学习扩散模型的医学图像中的无监督异常检测内含数据集和环境搭建说明.zip (140个子文件)
Brats21_test.csv 205KB
IXI_train_fold3.csv 60KB
IXI_train_fold0.csv 60KB
IXI_train_fold2.csv 60KB
IXI_train_fold1.csv 60KB
IXI_train_fold4.csv 60KB
IXI_test.csv 25KB
Brats21_val.csv 18KB
avail_t2.csv 17KB
IXI_val_fold4.csv 7KB
IXI_val_fold1.csv 7KB
IXI_val_fold2.csv 7KB
IXI_val_fold0.csv 7KB
IXI_val_fold3.csv 7KB
MSLUB_test.csv 3KB
MSLUB_val.csv 1KB
pc_environment.env 42B
README.md 5KB
generate_noise._noise2a-367.py39.1.nbc 57KB
generate_noise._noise2-266.py39.1.nbc 54KB
generate_noise._extrapolate2-250.py39.1.nbc 18KB
generate_noise._noise2a-367.py39.nbi 1KB
generate_noise._extrapolate2-250.py39.nbi 1KB
generate_noise._noise2-266.py39.nbi 1KB
T1_brain.nii 17.03MB
T2.nii 17.03MB
T1.nii 17.03MB
EPI_brain.nii 17.03MB
T2_brain.nii 17.03MB
PD.nii 17.03MB
PD_brain.nii 17.03MB
EPI.nii 17.03MB
pDDPM_graph_abstract.png 1.26MB
test.png 431KB
ddpm.py 67KB
ddpm_class.py 67KB
openaimodel.py 34KB
generate_noise.py 33KB
model.py 33KB
utils_eval.py 30KB
utils_image.py 28KB
OpenAI_Unet.py 26KB
bsrgan.py 25KB
cond_DDPM.py 23KB
bsrgan_light.py 22KB
LDM.py 21KB
x_transformer.py 20KB
autoencoder.py 18KB
plms.py 12KB
ddim.py 11KB
DDPM_2D_patched.py 11KB
classifier.py 10KB
train.py 10KB
util.py 9KB
attention.py 9KB
create_dataset.py 9KB
vqperceptual.py 8KB
DDPM_2D.py 8KB
utils.py 8KB
modules.py 7KB
cut.py 6KB
util.py 6KB
contperceptual.py 5KB
taming.py 5KB
registration.py 5KB
patch_sampling.py 4KB
Datamodules_eval.py 4KB
pos_embed.py 4KB
lr_scheduler.py 4KB
Datamodules_train.py 3KB
ema.py 3KB
distributions.py 3KB
n4filter.py 3KB
resample.py 3KB
get_mask.py 2KB
run.py 1KB
replace.py 1KB
extract_masks.py 1KB
__init__.py 230B
__init__.py 79B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
ddpm.cpython-39.pyc 43KB
ddpm.cpython-38.pyc 43KB
openaimodel.cpython-38.pyc 22KB
openaimodel.cpython-39.pyc 22KB
model.cpython-38.pyc 20KB
model.cpython-39.pyc 20KB
x_transformer.cpython-38.pyc 18KB
generate_noise.cpython-39.pyc 18KB
utils_eval.cpython-39.pyc 17KB
autoencoder.cpython-39.pyc 13KB
autoencoder.cpython-38.pyc 13KB
util.cpython-39.pyc 9KB
util.cpython-38.pyc 9KB
共 140 条
- 1
- 2
资源评论
小码蚁.
- 粉丝: 2633
- 资源: 4453
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功