Switch to unified view

a/README.md b/README.md
1
<!-- # MEDIGAN -->
1
<!-- # MEDIGAN -->
2
<!-- ![medigan](medigan_logo_1.png) -->
2
3
![medigan](docs/source/_static/medigan_logo.png)
3
4
5
[![License](https://img.shields.io/github/license/RichardObi/medigan)](https://opensource.org/licenses/MIT)
4
[![License](https://img.shields.io/github/license/RichardObi/medigan)](https://opensource.org/licenses/MIT)
6
![Continuous integration](https://github.com/RichardObi/medigan/actions/workflows/python-ci.yml/badge.svg)
5
![Continuous integration](https://github.com/RichardObi/medigan/actions/workflows/python-ci.yml/badge.svg)
7
[![PyPI version](https://badge.fury.io/py/medigan.svg)](https://badge.fury.io/py/medigan)
6
[![PyPI version](https://badge.fury.io/py/medigan.svg)](https://badge.fury.io/py/medigan)
8
[![Conda version](https://img.shields.io/conda/vn/conda-forge/medigan)](https://github.com/conda-forge/medigan-feedstock)
7
[![Conda version](https://img.shields.io/conda/vn/conda-forge/medigan)](https://github.com/conda-forge/medigan-feedstock)
9
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6327625.svg)](https://doi.org/10.5281/zenodo.6327625)
8
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6327625.svg)](https://doi.org/10.5281/zenodo.6327625)
10
[![arXiv](https://img.shields.io/badge/arXiv-2209.14472-b31b1b.svg)](https://arxiv.org/abs/2209.14472)
9
[![arXiv](https://img.shields.io/badge/arXiv-2209.14472-b31b1b.svg)](https://arxiv.org/abs/2209.14472)
11
10
12
`medigan` stands for **medi**cal **g**enerative (**a**dversarial) **n**etworks. `medigan` provides user-friendly medical image synthesis and allows users to choose from a range of pretrained generative models to `generate` synthetic datasets. These synthetic datasets can be used to train or adapt AI models that perform clinical tasks such as lesion classification, segmentation or detection. 
11
`medigan` stands for **medi**cal **g**enerative (**a**dversarial) **n**etworks. `medigan` provides user-friendly medical image synthesis and allows users to choose from a range of pretrained generative models to `generate` synthetic datasets. These synthetic datasets can be used to train or adapt AI models that perform clinical tasks such as lesion classification, segmentation or detection. 
13
12
14
See below how medigan can be run from the command line to generate synthetic medical images.
13
See below how medigan can be run from the command line to generate synthetic medical images.
15
14
16
![medigan can be run directly from the command line to generate synthetic medical images](https://github.com/RichardObi/medigan/blob/main/docs/source/_static/medigan.gif "medigan can be run directly from the command line to generate synthetic medical images.")
15
![medigan can be run directly from the command line to generate synthetic medical images](https://github.com/RichardObi/medigan/blob/main/docs/source/_static/medigan.gif "medigan can be run directly from the command line to generate synthetic medical images.")
17
16
18
## Features:
17
## Features:
19
18
20
- :x: **Problem 1:** Data scarcity in medical imaging. 
19
- :x: **Problem 1:** Data scarcity in medical imaging. 
21
20
22
- :x: **Problem 2:** Scarcity of readily reusable generative models in medical imaging.
21
- :x: **Problem 2:** Scarcity of readily reusable generative models in medical imaging.
23
22
24
- :white_check_mark: **Solution:** `medigan`
23
- :white_check_mark: **Solution:** `medigan`
25
    1. dataset sharing via generative models :gift:
24
    1. dataset sharing via generative models :gift:
26
    2. data augmentation :gift:
25
    2. data augmentation :gift:
27
    3. domain adaptation :gift:
26
    3. domain adaptation :gift:
28
    4. synthetic data evaluation method testing with multi-model datasets :gift:
27
    4. synthetic data evaluation method testing with multi-model datasets :gift:
29
28
30
Instead of training your own, use one of the generative models from `medigan` to generate synthetic data. 
29
Instead of training your own, use one of the generative models from `medigan` to generate synthetic data. 
31
30
32
Search and find a model in `medigan` using search terms (e.g. "Mammography" or "Endoscopy"). 
31
Search and find a model in `medigan` using search terms (e.g. "Mammography" or "Endoscopy"). 
33
32
34
Contribute your own generative model to `medigan` to increase its visibility, re-use, and impact.
33
Contribute your own generative model to `medigan` to increase its visibility, re-use, and impact.
35
34
36
35
37
## Available models
36
## Available models
38
37
39
| Output type                                                 |           Modality            |          Model type           |       Output size       |                                                        Base dataset                                                        |                                                                                                                                                                      Output examples                                                                                                                                                                       |                                                                   `model_id`                                                                   |                                    Hosted on                                    |                                      Reference                                       |
38
| Output type                                                 |           Modality            |          Model type           |       Output size       |                                                        Base dataset                                                        |                                                                                                                                                                      Output examples                                                                                                                                                                       |                                                                   `model_id`                                                                   |                                    Hosted on                                    |                                      Reference                                       |
40
|-------------------------------------------------------------|:-----------------------------:|:-----------------------------:|:-----------------------:|:--------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------:|
39
|-------------------------------------------------------------|:-----------------------------:|:-----------------------------:|:-----------------------:|:--------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------:|
41
| <sub> Breast Calcification        </sub>                    |  <sub>  mammography  </sub>   |   <sub>    dcgan     </sub>   |  <sub> 128x128 </sub>   |            <sub>  [Inbreast](https://www.academicradiology.org/article/S1076-6332(11)00451-X/fulltext)   </sub>            |                                                                                                                                                      ![sample](docs/source/_static/samples/00001.png)                                                                                                                                                      |               <sub> [`00001_DCGAN_MMG_CALC_ROI`](https://medigan.readthedocs.io/en/latest/models.html#dcgan-mmg-calc-roi) </sub>               |     <sub>[Zenodo (5187714)](https://doi.org/10.5281/zenodo.5187714) </sub>      |                                                                                      | 
40
| <sub> Breast Calcification        </sub>                    |  <sub>  mammography  </sub>   |   <sub>    dcgan     </sub>   |  <sub> 128x128 </sub>   |            <sub>  [Inbreast](https://www.academicradiology.org/article/S1076-6332(11)00451-X/fulltext)   </sub>            |                                                                                                                                                      ![sample](docs/source/_static/samples/00001.png)                                                                                                                                                      |               <sub> [`00001_DCGAN_MMG_CALC_ROI`](https://medigan.readthedocs.io/en/latest/models.html#dcgan-mmg-calc-roi) </sub>               |     <sub>[Zenodo (5187714)](https://doi.org/10.5281/zenodo.5187714) </sub>      |                                                                                      | 
42
| <sub> Breast Mass                 </sub>                    |  <sub>  mammography  </sub>   |   <sub>    dcgan     </sub>   |  <sub> 128x128 </sub>   |                           <sub>   [Optimam](https://doi.org/10.48550/arXiv.2004.04742)   </sub>                            |                                                                                                                                                      ![sample](docs/source/_static/samples/00002.png)                                                                                                                                                      |               <sub> [`00002_DCGAN_MMG_MASS_ROI`](https://medigan.readthedocs.io/en/latest/models.html#dcgan-mmg-mass-roi) </sub>               |     <sub>[Zenodo (5188557)](https://doi.org/10.5281/zenodo.5188557) </sub>      |     <sub>[Alyafi et al (2019)](https://doi.org/10.48550/arXiv.1909.02062) </sub>     | 
41
| <sub> Breast Mass                 </sub>                    |  <sub>  mammography  </sub>   |   <sub>    dcgan     </sub>   |  <sub> 128x128 </sub>   |                           <sub>   [Optimam](https://doi.org/10.48550/arXiv.2004.04742)   </sub>                            |                                                                                                                                                      ![sample](docs/source/_static/samples/00002.png)                                                                                                                                                      |               <sub> [`00002_DCGAN_MMG_MASS_ROI`](https://medigan.readthedocs.io/en/latest/models.html#dcgan-mmg-mass-roi) </sub>               |     <sub>[Zenodo (5188557)](https://doi.org/10.5281/zenodo.5188557) </sub>      |     <sub>[Alyafi et al (2019)](https://doi.org/10.48550/arXiv.1909.02062) </sub>     | 
43
| <sub> Breast Density Transfer     </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                                                      ![sample](docs/source/_static/samples/00003.png)                                                                                                                                                      |        <sub> [`00003_CYCLEGAN_MMG_DENSITY_FULL`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-full) </sub>        |     <sub>[Zenodo (5547263)](https://doi.org/10.5281/zenodo.5547263) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    | 
42
| <sub> Breast Density Transfer     </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                                                      ![sample](docs/source/_static/samples/00003.png)                                                                                                                                                      |        <sub> [`00003_CYCLEGAN_MMG_DENSITY_FULL`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-full) </sub>        |     <sub>[Zenodo (5547263)](https://doi.org/10.5281/zenodo.5547263) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    | 
44
| <sub> Breast Mass with Mask       </sub>                    |  <sub>  mammography  </sub>   |   <sub>   pix2pix    </sub>   |  <sub> 256x256 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                        ![sample](docs/source/_static/samples/00004.png) <br> ![sample](docs/source/_static/samples/00004_mask.png)                                                                                                                         | <sub><sub> [`00004_PIX2PIX_MMG_MASSES_W_MASKS`](https://medigan.readthedocs.io/en/latest/models.html#pix2pix-mmg-masses-w-masks) </sub></sub>  |     <sub>[Zenodo (7093759)](https://doi.org/10.5281/zenodo.7093759) </sub>      |                                                                                      | 
43
| <sub> Breast Mass with Mask       </sub>                    |  <sub>  mammography  </sub>   |   <sub>   pix2pix    </sub>   |  <sub> 256x256 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                        ![sample](docs/source/_static/samples/00004.png) <br> ![sample](docs/source/_static/samples/00004_mask.png)                                                                                                                         | <sub><sub> [`00004_PIX2PIX_MMG_MASSES_W_MASKS`](https://medigan.readthedocs.io/en/latest/models.html#pix2pix-mmg-masses-w-masks) </sub></sub>  |     <sub>[Zenodo (7093759)](https://doi.org/10.5281/zenodo.7093759) </sub>      |                                                                                      | 
45
| <sub> Breast Mass                 </sub>                    |  <sub>  mammography  </sub>   |   <sub>    dcgan     </sub>   |  <sub> 128x128 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                                                      ![sample](docs/source/_static/samples/00005.png)                                                                                                                                                      |                      <sub> [`00005_DCGAN_MMG_MASS_ROI`](https://medigan.readthedocs.io/en/latest/models.html#id1) </sub>                       |     <sub>[Zenodo (6555188)](https://doi.org/10.5281/zenodo.6555188) </sub>      |  <sub>[Szafranowska et al (2022)](https://doi.org/10.48550/arXiv.2203.04961) </sub>  | 
44
| <sub> Breast Mass                 </sub>                    |  <sub>  mammography  </sub>   |   <sub>    dcgan     </sub>   |  <sub> 128x128 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                                                      ![sample](docs/source/_static/samples/00005.png)                                                                                                                                                      |                      <sub> [`00005_DCGAN_MMG_MASS_ROI`](https://medigan.readthedocs.io/en/latest/models.html#id1) </sub>                       |     <sub>[Zenodo (6555188)](https://doi.org/10.5281/zenodo.6555188) </sub>      |  <sub>[Szafranowska et al (2022)](https://doi.org/10.48550/arXiv.2203.04961) </sub>  | 
46
| <sub> Breast Mass                 </sub>                    |  <sub>  mammography  </sub>   |   <sub>   wgan-gp    </sub>   |  <sub> 128x128 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                                                      ![sample](docs/source/_static/samples/00006.png)                                                                                                                                                      |              <sub> [`00006_WGANGP_MMG_MASS_ROI`](https://medigan.readthedocs.io/en/latest/models.html#wgangp-mmg-mass-roi) </sub>              |     <sub>[Zenodo (6554713)](https://doi.org/10.5281/zenodo.6554713) </sub>      |  <sub>[Szafranowska et al (2022)](https://doi.org/10.48550/arXiv.2203.04961) </sub>  | 
45
| <sub> Breast Mass                 </sub>                    |  <sub>  mammography  </sub>   |   <sub>   wgan-gp    </sub>   |  <sub> 128x128 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                                                      ![sample](docs/source/_static/samples/00006.png)                                                                                                                                                      |              <sub> [`00006_WGANGP_MMG_MASS_ROI`](https://medigan.readthedocs.io/en/latest/models.html#wgangp-mmg-mass-roi) </sub>              |     <sub>[Zenodo (6554713)](https://doi.org/10.5281/zenodo.6554713) </sub>      |  <sub>[Szafranowska et al (2022)](https://doi.org/10.48550/arXiv.2203.04961) </sub>  | 
47
| <sub> Brain Tumors on Flair, T1, T1c, T2 with Masks  </sub> |   <sub>  brain MRI  </sub>    | <sub>   inpaint GAN    </sub> |  <sub> 256x256 </sub>   |       <sub>    [BRATS 2018](https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=37224922)     </sub>        | ![sample](docs/source/_static/samples/00007_F.png) <br> ![sample](docs/source/_static/samples/00007_T1.png) <br> ![sample](docs/source/_static/samples/00007_T1c.png) <br> ![sample](docs/source/_static/samples/00007_T2.png) <br> ![sample](docs/source/_static/samples/00007_mask.png) <br> ![sample](docs/source/_static/samples/00007_grade_mask.png) |                <sub> [`00007_INPAINT_BRAIN_MRI`](https://medigan.readthedocs.io/en/latest/models.html#inpaint-brain-mri) </sub>                |     <sub> [Zenodo (7041737)](https://doi.org/10.5281/zenodo.7041737) </sub>     |           <sub>[Kim et al (2020)](https://doi.org/10.1002/mp.14701) </sub>           | 
46
| <sub> Brain Tumors on Flair, T1, T1c, T2 with Masks  </sub> |   <sub>  brain MRI  </sub>    | <sub>   inpaint GAN    </sub> |  <sub> 256x256 </sub>   |       <sub>    [BRATS 2018](https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=37224922)     </sub>        | ![sample](docs/source/_static/samples/00007_F.png) <br> ![sample](docs/source/_static/samples/00007_T1.png) <br> ![sample](docs/source/_static/samples/00007_T1c.png) <br> ![sample](docs/source/_static/samples/00007_T2.png) <br> ![sample](docs/source/_static/samples/00007_mask.png) <br> ![sample](docs/source/_static/samples/00007_grade_mask.png) |                <sub> [`00007_INPAINT_BRAIN_MRI`](https://medigan.readthedocs.io/en/latest/models.html#inpaint-brain-mri) </sub>                |     <sub> [Zenodo (7041737)](https://doi.org/10.5281/zenodo.7041737) </sub>     |           <sub>[Kim et al (2020)](https://doi.org/10.1002/mp.14701) </sub>           | 
48
| <sub> Breast Mass (Mal/Benign)    </sub>                    |  <sub>  mammography  </sub>   |  <sub>   c-dcgan     </sub>   |  <sub> 128x128 </sub>   |              <sub>    [CBIS-DDSM](https://wiki.cancerimagingarchive.net/display/Public/CBIS-DDSM)     </sub>               |                                                                                                                                                      ![sample](docs/source/_static/samples/00008.png)                                                                                                                                                      |               <sub> [`00008_C-DCGAN_MMG_MASSES`](https://medigan.readthedocs.io/en/latest/models.html#c-dcgan-mmg-masses) </sub>               |     <sub>[Zenodo (6647349)](https://doi.org/10.5281/zenodo.6647349) </sub>      |  <sub>[Osuala et al (2024)](https://doi.org/10.48550/arXiv.2407.12669) </sub>                                                                                  |  
47
| <sub> Breast Mass (Mal/Benign)    </sub>                    |  <sub>  mammography  </sub>   |  <sub>   c-dcgan     </sub>   |  <sub> 128x128 </sub>   |              <sub>    [CBIS-DDSM](https://wiki.cancerimagingarchive.net/display/Public/CBIS-DDSM)     </sub>               |                                                                                                                                                      ![sample](docs/source/_static/samples/00008.png)                                                                                                                                                      |               <sub> [`00008_C-DCGAN_MMG_MASSES`](https://medigan.readthedocs.io/en/latest/models.html#c-dcgan-mmg-masses) </sub>               |     <sub>[Zenodo (6647349)](https://doi.org/10.5281/zenodo.6647349) </sub>      |  <sub>[Osuala et al (2024)](https://doi.org/10.48550/arXiv.2407.12669) </sub>                                                                                  |  
49
| <sub> Polyp with Mask             </sub>                    |   <sub>  endoscopy  </sub>    |    <sub>   pggan   </sub>     |  <sub> 256x256 </sub>   |                                  <sub>    [HyperKvasir](https://osf.io/mh9sj/)     </sub>                                  |                                                                                                                        ![sample](docs/source/_static/samples/00009.png) <br> ![sample](docs/source/_static/samples/00009_mask.png)                                                                                                                         |      <sub> [`00009_PGGAN_POLYP_PATCHES_W_MASKS`](https://medigan.readthedocs.io/en/latest/models.html#pggan-polyp-patches-w-masks) </sub>      |     <sub>[Zenodo (6653743)](https://doi.org/10.5281/zenodo.6653743) </sub>      | <sub>[Thambawita et al (2022)](https://doi.org/10.1371/journal.pone.0267976) </sub>  | 
48
| <sub> Polyp with Mask             </sub>                    |   <sub>  endoscopy  </sub>    |    <sub>   pggan   </sub>     |  <sub> 256x256 </sub>   |                                  <sub>    [HyperKvasir](https://osf.io/mh9sj/)     </sub>                                  |                                                                                                                        ![sample](docs/source/_static/samples/00009.png) <br> ![sample](docs/source/_static/samples/00009_mask.png)                                                                                                                         |      <sub> [`00009_PGGAN_POLYP_PATCHES_W_MASKS`](https://medigan.readthedocs.io/en/latest/models.html#pggan-polyp-patches-w-masks) </sub>      |     <sub>[Zenodo (6653743)](https://doi.org/10.5281/zenodo.6653743) </sub>      | <sub>[Thambawita et al (2022)](https://doi.org/10.1371/journal.pone.0267976) </sub>  | 
50
| <sub> Polyp with Mask             </sub>                    |   <sub>  endoscopy  </sub>    |    <sub>   fastgan </sub>     |  <sub> 256x256 </sub>   |                                  <sub>    [HyperKvasir](https://osf.io/mh9sj/)     </sub>                                  |                                                                                                                        ![sample](docs/source/_static/samples/00010.png) <br> ![sample](docs/source/_static/samples/00010_mask.png)                                                                                                                         |    <sub> [`00010_FASTGAN_POLYP_PATCHES_W_MASKS`](https://medigan.readthedocs.io/en/latest/models.html#fastgan-polyp-patches-w-masks) </sub>    |     <sub>[Zenodo (6660711)](https://doi.org/10.5281/zenodo.6660711) </sub>      | <sub>[Thambawita et al (2022)](https://doi.org/10.1371/journal.pone.0267976) </sub>  | 
49
| <sub> Polyp with Mask             </sub>                    |   <sub>  endoscopy  </sub>    |    <sub>   fastgan </sub>     |  <sub> 256x256 </sub>   |                                  <sub>    [HyperKvasir](https://osf.io/mh9sj/)     </sub>                                  |                                                                                                                        ![sample](docs/source/_static/samples/00010.png) <br> ![sample](docs/source/_static/samples/00010_mask.png)                                                                                                                         |    <sub> [`00010_FASTGAN_POLYP_PATCHES_W_MASKS`](https://medigan.readthedocs.io/en/latest/models.html#fastgan-polyp-patches-w-masks) </sub>    |     <sub>[Zenodo (6660711)](https://doi.org/10.5281/zenodo.6660711) </sub>      | <sub>[Thambawita et al (2022)](https://doi.org/10.1371/journal.pone.0267976) </sub>  | 
51
| <sub> Polyp with Mask             </sub>                    |   <sub>  endoscopy  </sub>    |     <sub>   singan </sub>     |  <sub> ≈250x250 </sub>  |                                  <sub>    [HyperKvasir](https://osf.io/mh9sj/)     </sub>                                  |                                                                                                                        ![sample](docs/source/_static/samples/00011.png) <br> ![sample](docs/source/_static/samples/00011_mask.png)                                                                                                                         |     <sub> [`00011_SINGAN_POLYP_PATCHES_W_MASKS`](https://medigan.readthedocs.io/en/latest/models.html#singan-polyp-patches-w-masks) </sub>     |     <sub>[Zenodo (6667944)](https://doi.org/10.5281/zenodo.6667944) </sub>      | <sub>[Thambawita et al (2022)](https://doi.org/10.1371/journal.pone.0267976) </sub>  | 
50
| <sub> Polyp with Mask             </sub>                    |   <sub>  endoscopy  </sub>    |     <sub>   singan </sub>     |  <sub> ≈250x250 </sub>  |                                  <sub>    [HyperKvasir](https://osf.io/mh9sj/)     </sub>                                  |                                                                                                                        ![sample](docs/source/_static/samples/00011.png) <br> ![sample](docs/source/_static/samples/00011_mask.png)                                                                                                                         |     <sub> [`00011_SINGAN_POLYP_PATCHES_W_MASKS`](https://medigan.readthedocs.io/en/latest/models.html#singan-polyp-patches-w-masks) </sub>     |     <sub>[Zenodo (6667944)](https://doi.org/10.5281/zenodo.6667944) </sub>      | <sub>[Thambawita et al (2022)](https://doi.org/10.1371/journal.pone.0267976) </sub>  | 
52
| <sub> Breast Mass (Mal/Benign)    </sub>                    |  <sub>  mammography  </sub>   |  <sub>   c-dcgan     </sub>   |  <sub> 128x128 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                                                      ![sample](docs/source/_static/samples/00012.png)                                                                                                                                                      |                      <sub> [`00012_C-DCGAN_MMG_MASSES`](https://medigan.readthedocs.io/en/latest/models.html#id2) </sub>                       |     <sub>[Zenodo (6755693)](https://doi.org/10.5281/zenodo.6818095) </sub>      |                                                                                      | 
51
| <sub> Breast Mass (Mal/Benign)    </sub>                    |  <sub>  mammography  </sub>   |  <sub>   c-dcgan     </sub>   |  <sub> 128x128 </sub>   |                               <sub>    [BCDR](https://bcdr.eu/information/about)     </sub>                                |                                                                                                                                                      ![sample](docs/source/_static/samples/00012.png)                                                                                                                                                      |                      <sub> [`00012_C-DCGAN_MMG_MASSES`](https://medigan.readthedocs.io/en/latest/models.html#id2) </sub>                       |     <sub>[Zenodo (6755693)](https://doi.org/10.5281/zenodo.6818095) </sub>      |                                                                                      | 
53
| <sub> Breast Density Transfer MLO </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                          <sub>    [OPTIMAM](https://doi.org/10.48550/arXiv.2004.04742)     </sub>                          |                                                                                                                                                      ![sample](docs/source/_static/samples/00013.png)                                                                                                                                                      | <sub> [`00013_CYCLEGAN_MMG_DENSITY_OPTIMAM_MLO`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-optimam-mlo) </sub> |     <sub>[Zenodo (6818095)](https://doi.org/10.5281/zenodo.6818095) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    | 
52
| <sub> Breast Density Transfer MLO </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                          <sub>    [OPTIMAM](https://doi.org/10.48550/arXiv.2004.04742)     </sub>                          |                                                                                                                                                      ![sample](docs/source/_static/samples/00013.png)                                                                                                                                                      | <sub> [`00013_CYCLEGAN_MMG_DENSITY_OPTIMAM_MLO`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-optimam-mlo) </sub> |     <sub>[Zenodo (6818095)](https://doi.org/10.5281/zenodo.6818095) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    | 
54
| <sub> Breast Density Transfer CC  </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                          <sub>    [OPTIMAM](https://doi.org/10.48550/arXiv.2004.04742)     </sub>                          |                                                                                                                                                      ![sample](docs/source/_static/samples/00014.png)                                                                                                                                                      |  <sub> [`00014_CYCLEGAN_MMG_DENSITY_OPTIMAM_CC`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-optimam-cc) </sub>  |     <sub>[Zenodo (6818103)](https://doi.org/10.5281/zenodo.6818103) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    |  
53
| <sub> Breast Density Transfer CC  </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                          <sub>    [OPTIMAM](https://doi.org/10.48550/arXiv.2004.04742)     </sub>                          |                                                                                                                                                      ![sample](docs/source/_static/samples/00014.png)                                                                                                                                                      |  <sub> [`00014_CYCLEGAN_MMG_DENSITY_OPTIMAM_CC`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-optimam-cc) </sub>  |     <sub>[Zenodo (6818103)](https://doi.org/10.5281/zenodo.6818103) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    |  
55
| <sub> Breast Density Transfer MLO </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                  <sub>    [CSAW](https://link.springer.com/article/10.1007/s10278-019-00278-0)     </sub>                  |                                                                                                                                                      ![sample](docs/source/_static/samples/00015.png)                                                                                                                                                      |    <sub> [`00015_CYCLEGAN_MMG_DENSITY_CSAW_MLO`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-csaw-mlo) </sub>    |     <sub>[Zenodo (6818105)](https://doi.org/10.5281/zenodo.6818105) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    |  
54
| <sub> Breast Density Transfer MLO </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                  <sub>    [CSAW](https://link.springer.com/article/10.1007/s10278-019-00278-0)     </sub>                  |                                                                                                                                                      ![sample](docs/source/_static/samples/00015.png)                                                                                                                                                      |    <sub> [`00015_CYCLEGAN_MMG_DENSITY_CSAW_MLO`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-csaw-mlo) </sub>    |     <sub>[Zenodo (6818105)](https://doi.org/10.5281/zenodo.6818105) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    |  
56
| <sub> Breast Density Transfer CC  </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                  <sub>    [CSAW](https://link.springer.com/article/10.1007/s10278-019-00278-0)    </sub>                   |                                                                                                                                                      ![sample](docs/source/_static/samples/00016.png)                                                                                                                                                      |     <sub> [`00016_CYCLEGAN_MMG_DENSITY_CSAW_CC`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-csaw-cc) </sub>     |     <sub>[Zenodo (6818107)](https://doi.org/10.5281/zenodo.6818107) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    | 
55
| <sub> Breast Density Transfer CC  </sub>                    |  <sub>  mammography  </sub>   |   <sub>   cyclegan   </sub>   |  <sub>1332x800 </sub>   |                  <sub>    [CSAW](https://link.springer.com/article/10.1007/s10278-019-00278-0)    </sub>                   |                                                                                                                                                      ![sample](docs/source/_static/samples/00016.png)                                                                                                                                                      |     <sub> [`00016_CYCLEGAN_MMG_DENSITY_CSAW_CC`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-mmg-density-csaw-cc) </sub>     |     <sub>[Zenodo (6818107)](https://doi.org/10.5281/zenodo.6818107) </sub>      |   <sub> [Garrucho et al (2022)](https://doi.org/10.48550/arXiv.2209.09809) </sub>    | 
57
| <sub> Lung Nodules                </sub>                    |  <sub>  chest x-ray  </sub>   |   <sub>   dcgan      </sub>   |  <sub>128x128  </sub>   |                        <sub>    [NODE21](https://zenodo.org/record/4725881#.YxNmNuxBwXA)     </sub>                        |                                                                                                                                                      ![sample](docs/source/_static/samples/00017.png)                                                                                                                                                      |          <sub> [`00017_DCGAN_XRAY_LUNG_NODULES`](https://medigan.readthedocs.io/en/latest/models.html#dcgan-xray-lung-nodules) </sub>          |     <sub>[Zenodo (6943691)](https://doi.org/10.5281/zenodo.6943691) </sub>      |                                                                                      | 
56
| <sub> Lung Nodules                </sub>                    |  <sub>  chest x-ray  </sub>   |   <sub>   dcgan      </sub>   |  <sub>128x128  </sub>   |                        <sub>    [NODE21](https://zenodo.org/record/4725881#.YxNmNuxBwXA)     </sub>                        |                                                                                                                                                      ![sample](docs/source/_static/samples/00017.png)                                                                                                                                                      |          <sub> [`00017_DCGAN_XRAY_LUNG_NODULES`](https://medigan.readthedocs.io/en/latest/models.html#dcgan-xray-lung-nodules) </sub>          |     <sub>[Zenodo (6943691)](https://doi.org/10.5281/zenodo.6943691) </sub>      |                                                                                      | 
58
| <sub> Lung Nodules                </sub>                    |  <sub>  chest x-ray  </sub>   |  <sub>   wgan-gp      </sub>  |  <sub>128x128  </sub>   |                        <sub>    [NODE21](https://zenodo.org/record/4725881#.YxNmNuxBwXA)     </sub>                        |                                                                                                                                                      ![sample](docs/source/_static/samples/00018.png)                                                                                                                                                      |         <sub> [`00018_WGANGP_XRAY_LUNG_NODULES`](https://medigan.readthedocs.io/en/latest/models.html#wgangp-xray-lung-nodules) </sub>         |     <sub>[Zenodo (6943761)](https://doi.org/10.5281/zenodo.6943761) </sub>      |                                                                                      | 
57
| <sub> Lung Nodules                </sub>                    |  <sub>  chest x-ray  </sub>   |  <sub>   wgan-gp      </sub>  |  <sub>128x128  </sub>   |                        <sub>    [NODE21](https://zenodo.org/record/4725881#.YxNmNuxBwXA)     </sub>                        |                                                                                                                                                      ![sample](docs/source/_static/samples/00018.png)                                                                                                                                                      |         <sub> [`00018_WGANGP_XRAY_LUNG_NODULES`](https://medigan.readthedocs.io/en/latest/models.html#wgangp-xray-lung-nodules) </sub>         |     <sub>[Zenodo (6943761)](https://doi.org/10.5281/zenodo.6943761) </sub>      |                                                                                      | 
59
| <sub> Chest Xray Images           </sub>                    |  <sub>  chest x-ray  </sub>   |   <sub>   pggan      </sub>   | <sub>1024x1024  </sub>  |             <sub>    [ChestX-ray14](https://nihcc.app.box.com/v/ChestXray-NIHCC/folder/36938765345)     </sub>             |                                                                                                                                                      ![sample](docs/source/_static/samples/00019.png)                                                                                                                                                      |                 <sub> [`00019_PGGAN_CHEST_XRAY`](https://medigan.readthedocs.io/en/latest/models.html#pggan-chest-xray) </sub>                 |     <sub>[Zenodo (6943803)](https://doi.org/10.5281/zenodo.6943803) </sub>      |                                                                                      | 
58
| <sub> Chest Xray Images           </sub>                    |  <sub>  chest x-ray  </sub>   |   <sub>   pggan      </sub>   | <sub>1024x1024  </sub>  |             <sub>    [ChestX-ray14](https://nihcc.app.box.com/v/ChestXray-NIHCC/folder/36938765345)     </sub>             |                                                                                                                                                      ![sample](docs/source/_static/samples/00019.png)                                                                                                                                                      |                 <sub> [`00019_PGGAN_CHEST_XRAY`](https://medigan.readthedocs.io/en/latest/models.html#pggan-chest-xray) </sub>                 |     <sub>[Zenodo (6943803)](https://doi.org/10.5281/zenodo.6943803) </sub>      |                                                                                      | 
60
| <sub> Chest Xray Images           </sub>                    |  <sub>  chest x-ray  </sub>   |   <sub>   pggan      </sub>   | <sub>1024x1024  </sub>  |             <sub>    [ChestX-ray14](https://nihcc.app.box.com/v/ChestXray-NIHCC/folder/36938765345)     </sub>             |                                                                                                                                                      ![sample](docs/source/_static/samples/00020.png)                                                                                                                                                      |                       <sub> [`00020_PGGAN_CHEST_XRAY`](https://medigan.readthedocs.io/en/latest/models.html#id3) </sub>                        |     <sub>[Zenodo (7046280)](https://doi.org/10.5281/zenodo.7046280) </sub>      |    <sub> [Segal et al (2021)](https://doi.org/10.1007/s42979-021-00720-7) </sub>     |
59
| <sub> Chest Xray Images           </sub>                    |  <sub>  chest x-ray  </sub>   |   <sub>   pggan      </sub>   | <sub>1024x1024  </sub>  |             <sub>    [ChestX-ray14](https://nihcc.app.box.com/v/ChestXray-NIHCC/folder/36938765345)     </sub>             |                                                                                                                                                      ![sample](docs/source/_static/samples/00020.png)                                                                                                                                                      |                       <sub> [`00020_PGGAN_CHEST_XRAY`](https://medigan.readthedocs.io/en/latest/models.html#id3) </sub>                        |     <sub>[Zenodo (7046280)](https://doi.org/10.5281/zenodo.7046280) </sub>      |    <sub> [Segal et al (2021)](https://doi.org/10.1007/s42979-021-00720-7) </sub>     |
61
| <sub> Brain T1-T2 MRI Modality Transfer </sub>              |   <sub>  brain MRI  </sub>    | <sub>   cyclegan      </sub>  |  <sub>224x192  </sub>   |                           <sub>    [CrossMoDA 2021](https://arxiv.org/abs/2201.02831)     </sub>                           |                                                                                                                                                      ![sample](docs/source/_static/samples/00021.png)                                                                                                                                                      |         <sub> [`00021_CYCLEGAN_BRAIN_MRI_T1_T2`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-brain-mri-t1-t2) </sub>         |     <sub>[Zenodo (7074555)](https://doi.org/10.5281/zenodo.7074555) </sub>      |   <sub> [Joshi et al (2022)](https://doi.org/10.1007/978-3-031-09002-8_47) </sub>    |
60
| <sub> Brain T1-T2 MRI Modality Transfer </sub>              |   <sub>  brain MRI  </sub>    | <sub>   cyclegan      </sub>  |  <sub>224x192  </sub>   |                           <sub>    [CrossMoDA 2021](https://arxiv.org/abs/2201.02831)     </sub>                           |                                                                                                                                                      ![sample](docs/source/_static/samples/00021.png)                                                                                                                                                      |         <sub> [`00021_CYCLEGAN_BRAIN_MRI_T1_T2`](https://medigan.readthedocs.io/en/latest/models.html#cyclegan-brain-mri-t1-t2) </sub>         |     <sub>[Zenodo (7074555)](https://doi.org/10.5281/zenodo.7074555) </sub>      |   <sub> [Joshi et al (2022)](https://doi.org/10.1007/978-3-031-09002-8_47) </sub>    |
62
| <sub> Cardiac MRI Age Transfer </sub>                       |  <sub>  cardiac MRI  </sub>   |   <sub>   wgan      </sub>    |  <sub>256x256  </sub>   |                               <sub>    [UK Biobank](https://www.ukbiobank.ac.uk/)     </sub>                               |                                                                                                                                                      ![sample](docs/source/_static/samples/00022.png)                                                                                                                                                      |               <sub> [`00022_WGAN_CARDIAC_AGING`](https://medigan.readthedocs.io/en/latest/models.html#wgan-cardiac-aging) </sub>               |     <sub>[Zenodo (7446930)](https://doi.org/10.5281/zenodo.74469305) </sub>     |    <sub> [Campello et al (2022)](https://doi.org/10.3389/fcvm.2022.983091) </sub>    |
61
| <sub> Cardiac MRI Age Transfer </sub>                       |  <sub>  cardiac MRI  </sub>   |   <sub>   wgan      </sub>    |  <sub>256x256  </sub>   |                               <sub>    [UK Biobank](https://www.ukbiobank.ac.uk/)     </sub>                               |                                                                                                                                                      ![sample](docs/source/_static/samples/00022.png)                                                                                                                                                      |               <sub> [`00022_WGAN_CARDIAC_AGING`](https://medigan.readthedocs.io/en/latest/models.html#wgan-cardiac-aging) </sub>               |     <sub>[Zenodo (7446930)](https://doi.org/10.5281/zenodo.74469305) </sub>     |    <sub> [Campello et al (2022)](https://doi.org/10.3389/fcvm.2022.983091) </sub>    |
63
| <sub> Breast DCE-MRI Contrast Injection </sub>              | <sub>  breast DCE-MRI  </sub> | <sub>   pix2pixHD      </sub> | <sub>512x512  </sub>    | <sub>    [Duke Dataset](https://sites.duke.edu/mazurowski/resources/breast-cancer-mri-dataset/)     </sub>                 |                                                                                                                                                      ![sample](docs/source/_static/samples/00023.png)                                                                                                                                                      |          <sub> [`00023_PIX2PIXHD_BREAST_DCEMRI`](https://medigan.readthedocs.io/en/latest/models.html#pix2pixhd-breast-dcemri) </sub>          | <sub>[Zenodo (10210944)](https://zenodo.org/doi/10.5281/zenodo.10210944) </sub> |    <sub> [Osuala et al (2023)](https://doi.org/10.48550/arXiv.2311.10879) </sub>     |
62
| <sub> Breast DCE-MRI Contrast Injection </sub>              | <sub>  breast DCE-MRI  </sub> | <sub>   pix2pixHD      </sub> | <sub>512x512  </sub>    | <sub>    [Duke Dataset](https://sites.duke.edu/mazurowski/resources/breast-cancer-mri-dataset/)     </sub>                 |                                                                                                                                                      ![sample](docs/source/_static/samples/00023.png)                                                                                                                                                      |          <sub> [`00023_PIX2PIXHD_BREAST_DCEMRI`](https://medigan.readthedocs.io/en/latest/models.html#pix2pixhd-breast-dcemri) </sub>          | <sub>[Zenodo (10210944)](https://zenodo.org/doi/10.5281/zenodo.10210944) </sub> |    <sub> [Osuala et al (2023)](https://doi.org/10.48550/arXiv.2311.10879) </sub>     |
64
63
65
Model information can be found in:
64
Model information can be found in:
66
- [model documentation](https://medigan.readthedocs.io/en/latest/models.html) (e.g. the parameters of the models' generate functions)
65
- [model documentation](https://medigan.readthedocs.io/en/latest/models.html) (e.g. the parameters of the models' generate functions)
67
- [global.json](https://github.com/RichardObi/medigan/blob/main/config/global.json) file (e.g. metadata for model description, selection, and execution)
66
- [global.json](https://github.com/RichardObi/medigan/blob/main/config/global.json) file (e.g. metadata for model description, selection, and execution)
68
- [medigan paper](https://arxiv.org/abs/2209.14472) (e.g. analysis and comparisons of models and FID scores)
67
- [medigan paper](https://arxiv.org/abs/2209.14472) (e.g. analysis and comparisons of models and FID scores)
69
68
70
## Installation
69
## Installation
71
To install the current release, simply run:
70
To install the current release, simply run:
72
```console
71
```console
73
pip install medigan
72
pip install medigan
74
```
73
```
75
Or, alternatively via conda:
74
Or, alternatively via conda:
76
```console
75
```console
77
conda install -c conda-forge medigan
76
conda install -c conda-forge medigan
78
```
77
```
79
78
80
## Getting Started
79
## Getting Started
81
Examples and notebooks are located at [examples](examples) folder
80
Examples and notebooks are located at [examples](examples) folder
82
81
83
Documentation is available at [medigan.readthedocs.io](https://medigan.readthedocs.io/en/latest/)
82
Documentation is available at [medigan.readthedocs.io](https://medigan.readthedocs.io/en/latest/)
84
83
85
84
86
### Generation example
85
### Generation example
87
#### DCGAN 
86
#### DCGAN 
88
Create mammography masses with labels (malignant or benign) using a [class-conditional DCGAN model](https://arxiv.org/abs/2407.12669).
87
Create mammography masses with labels (malignant or benign) using a [class-conditional DCGAN model](https://arxiv.org/abs/2407.12669).
89
```python
88
```python
90
# import medigan and initialize Generators
89
# import medigan and initialize Generators
91
from medigan import Generators
90
from medigan import Generators
92
generators = Generators()
91
generators = Generators()
93
92
94
# generate 8 samples with model 8 (00008_C-DCGAN_MMG_MASSES). 
93
# generate 8 samples with model 8 (00008_C-DCGAN_MMG_MASSES). 
95
# Also, auto-install required model dependencies.
94
# Also, auto-install required model dependencies.
96
generators.generate(model_id=8, num_samples=8, install_dependencies=True)
95
generators.generate(model_id=8, num_samples=8, install_dependencies=True)
97
```
96
```
98
![sample](docs/source/_static/samples/c-dcgan/model8_samples.png)
97
![sample](docs/source/_static/samples/c-dcgan/model8_samples.png)
99
98
100
The synthetic images in the top row show malignant masses (breast cancer) while the images in the bottom row show benign masses. 
99
The synthetic images in the top row show malignant masses (breast cancer) while the images in the bottom row show benign masses. 
101
Given such images with class information, [image classification models](https://arxiv.org/abs/2407.12669) can be (pre-)trained.
100
Given such images with class information, [image classification models](https://arxiv.org/abs/2407.12669) can be (pre-)trained.
102
101
103
102
104
#### CYCLEGAN 
103
#### CYCLEGAN 
105
Create mammograms translated from Low-to-High Breast Density using CYCLEGAN model
104
Create mammograms translated from Low-to-High Breast Density using CYCLEGAN model
106
```python
105
```python
107
from medigan import Generators
106
from medigan import Generators
108
generators = Generators()
107
generators = Generators()
109
# model 3 is "00003_CYCLEGAN_MMG_DENSITY_FULL"
108
# model 3 is "00003_CYCLEGAN_MMG_DENSITY_FULL"
110
generators.generate(model_id=3, num_samples=1)
109
generators.generate(model_id=3, num_samples=1)
111
```
110
```
112
![sample](docs/source/_static/samples/cyclegan/sample_image_5_low.png)
111
![sample](docs/source/_static/samples/cyclegan/sample_image_5_low.png)
113
&rarr;
112
&rarr;
114
![sample](docs/source/_static/samples/cyclegan/sample_image_5_high.png)
113
![sample](docs/source/_static/samples/cyclegan/sample_image_5_high.png)
115
114
116
115
117
### Search Example
116
### Search Example
118
Search for a [model](https://medigan.readthedocs.io/en/latest/models.html) inside medigan using keywords
117
Search for a [model](https://medigan.readthedocs.io/en/latest/models.html) inside medigan using keywords
119
```python
118
```python
120
# import medigan and initialize Generators
119
# import medigan and initialize Generators
121
from medigan import Generators
120
from medigan import Generators
122
generators = Generators()
121
generators = Generators()
123
122
124
# list all models
123
# list all models
125
print(generators.list_models())
124
print(generators.list_models())
126
125
127
# search for models that have specific keywords in their config
126
# search for models that have specific keywords in their config
128
keywords = ['DCGAN', 'Mammography', 'BCDR']
127
keywords = ['DCGAN', 'Mammography', 'BCDR']
129
results = generators.find_matching_models_by_values(keywords)
128
results = generators.find_matching_models_by_values(keywords)
130
```
129
```
131
130
132
### Get Model as Dataloader 
131
### Get Model as Dataloader 
133
We can directly receive a [torch.utils.data.DataLoader](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader) object for any of medigan's generative models.
132
We can directly receive a [torch.utils.data.DataLoader](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader) object for any of medigan's generative models.
134
```python
133
```python
135
from medigan import Generators
134
from medigan import Generators
136
generators = Generators()
135
generators = Generators()
137
# model 4 is "00004_PIX2PIX_MMG_MASSES_W_MASKS"
136
# model 4 is "00004_PIX2PIX_MMG_MASSES_W_MASKS"
138
dataloader = generators.get_as_torch_dataloader(model_id=4, num_samples=3)
137
dataloader = generators.get_as_torch_dataloader(model_id=4, num_samples=3)
139
```
138
```
140
139
141
Visualize the contents of the dataloader.
140
Visualize the contents of the dataloader.
142
```python
141
```python
143
from matplotlib import pyplot as plt
142
from matplotlib import pyplot as plt
144
import numpy as np
143
import numpy as np
145
144
146
plt.figure()
145
plt.figure()
147
# subplot with 2 rows and len(dataloader) columns
146
# subplot with 2 rows and len(dataloader) columns
148
f, img_array = plt.subplots(2, len(dataloader)) 
147
f, img_array = plt.subplots(2, len(dataloader)) 
149
148
150
for batch_idx, data_dict in enumerate(dataloader):
149
for batch_idx, data_dict in enumerate(dataloader):
151
    sample = np.squeeze(data_dict.get("sample"))
150
    sample = np.squeeze(data_dict.get("sample"))
152
    mask = np.squeeze(data_dict.get("mask"))
151
    mask = np.squeeze(data_dict.get("mask"))
153
    img_array[0][batch_idx].imshow(sample, interpolation='nearest', cmap='gray')
152
    img_array[0][batch_idx].imshow(sample, interpolation='nearest', cmap='gray')
154
    img_array[1][batch_idx].imshow(mask, interpolation='nearest', cmap='gray')
153
    img_array[1][batch_idx].imshow(mask, interpolation='nearest', cmap='gray')
155
plt.show()
154
plt.show()
156
```
155
```
157
![sample](docs/source/_static/samples/gan_sample_00004_dataloader.png)
156
![sample](docs/source/_static/samples/gan_sample_00004_dataloader.png)
158
157
159
## Visualize A Model 
158
## Visualize A Model 
160
With our interface, it is possible to generate sample by manually setting the conditional inputs or latent vector values. The sample is updated in realtime, so it's possible to observe how the images changes when the parameters are modified. The visualization is available only for models with accessible input latent vector. Depending on a model, a conditional input may be also available or synthetic segmentation mask.
159
With our interface, it is possible to generate sample by manually setting the conditional inputs or latent vector values. The sample is updated in realtime, so it's possible to observe how the images changes when the parameters are modified. The visualization is available only for models with accessible input latent vector. Depending on a model, a conditional input may be also available or synthetic segmentation mask.
161
```python
160
```python
162
from medigan import Generators
161
from medigan import Generators
163
162
164
generators = Generators()
163
generators = Generators()
165
# model 10 is "00010_FASTGAN_POLYP_PATCHES_W_MASKS"
164
# model 10 is "00010_FASTGAN_POLYP_PATCHES_W_MASKS"
166
generators.visualize(10)
165
generators.visualize(10)
167
```
166
```
168
167
169
![sample](docs/source/_static/interface.png)
168
![sample](docs/source/_static/interface.png)
170
169
171
## Contribute A Model
170
## Contribute A Model
172
171
173
Create an [__init__.py](templates/examples/__init__.py) file in your model's root folder. 
172
Create an [__init__.py](templates/examples/__init__.py) file in your model's root folder. 
174
173
175
Next, run the following code to contribute your model to medigan.
174
Next, run the following code to contribute your model to medigan.
176
175
177
- Your model will be stored on [Zenodo](https://zenodo.org/). 
176
- Your model will be stored on [Zenodo](https://zenodo.org/). 
178
177
179
- Also, a Github [issue](https://github.com/RichardObi/medigan/issues) will be created to add your model's metadata to medigan's [global.json](https://github.com/RichardObi/medigan/blob/main/config/global.json).
178
- Also, a Github [issue](https://github.com/RichardObi/medigan/issues) will be created to add your model's metadata to medigan's [global.json](https://github.com/RichardObi/medigan/blob/main/config/global.json).
180
179
181
- To do so, please provide a github access token ([get one here](https://github.com/settings/tokens)) and a zenodo access token ([get one here](https://zenodo.org/account/settings/applications/tokens/new/)), as shown below. After creation, the zenodo access token may take a few minutes before being recognized in zenodo API calls.
180
- To do so, please provide a github access token ([get one here](https://github.com/settings/tokens)) and a zenodo access token ([get one here](https://zenodo.org/account/settings/applications/tokens/new/)), as shown below. After creation, the zenodo access token may take a few minutes before being recognized in zenodo API calls.
182
181
183
```python
182
```python
184
from medigan import Generators
183
from medigan import Generators
185
generators = Generators()
184
generators = Generators()
186
185
187
# Contribute your model
186
# Contribute your model
188
generators.contribute(
187
generators.contribute(
189
    model_id = "00100_YOUR_MODEL", # assign an ID
188
    model_id = "00100_YOUR_MODEL", # assign an ID
190
    init_py_path ="path/ending/with/__init__.py",
189
    init_py_path ="path/ending/with/__init__.py",
191
    model_weights_name = "10000",
190
    model_weights_name = "10000",
192
    model_weights_extension = ".pt",
191
    model_weights_extension = ".pt",
193
    generate_method_name = "generate", # in __init__.py
192
    generate_method_name = "generate", # in __init__.py
194
    dependencies = ["numpy", "torch"], 
193
    dependencies = ["numpy", "torch"], 
195
    creator_name = "YOUR_NAME",
194
    creator_name = "YOUR_NAME",
196
    creator_affiliation = "YOUR_AFFILIATION",
195
    creator_affiliation = "YOUR_AFFILIATION",
197
    zenodo_access_token = 'ZENODO_ACCESS_TOKEN',
196
    zenodo_access_token = 'ZENODO_ACCESS_TOKEN',
198
    github_access_token = 'GITHUB_ACCESS_TOKEN',
197
    github_access_token = 'GITHUB_ACCESS_TOKEN',
199
```
198
```
200
Thank you for your contribution! 
199
Thank you for your contribution! 
201
200
202
You will soon receive a reply in the Github [issue](https://github.com/RichardObi/medigan/issues) that you created for your model by running ```generators.contribute()```.
201
You will soon receive a reply in the Github [issue](https://github.com/RichardObi/medigan/issues) that you created for your model by running ```generators.contribute()```.
203
202
204
## Contributions in General
203
## Contributions in General
205
We welcome contributions to medigan. Please send us an email or read the [contributing guidelines](CONTRIBUTING.md) regarding contributing to the medigan project.
204
We welcome contributions to medigan. Please send us an email or read the [contributing guidelines](CONTRIBUTING.md) regarding contributing to the medigan project.
206
205
207
## Reference
206
## Reference
208
207
209
If you use a medigan model in your work, please cite its respective publication ([see references](#available-models)). 
208
If you use a medigan model in your work, please cite its respective publication ([see references](#available-models)). 
210
209
211
Please also consider citing the medigan paper:
210
Please also consider citing the medigan paper:
212
211
213
> [Osuala, R., Skorupko, G., Lazrak, N., Garrucho, L., García, E., Joshi, S., ... & Lekadir, K. (2023). medigan: a Python library of pretrained generative models for medical image synthesis. Journal of Medical Imaging, 10(6), 061403.](https://doi.org/10.1117/1.JMI.10.6.061403)
212
[Osuala, R., Skorupko, G., Lazrak, N., Garrucho, L., García, E., Joshi, S., ... & Lekadir, K. (2023). medigan: a Python library of pretrained generative models for medical image synthesis. Journal of Medical Imaging, 10(6), 061403.](https://doi.org/10.1117/1.JMI.10.6.061403)
214
213
215
BibTeX entry:
214
BibTeX entry:
216
```bibtex
215
```bibtex
217
@article{osuala2023medigan,
216
@article{osuala2023medigan,
218
  title={medigan: a Python library of pretrained generative models for medical image synthesis},
217
  title={medigan: a Python library of pretrained generative models for medical image synthesis},
219
  author={Osuala, Richard and Skorupko, Grzegorz and Lazrak, Noussair and Garrucho, Lidia and Garc{\'\i}a, Eloy and Joshi, Smriti and Jouide, Socayna and Rutherford, Michael and Prior, Fred and Kushibar, Kaisar and others},
218
  author={Osuala, Richard and Skorupko, Grzegorz and Lazrak, Noussair and Garrucho, Lidia and Garc{\'\i}a, Eloy and Joshi, Smriti and Jouide, Socayna and Rutherford, Michael and Prior, Fred and Kushibar, Kaisar and others},
220
  journal={Journal of Medical Imaging},
219
  journal={Journal of Medical Imaging},
221
  volume={10},
220
  volume={10},
222
  number={6},
221
  number={6},
223
  pages={061403},
222
  pages={061403},
224
  year={2023},
223
  year={2023},
225
  publisher={SPIE}
224
  publisher={SPIE}
226
}
225
}
227
```
226
```