Author: Zhennong Chen, PhD
This is the GitHub repo based on an paper under rewivew:
Diffusion-based Synthesis of Cardiac 4D Computed Tomography via Learned Cardiac Motion Vector Fields
Authors: Zhennong Chen, Dufan Wu, Quanzheng Li
Citation: TBD
We have proposed the first method to synthesize a cardiac 4DCT sequence given a patient's 3DCT data and a specified ejection fraction (EF).
The main contributions are as follows:
(1) instead of directly synthesizing 4DCT data, we propose to learn and synthesize cardiac motion vector fields (MVF) using a diffusion model. MVFs can be compactly synthesized in a downsampled form and later applied to the 3DCT template via warping to reconstruct 4DCT sequences.
(2) we introduce a novel method for counterfactual 4DCT synthesis conditioned on varying values of left ventricular ejection fraction (LVEF). Please refer "mapping function" in our paper.
The entire code is containerized. This makes setting up environment swift and easy. Make sure you have nvidia-docker and Docker CE installed on your machine before going further.
- You can build your own docker from the folder
docker. The docker image can be built by./docker_build.sh, after that the docker container can be built by./docker_run.sh. The installed packages can be referred todockerfileandrequirements.txt - You'll need
docker/docker_tensorflowfor step 1 anddocker/docker_torchfor the rest steps
You should prepare two things before running this step. Please refer to the example_data folder for guidance:
-
NIfTI images of 4DCT resampled to a voxel size of [1.5, 1.5, 1.5] mm³.
- Each cardiac phase should be saved as a separate file.
- All files should be placed in a folder named:
img-nii-resampled-1.5mm.
-
A patient list that enumerates all your cases.
- To understand the expected format, please refer to the file:
example_data/Patient_lists/example_data/patient_list.xlsx. - Make sure the number of time frames is equal to the number of nii files
- To understand the expected format, please refer to the file:
-
Please refer
example_datafolder for examples.
we have designed our study into 5 steps, with each step having its own jupyter notebook.
step1: get ground truth MVF: use step1_get_MVF.ipynb, it uses Voxelmorph generated ground truth MVF for each 4DCT case saved in a folder called mvf_warp0_onecase
step2: data preparation: use step2_data_preprocessing.ipynb, it does the following tasks:
- Prepare the left ventricular (LV) segmentation masks using pre-trained network (in the folder
segmentation_network). it should save the segmentation in a folder calledpredicted_seg - Sample the original time frames into 10 evenly spaced cardiac phases and Get ground truth Ejection fraction (LVEF) for each case. it should save these info in a spreadsheet in
Patient_lists/example_data/patient_list_final_selection_timeframes - Prepare augmented data for training (since data is large, on-the-fly augmentation will be time-consuming). it should save the augmented data in a folder called
mvf_aug
step3: train diffusion model: use step3_train_model.ipynb
step4: synthesize MVF: use step4_MVF_synthesis.ipynb
step5: synthesize 4DCT: use step5_4DCT_synthesis.ipynb, it applies the synthesized MVF to the 3DCT template for 4DCT generation
Please contact chenzhennong@gmail.com for any further questions.