Giter Club home page Giter Club logo

genericssl's Introduction

[NeurIPS-2023] Towards Generic Semi-Supervised Framework for Volumetric Medical Image Segmentation

This repo is the official implementation of Towards Generic Semi-Supervised Framework for Volumetric Medical Image Segmentation which is accepted at NeurIPS-2023.

πŸš€ The significance of this work lies in its ability to encourage semi-supervised medical image segmentation methods to address more complex real-world application scenarios, rather than just developing frameworks in ideal experimental environments. Furthermore, we have consolidated all four settings within this single codebase, enabling the execution of any task using a single bash file by merely adjusting the arguments.

Online Presentation Video is available for brief introduction.

1. Environment

First, create a new environment and install the requirements:

conda create -n genericssl python=3.8
conda activate genericssl
cd GenericSSL/
pip install -r requirements.txt

[πŸ“ŒIMPORTANT] Then, before running the code, set the PYTHONPATH to pwd:

export PYTHONPATH=$(pwd)/code:$PYTHONPATH

2. Data Preparation

First, download the datasets and put them under the Datasets folder:

The file structure should be:

.
β”œβ”€β”€ Datasets
β”‚Β Β  β”œβ”€β”€ LASeg
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ 2018LA_Seg_Training Set
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ 0RZDK210BSMWAA6467LU
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mri_norm2.h5
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ 1D7CUD1955YZPGK8XHJX
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── ...
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test.list
β”‚Β Β  β”‚Β Β  └── train.list
β”‚Β Β  β”œβ”€β”€ MMWHS
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CT
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ imagesTr
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ct_train_1001_image.nii.gz
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── ...
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── labelsTr
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ct_train_1001_label.nii.gz
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── ...
β”‚Β Β  β”‚Β Β  └── MR
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ imagesTr
β”‚Β Β  β”‚Β Β      └── labelsTr
β”‚Β Β  β”œβ”€β”€ MNMs
β”‚Β Β  β”‚Β Β  └── Labeled
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ VendorA
β”‚Β Β  β”‚Β Β   Β Β  β”‚Β Β  β”œβ”€β”€ A0S9V9
β”‚Β Β  β”‚Β Β   Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ A0S9V9_sa.nii.gz
β”‚Β Β  β”‚Β Β   Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ A0S9V9_sa_gt.nii.gz
β”‚Β Β  β”‚Β Β   Β Β  β”‚Β Β  β”œβ”€β”€ A1D9Z7
β”‚Β Β  β”‚Β Β   Β Β  β”‚Β Β  └── ...
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ VendorB
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ VendorC
β”‚Β Β  β”‚Β Β      └── VendorD
β”‚Β Β  β”œβ”€β”€ OpenDataset
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Testing
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Training
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Validation
β”‚Β Β  β”‚Β Β  └── mnms_dataset_info.xls
β”‚Β Β  └── Synapse
β”‚Β Β      β”œβ”€β”€ imagesTr
β”‚Β Β   Β Β  β”‚Β Β  β”œβ”€β”€img0001.nii.gz
β”‚Β Β   Β Β  β”‚Β Β  └── ...
β”‚Β Β      └── labelsTr
β”‚Β Β   Β Β   Β Β  β”œβ”€β”€label0001.nii.gz
β”‚Β Β   Β Β   Β Β  └── ...

2.1 Pre-process LASeg dataset

Run python ./code/data/preprocess_la.py to:

  • convert .h5 files to .npy.
  • generate the labeled/unlabeled splits

2.2 Pre-process Synapse dataset

Run python ./code/data/preprocess_synapse.py to

  • resize the images and convert to .npy for faster loading;
  • generate the train/test splits (use labeled data for validation);
  • generate the labeled/unlabeled splits.

2.3 Pre-process MMWHS dataset

Run python ./code/data/preprocess_mmwhs.py to:

  • reorient to the same orientation, RAI;
  • convert to continuous labels;
  • crop centering at the heart region;
  • for each 3D cropped image top 2/% of its intensity histogram was cut off for alleviating artifacts;
  • resize and convert to .npy;
  • generate the train/validation/test splits.

2.4 Pre-process M&Ms dataset

Run python ./code/data/preprocess_mnms.py to:

  • split the original 4D data to 3D along the time axis;
  • crop and resize;
  • save to .npy;
  • generate the train/test splits (use labeled data for validation);
  • generate the labeled/unlabeled splits.

For all the pre-processing, you can comment out the functions corresponding to splits and use our pre-split files.

Finally, you will get a file structure as follow:

.
β”œβ”€β”€ Synapse_data
β”‚   β”œβ”€β”€ npy
β”‚   β”‚   β”œβ”€β”€ <id>_image.npy
β”‚   β”‚   β”œβ”€β”€ <id>_label.npy
β”‚   β”‚   └── ...
β”‚   └── split_txts
β”‚       β”œβ”€β”€ labeled_0.2.txt
β”‚       β”œβ”€β”€ unlabeled_0.2.txt
β”‚       β”œβ”€β”€ train.txt
β”‚       β”œβ”€β”€ eval.txt
β”‚       β”œβ”€β”€ test.txt
β”‚       └── ...
β”œβ”€β”€ LA_data
β”‚   └── ...
β”œβ”€β”€ MMWHS_data
β”‚   └── ...
└── MNMS_data
    └── ...

3. Training & Testing & Evaluating

πŸ”₯πŸ”₯ This codebase allows train, test, and evaluate on all the four settings using one single bash file. πŸ”₯πŸ”₯

Run the following commands for training, testing and evaluating.

bash train.sh -c 0 -e diffusion -t <task> -i '' -l 1e-2 -w 10 -n 300 -d true 

Parameters:

-c: use which gpu to train

-e: use which training script, can be diffusion for train_diffusion.py, or diffusion_2d for train_diffusion_2d.py

-t: switch to different tasks:
Β  Β  Β  Β  Β  For SSL on 5% labeled LA dataset: la_0.05
Β  Β  Β  Β  Β  For IBSSL on 20% labeled Synapse dataset: synapse_0.2
Β  Β  Β  Β  Β  For UDA on MMWHS dataset: mmwhs_ct2mr for labeled CT and unlabeled MR, mmwhs_mr2ct in opposite
Β  Β  Β  Β  Β  For SemiDG on M&Ms dataset, 2% labeled B,C,D -> A setting: mnms_A_0.02; 5% labeled A,B,C -> D setting: mnms_D_0.05

-i: name of current experiment, can be whatever you like

-l: learning rate

-w: weight of unsupervised loss

-n: max epochs

-d: whether to train, if true, training -> testing -> evaluating; if false, testing -> evaluating

4. Results & Model Weights


🌟🌟 All trained model weights can be downloaded from this link. 🌟🌟


Put the logs directory under the root directory of this repo and set -d False, then you can test and evaluate the models.

4.1 Imbalance SSL on Synapse dataset

Result_IBSSL.png

4.2 SSL on LASeg dataset & UDA on MMWHS dataset

Result_SSL_UDA.png

4.3 SemiDG on M&Ms dataset

Result_SemiDG.png

Citations

If this code is helpful for your study, please cite:

@inproceedings{wang2023towards,
  title={Towards Generic Semi-Supervised Framework for Volumetric Medical Image Segmentation},
  author={Wang, Haonan and Li, Xiaomeng},
  booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
  year={2023}
}

Contact

Haonan Wang ([email protected])

License

This repository is released under MIT License.

genericssl's People

Contributors

mcgregorwwww avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

genericssl's Issues

Running with other dataset

Hi,

Thank you for your great work. Would it be possible to provide a quick guide on how to run this code with different datasets other than the four mentioned in the paper?

Thanks!

The results of training dice on the new data set

Hello, sorry to bother you . I have processed the scgm data set and trained it on the genericsl code you provided. This is the result displayed during the training process:
1
2
But the dice value of the running result is very low. Is it because there are too few samples in the scgm data set? This is using 20% of the scgm dataset train_toA_labeled_0.2.txt file, which has only 6 site2-sc03-image site2-sc07-image site3-sc03-image site3-sc08-image site4-sc04-image site4-sc07-image.If you have time, I hope you can give me some suggestions and I look forward to your reply. Thank you so much!

Request more detailed experimental parameters

Hi,
Thank you very much for your remarkable work. I've conducted experiments on the LA dataset using the configuration consistent with Table 8 in your paper (same with the config file). The obtained results show some variance from those reported in the paper. Could you please advise if there are any additional parameters I should adjust to better replicate your reported results on the LA dataset?

Thank you very much for your assistance.

SCGM dataset

Hello, I would like to ask if you have done experiments on the SCGM dataset?If so, can you share your experimental results on this?

Request more detailed experimental parameters

Hi,

Thank you very much for your excellent work. I would like to ask for a guide on using the dataset mentioned in your paper. I have attempted multiple rounds of training on the Synapse dataset and tried different epochs, but found that the accuracy of the reproduced results still differs from the data in your paper. May I ask if it is possible to provide more detailed parameter explanations so that I can better reproduce your results?

Thank you very much for your help!

train_diffusion_2d.py

Hi, thanks for the code. I would like to ask, do train_diffusion_2d.py and train_diffusion.py in your code handle 2d slice data and 3d data respectively?
Is there a big difference in accuracy between running train_diffusion_2d.py and train_diffusion.py?

backbone

Hi, thank you for sharing the code. Does your train_diffusion_2d.py use unet as the backbone?

recurrent

Hello, I conducted an experiment on the m&ms data set according to the DiffUNet.txt you provided. I can achieve an accuracy of about 72% on 2% of the D domain, and an accuracy of about 69% on the 2% of the A domain. , the effect is very different from what you said. I would like to ask if you set some specific parameters when using unet as backbone training?

3d scgm

Hello, I would like to ask if you have a way to process the scgm data set that your network can receive? The scgm data sets I processed before were all processed into 2D slices. Can I directly modify your preprocess_mnms.py code? Looking forward to your reply, thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.