Skip to content

Repository files navigation

FSDA-DG: Single Domain Generalization for Medical Image Segmentation with Few Source Domain Annotations

This repository is the official PyTorch implementation of our paper: "FSDA-DG:Single Domain Generalization Medical Image Segmentation with Few Source Domain Annotations".

📢 News

  • [2025.06.17] FSDA-DG has accepted by Medical Image Analysis (MedIA) !🎉
  • [2024.11.10] We open-sourced a simply FSDA-DG code!🎉**

Main framework overview and results

Main framework

Results

Main framework

Results

🔧 1. Installation

First, clone this repository and navigate to the project directory:

git clone https://github.com/yezanting/FSDA-DG.git
cd FSDA-DG

Next, install the required dependencies. We recommend using a virtual environment.

pip install -r requirements.txt

📦 2. Data Preparation

We follow the data preparation pipeline from [CSDG]. Please download the datasets and process them as described below.

Abdominal Datasets (CT & MRI)

Abdominal MRI

  1. Download the [Combined Healthy Abdominal Organ Segmentation (CHAOS) dataset].
  2. Place the downloaded /MR folder into the ./data/CHAOST2/ directory.
  3. Run the provided scripts to convert and preprocess the data:
    # Convert DICOM images to NIFTI format
    bash ./data/abdominal/CHAOST2/s1_dcm_img_to_nii.sh
    # Convert PNG ground truth masks to NIFTI format
    python ./data/abdominal/CHAOST2/png_gth_to_nii.ipynp
    # Normalize images and extract Region of Interest (ROI)
    python ./data/abdominal/CHAOST2/s2_image_normalize.ipynb
    python ./data/abdominal/CHAOST2/s3_resize_roi_reindex.ipynb

The processed data will be saved in ./data/abdominal/CHAOST2/processed/.

Abdominal CT

  1. Download the [Synapse Multi-atlas Abdominal Segmentation dataset].
  2. Place the /img and /label folders into the ./data/SABSCT/CT/ directory.
  3. Run the preprocessing scripts:
    python ./data/abdominal/SABS/s1_intensity_normalization.ipynb
    python ./data/abdominal/SABS/s2_remove_excessive_boundary.ipynb
    python ./data/abdominal/SABS/s3_resample_and_roi.ipynb

The processed data will be saved in ./data/abdominal/SABSCT/processed/.

Cardiac Datasets (bSSFP & LGE)

Note: For data preprocessing, please refer to CSDG

The final data directory structure should look like this:

FSDA-DG/
├── data/
│   ├── abdominal/
│   │   ├── CHAOST2/
│   │   │   └── processed/
│   │   └── SABSCT/
│   │       └── processed/
│   └── cardiac/
│       └── processed/
│           ├── bSSFP/
│           └── LGE/
└── ...

🚀 3. Training

All training configurations are defined in the .yaml files within the configs/ directory. You can start training with a single command. A GPU like the NVIDIA 3080 is recommended.

Cross-modality Abdominal Segmentation
  • Direction: CT -> MRI (Train on Synapse, test on CHAOS)

    # Use --labelnum to specify the fraction of labeled data (e.g., 0.1 for 10%)
    python main.py --base configs/efficientUnet_SABSCT_to_CHAOS.yaml --seed 22 --labeled_bs 0.5 --labelnum 0.1
  • Direction: MRI -> CT (Train on CHAOS, test on Synapse)

    python main.py --base configs/efficientUnet_CHAOS_to_SABSCT.yaml --seed 22 --labeled_bs 0.5 --labelnum 0.1
Cross-sequence Cardiac Segmentation
  • Direction: bSSFP -> LGE

    python main.py --base configs/efficientUnet_bSSFP_to_LEG.yaml --seed 22 --labeled_bs 0.5 --labelnum 0.2
  • Direction: LGE -> bSSFP

    python main.py --base configs/efficientUnet_LEG_to_bSSFP.yaml --seed 22 --labeled_bs 0.5 --labelnum 0.2

📊 4. Inference

Download our pretrained models and unzip them into the logs/ directory.

Run the following commands to evaluate the models on the test set.

Example: Cross-sequence Cardiac Segmentation
  • Direction: bSSFP -> LGE (with 50% labeled source samples, DICE 85.87)

    python test.py -r logs/2023-07-31T10-47-53_seed22_efficientUnet_bSSFP_to_LEG_labelnum_0.5
  • Direction: LGE -> bSSFP (with 20% labeled source samples, DICE 83.15)

    python test.py -r logs/2023-08-01T19-14-19_seed22_efficientUnet_LEG_to_BSSFP_labelnum_0.2

Visual segmentation results for each test case will be saved in the corresponding log directory.


🤝 Acknowledgements

Our codes are built upon CSDG, SLAug, and MC-Net, thanks for their contribution to the community and the development of researches!

Releases

Packages

Used by

Contributors

Languages