Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ci-ber/PHANES
Reversing the Abnormal: Pseudo-Healthy Generative Networks for Anomaly Detection
https://github.com/ci-ber/PHANES
Last synced: 14 days ago
JSON representation
Reversing the Abnormal: Pseudo-Healthy Generative Networks for Anomaly Detection
- Host: GitHub
- URL: https://github.com/ci-ber/PHANES
- Owner: ci-ber
- License: gpl-3.0
- Created: 2023-07-20T14:09:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-16T17:55:49.000Z (about 2 months ago)
- Last Synced: 2024-09-16T22:04:57.393Z (about 2 months ago)
- Language: Python
- Size: 145 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
The code is being tested...
Reversing the Abnormal: Pseudo-Healthy Generative Networks for Anomaly Detection
Cosmin Bercea •
Benedikt Wiestler •
Daniel Rueckert •
Julia A. Schnabel
Official repository of the paper
MICCAI 2023
Project Website • Preprint • Paper
## Citation
If you find our work helpful, please cite our paper:
```
@article{bercea2023reversing,
title={Reversing the abnormal: Pseudo-healthy generative networks for anomaly detection},
author={Bercea, Cosmin I and Wiestler, Benedikt and Rueckert, Daniel and Schnabel, Julia A},
journal={arXiv preprint arXiv:2303.08452},
year={2023}
}
```> **Abstract:** *Early and accurate disease detection is crucial for patient management and successful treatment outcomes. However, the automatic identification of anomalies in medical images can be challenging. Conventional methods rely on large labeled datasets which are difficult to obtain. To overcome these limitations, we introduce a novel unsupervised approach, called PHANES (Pseudo Healthy generative networks for ANomaly Segmentation). Our method has the capability of reversing anomalies, i.e., preserving healthy tissue and replacing anomalous regions with pseudo-healthy (PH) reconstructions. Unlike recent diffusion models, our method does not rely on a learned noise distribution nor does it introduce random alterations to the entire image. Instead, we use latent generative networks to create masks around possible anomalies, which are refined using inpainting generative networks. We demonstrate the effectiveness of PHANES in detecting stroke lesions in T1w brain MRI datasets and show significant improvements over state-of-the-art (SOTA) methods. We believe that our proposed framework will open new avenues for interpretable, fast, and accurate anomaly segmentation with the potential to support various clinical-oriented downstream tasks.*
## Setup and Run
The code is based on the deep learning framework from the Institute of Machine Learning in Biomedical Imaging: https://github.com/compai-lab/iml-dl
### Framework Overview:
#### 1). Set up wandb (https://docs.wandb.ai/quickstart)
Sign up for a free account and login to your wandb account.
```bash
wandb login
```
Paste the API key from https://wandb.ai/authorize when prompted.#### 2). Clone repository
```bash
git clone https://github.com/ci-ber/PHANES.git
cd PHANES
```#### 3). Install requirements
```bash
pip install -r pip_requirements.txt
```
or *conda*:
```bash
conda create --name phanes_py308 --file conda_requirements.txt
conda activate phanes_py308
```#### 4). Install PyTorch
> Example installation:
* *with cuda*:
```
pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
```
* *w/o cuda*:
```
pip3 install torch==1.9.1 torchvision==0.10.1 -f https://download.pytorch.org/whl/torch_stable.html
```#### 5). Download datasets
IXI • FastMRI • Labels for FastMRI • Atlas (Stroke)> *Alternatively you can use your own mid-axial slices of T1w brain scans with our pre-trained weights or train from scratch on other anatomies and modalities.*
#### 6). !!! Set the right threshold
You have to choose a threshold for binarizing the probable anomaly masks of the first step. Be mindful of this step since it can dramatically influence the outcome. In the paper, we use a threshold that delivers at most 5% false positive for inference *masking_threshold_infer: 0.153* in the *phanes.yaml* config file (0.153 for the given dataset). We choose a lower threshold for training (*masking_threshold_train: 0.1*) since the networks make fewer errors on the training data and we need to train the GAN with some input. This has to be set for each dataset individually since the network might produce different errors on healthy data due to domain shifts! You can use the *thresholding* function in the *DownStreamEvaluator.py* to compute these on a healthy subsample of that distribution or use *None* otherwise (This will automatically filter the 95% percentile of each scan individually).
#### 7). Run the pipeline
Run the main script with the corresponding config like this:
```bash
python core/Main.py --config_path ./projects/phanes/phanes.yaml
```Refer to phanes.yaml for the default configuration.
# That's it, enjoy! :rocket: