Welcome! This is the official implementation of TUMSyn, which is a Text-guided Universal MR image Synthesis framework. It can flexibly generate brain MR images with demanded image contrast and spatial resolution from routinely-acquired scans guided by imaging metadata as text prompt. The model is trained and evaluated on a brain MR database comprising 31,407 3D images with 7 structural MRI modalities from 13 centers. [Arxiv]
For the MR image synthesis model, the relative storage path of each training/testing image path should be put in .txt files. The example format is shown here. The format of training/testing images are .npy and .nii.gz, respectively. We provide the English template for compiling text prompts. An example of the text prompt is shown below:
"train_HCPD_T1w.npy": "Age: 12; Gender: M; Scanner: 3.0 Siemens; Modality: T1w; Voxel size: (0.8, 0.8, 0.8); Imaging parameter TR(ms), TE(ms), TI(ms), and FA(degree): (2500.0, 2.2, 1000.0, 8.0)"
The content within the first double quotation mark is the image name, while the content within the second double quotation mark contains the corresponding demographic information and imaging parameters for that image. When compiling your text prompts, you just need to place the metadata after each corresponding colon in our format.
The full names of abbreviations as below: - M: Male (If that is a female, use the F) - TR: Repetition time - TE: Echo time - TI: Inversion time - FA: Flip angle
If the metadata does not contain the required information, use “None” as the placeholder.
Examples of training and testing images for the image synthesis model are also provided in Experimental_data directory, and their corresponding text prompts are provided here.
The overview of TUMSyn training
To effectively align and fuse image-text pairs, TUMSyn is built upon a two-stage training strategy. In the first stage (stage 1), we pre-trained a text encoder using contrastive learning to extract textual semantic features that are aligned with the corresponding image features from metadata. Built on the pre-trained text encoder, in the second stage (stage 2), the text encoder is frozen and used to extract prompt features to steer the cross-sequence synthesis.
The following steps can help you to train your own network for text-guided MR image synthesis.
python train.py
The trained network parameters will be saved in the save folder when the training process finishes.
🎉 Congratulations! You now have a powerful brain MRI synthesis model trained on your dataset. You can use demo code to easily perform inference with the trained model. If you simply want to try out the model without training it yourself, a pre-trained version is publicly available here
Note: The model should be run on a Linux machine with GPU.
train_lccd_sr.yaml, which is used to set all training/validation parameters.lccd.py, which is a wrapper around the model. It also contains the network architectures of all the modules used in the image synthesis model.$ claude mcp add TUMSyn \
-- python -m otcore.mcp_server <graph>