This repo contains Matlab codes for generating input data and python codes for running Diffusion-QSM.
Diffusion-QSM: diffusion model with time-travel and resampling refinement for quantitative susceptibility mapping https://ieeexplore.ieee.org/document/11147123
Our codes are built upon openai/guided-diffusion, you may install the environment based on openai/guided-diffusion.
- STISuite 3.0
- PyTorch 2.4.1
- Python 3.8
data_prep
test data preparation, run demo.m to generate data_DiffusionQSM.mat under data_prep/data folder
guided_diffusion
files for DDPM and QSM-related codes, important files include gaussian_diffusion.py and data_consistent.py
weights
trained weight model700000.pt from Google Drive
QSM_Diffusion_train.py
training code, train the diffusion network using this script
recon.py
inference code, recommend to adjust only in variable args_params
Data preparation
- Generate test data
data_DiffusionQSM.matcontainingphi_use,mask,D2andpad_sizebased on thedemo.mfiles indata_prepfolder. You can download one test data via Google Drive. - Download the trained weight of the network via Google Drive and place it in
weightsfolder - Adjust the
args_paramsinrecon.py
Training
- Generate your own training patch-wise dataset (64x64x64 dimension)
- Run
QSM_Diffusion_train.pyfor network training
Testing
- Run
recon.pyfor generating Diffusion-QSM output - The results are saved under
data_prep/data/results
Feel free to contact zhangming430424@gmail.com for questions/discussions/suggestions.