# Diffusion Models for Medical Anomaly Detection
We provide the Pytorch implementation of our MICCAI 2022 submission "Diffusion Models for Medical Anomaly Detection" (paper 704).
The implementation of Denoising Diffusion Probabilistic Models presented in the paper is based on [openai/guided-diffusion](https://github.com/openai/guided-diffusion).
## Data
We evaluated our method on the [BRATS2020 dataset](https://www.med.upenn.edu/cbica/brats2020/data.html), and on the [CheXpert dataset](https://stanfordmlgroup.github.io/competitions/chexpert/).
A mini-example how the data needs to be stored can be found in the folder *data*. To train or evaluate on the desired dataset, set `--dataset brats` or `--dataset chexpert` respectively.
## Usage
We set the flags as follows:
```
MODEL_FLAGS="--image_size 256 --num_channels 128 --class_cond True --num_res_blocks 2 --num_heads 1 --learn_sigma True --use_scale_shift_norm False --attention_resolutions 16"
DIFFUSION_FLAGS="--diffusion_steps 1000 --noise_schedule linear --rescale_learned_sigmas False --rescale_timesteps False"
TRAIN_FLAGS="--lr 1e-4 --batch_size 10"
CLASSIFIER_FLAGS="--image_size 256 --classifier_attention_resolutions 32,16,8 --classifier_depth 4 --classifier_width 32 --classifier_pool attention --classifier_resblock_updown True --classifier_use_scale_shift_norm True"
SAMPLE_FLAGS="--batch_size 1 --num_samples 1 --timestep_respacing ddim1000 --use_ddim True"
```
To train the classification model, run
```
python scripts/classifier_train.py --data_dir path_to_traindata --dataset brats_or_chexpert $TRAIN_FLAGS $CLASSIFIER_FLAGS
```
To train the diffusion model, run
```
python scripts/image_train.py --data_dir --data_dir path_to_traindata --datasaet brats_or_chexpert $MODEL_FLAGS $DIFFUSION_FLAGS $TRAIN_FLAGS
```
The model will be saved in the *results* folder.
For image-to-image translation to a healthy subject on the test set, run
```
python scripts/classifier_sample_known.py --data_dir path_to_testdata --model_path ./results/model.pt --classifier_path ./results/classifier.pt --dataset brats_or_chexpert --classifier_scale 100 --noise_level 500 $MODEL_FLAGS $DIFFUSION_FLAGS $CLASSIFIER_FLAGS $SAMPLE_FLAGS
```
A visualization of the sampling process is done using [Visdom](https://github.com/fossasia/visdom).
## Comparing Methods
### FixedPoint-GAN
We follow the implementation given in this [repo](https://github.com/mahfuzmohammad/Fixed-Point-GAN). We choose λ<sub>cls</sub>=1, λ<sub>gp</sub>=λ<sub>id</sub>=λ<sub>rec</sub>=10, and train our model for 150 epochs. The batch size is set to 10, and the learning rate to 10<sup>-4</sup>.
### VAE
We follow the implementation given in this [repo](https://github.com/aubreychen9012/cAAE) and train the model for 500 epochs. The batch size is set to 10, and the learning rate to 10<sup>-4</sup>.
### DDPM
For sampling using the DDPM approach, run
```
python scripts/classifier_sample_known.py --data_dir path_to_testdata --model_path ./results/model.pt --classifier_path ./results/classifier.pt --dataset brats_or_chexpert --classifier_scale 100 --noise_level 500 $MODEL_FLAGS $DIFFUSION_FLAGS $CLASSIFIER_FLAGS
```
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目聚焦于基于扩散模型的医学脑部MRI异常检测方法,旨在提高脑部疾病的诊断效率和准确性。脑部MRI影像分析在神经疾病的诊断中具有重要意义。 我们采用深度学习中的扩散模型,通过分析脑部MRI影像,实现对异常区域的自动识别和分类。项目使用的数据集包括公开的脑部MRI影像数据集,如ADNI、UK Biobank等,并进行了预处理,包括图像增强、分割和特征提取等。 在运行环境方面,我们使用Python编程语言,基于TensorFlow、PyTorch等深度学习框架进行开发。为了提高模型的性能,我们还使用了数据增强、模型融合等技术。 项目完成后,将实现对医学脑部MRI影像中异常区域的快速、准确检测,为脑部疾病的诊断和治疗提供有力支持。同时,项目成果也可应用于其他医学图像分析领域。
资源推荐
资源详情
资源评论
收起资源包目录
基于扩散模型的医学脑补MRI的异常检测方法.zip (62个子文件)
data
brats
testing
000247
brats_train_006_t1ce_081_w.nii.gz 37KB
brats_train_006_t2_081_w.nii.gz 37KB
brats_train_006_flair_081_w.nii.gz 36KB
brats_train_006_t1_081_w.nii.gz 36KB
000248
brats_train_006_flair_082_w.nii.gz 36KB
brats_train_006_t1_082_w.nii.gz 36KB
brats_train_006_t1ce_082_w.nii.gz 36KB
brats_train_006_t2_082_w.nii.gz 36KB
test_labels
000247-label.nii.gz 3KB
000248-label.nii.gz 3KB
training
000004
brats_train_001_t2_083_w.nii.gz 35KB
brats_train_001_t1_083_w.nii.gz 36KB
brats_train_001_flair_083_w.nii.gz 35KB
brats_train_001_t1ce_083_w.nii.gz 38KB
brats_train_001_seg_083_w.nii.gz 3KB
000003
brats_train_001_seg_082_w.nii.gz 3KB
brats_train_001_t1_082_w.nii.gz 36KB
brats_train_001_flair_082_w.nii.gz 35KB
brats_train_001_t2_082_w.nii.gz 35KB
brats_train_001_t1ce_082_w.nii.gz 38KB
000001
brats_train_001_flair_080_w.nii.gz 36KB
brats_train_001_t2_080_w.nii.gz 35KB
brats_train_001_t1_080_w.nii.gz 36KB
brats_train_001_t1ce_080_w.nii.gz 39KB
brats_train_001_seg_080_w.nii.gz 3KB
000002
brats_train_001_seg_081_w.nii.gz 3KB
brats_train_001_t1_081_w.nii.gz 36KB
brats_train_001_t2_081_w.nii.gz 35KB
brats_train_001_flair_081_w.nii.gz 35KB
brats_train_001_t1ce_081_w.nii.gz 38KB
chexpert
testing
healthy
patient01104_study1.npy 64KB
diseased
patient05883_study2.npy 64KB
training
healthy
patient00486_study1.npy 64KB
patient00485_study2.npy 64KB
patient00488_study1.npy 64KB
diseased
patient00128_study3.npy 64KB
patient00124_study2.npy 64KB
patient00122_study6.npy 64KB
guided_diffusion
__init__.py 70B
losses.py 2KB
dist_util.py 3KB
fp16_util.py 8KB
bratsloader.py 3KB
nn.py 5KB
train_util.py 11KB
gaussian_diffusion.py 43KB
load_BRATS.py 2KB
resample.py 6KB
image_datasets.py 6KB
unet.py 31KB
logger.py 14KB
script_util.py 13KB
respace.py 5KB
requirements.txt 952B
initial_README 192B
README.md 3KB
scripts
classifier_sample_known.py 7KB
classifier_train.py 9KB
image_sample.py 3KB
evaluation_metrics 1KB
image_train.py 3KB
image_nll.py 3KB
共 62 条
- 1
资源评论
小码蚁.
- 粉丝: 2654
- 资源: 4452
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 使用redis构建简单的社交网站-model-for-netwo开发笔记
- 神经网络aper-开发笔记
- 树状数组-2023C-m开发笔记
- mysql多表联合查询案例
- IMG20240609013653.jpg
- 分别通过BP神经网络和GRNN广义回归神经网络对电力负荷数据进行训练和预测matlab仿真,包括程序,注释,操作步骤
- 基于图像纹理特征提取的图像分割算法matlab仿真,包括程序,注释,操作步骤
- Spring Boot整合Redis通过Zset数据类型+定时任务实现延迟队列教程对应源码
- 创意互动:HTML+CSS+JS打造《三维端午节动态文字秀》大屏特效
- Python爬虫框架scrapy获取百度热搜
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功