This is a forked Github repository containing the code used for my semester project conducted in the Center for MR-Research, University Children's Hospital Zürich and Swiss Federal Institute of Technology. The semester project was supervised by Prof. Dr. Andras Jakab and Prof. Dr. Ender Konukoglu.
In this semester project, Med-DDPM, a denoising diffusion probabilistic model, is employed to generate high-quality 3D MR images of the developing human brain, attempting to address some of the limitations of traditional GAN-based methods. The work focuses on developing and refining the existing Med-DDPM for semantic 3D MRI synthesis using brain tissue label maps and compares its performance with the SPADE GAN method. Results demonstrate Med-DDPM's capabilities to generate realistic, anatomically detailed, coherent fetal MR images with improved statistical accuracy and signal clarity. However, it falls short in reliably and consistently producing these high-quality images compared to SPADE GAN. This exploration contributes to the field of medical imaging by offering a novel approach for generating realistic fetal MRIs from a label map representing anatomical brain tissues.
Ensure you have the following libraries installed for training and generating images:
- Torchio: Torchio GitHub
- Nibabel: Nibabel GitHub
pip install -r requirements.txt
Med-DDPM is versatile. If you're working with image formats other than NIfTI (.nii.gz), modify the `read_image` function in `dataset.py`.
- Specify the segmentation mask directory with `--inputfolder`.
- Set the image directory using `--targetfolder`.
- If you have more than 4 segmentation mask label classes, update channel configurations in `train.py`, `datasets.py`, and `utils/dtypes.py`.
Specify dataset paths using `--inputfolder` and `--targetfolder`:
- Fetal MRI synthesis: 128x128x128 - 256x256x256
- Optionally: Define image size in `diffusion_model/unet.py`
fetal MRI synthesis:$ ./scripts/train.sh
Requests to access the model weights and fetal datasets should be directed to: Andras Jakab
After obtaininig and downloading the model weights, place the files under the "model" directory.
To create images, follow these steps:
- Fetal MRI synthesis: 128x128x128 - 256x256x256
- Set the learned weight file path with `--weightfile`.
- Determine the input mask file using `--inputfolder`.
fetal MRI synthesis:$ ./scripts/sample.sh