Giter Site home page Giter Site logo

sha168 / adnet Goto Github PK

View Code? Open in Web Editor NEW
25.0 1.0 9.0 254 KB

Code for the paper "Anomaly Detection-Inspired Few-Shot Medical Image Segmentation Through Self-Supervision With Supervoxels".

License: MIT License

Dockerfile 0.47% Python 70.27% Shell 2.58% Cython 26.68%

adnet's Introduction

ADNet

Code for the paper "Anomaly Detection-Inspired Few-Shot Medical Image Segmentation Through Self-Supervision With Supervoxels", published in Medical Image Analysis.

Abstract

Recent work has shown that label-efficient few-shot learning through self-supervision can achieve promising medical image segmentation results. However, few-shot segmentation models typically rely on prototype representations of the semantic classes, resulting in a loss of local information that can degrade performance. This is particularly problematic for the typically large and highly heterogeneous background class in medical image segmentation problems. Previous works have attempted to address this issue by learning additional prototypes for each class, but since the prototypes are based on a limited number of slices, we argue that this ad-hoc solution is insufficient to capture the background properties. Motivated by this, and the observation that the foreground class (e.g., one organ) is relatively homogeneous, we propose a novel anomaly detection-inspired approach to few-shot medical image segmentation in which we refrain from modeling the background explicitly. Instead, we rely solely on a single foreground prototype to compute anomaly scores for all query pixels. The segmentation is then performed by thresholding these anomaly scores using a learned threshold. Assisted by a novel self-supervision task that exploits the 3D structure of medical images through supervoxels, our proposed anomaly detection-inspired few-shot medical image segmentation model outperforms previous state-of-the-art approaches on two representative MRI datasets for the tasks of abdominal organ segmentation and cardiac segmentation.

@article{hansen2022anomaly,
  title={Anomaly Detection-Inspired Few-Shot Medical Image Segmentation Through Self-Supervision With Supervoxels},
  author={Hansen, Stine and Gautam, Srishti and Jenssen, Robert and Kampffmeyer, Michael},
  journal={Medical Image Analysis},
  pages={102385},
  year={2022},
  publisher={Elsevier}
}

Getting started

Requirements

Requirements are included in the Dockerfile.

Data sets and pre-processing

Download:

  1. Combined Healthy Abdominal Organ Segmentation data set
  2. Multi-sequence Cardiac MRI Segmentation data set (bSSFP fold)

Pre-processing is performed according to Ouyang et al. and we follow the procedure on their github repository.

Training

  1. Compile ./supervoxels/felzenszwalb_3d_cy.pyx with cython (python ./supervoxels/setup.py build_ext --inplace) and run ./supervoxels/generate_supervoxels.py
  2. Download pretrained 3D ResNeXt weights. We use the pre-trained weights in resnext-101-kinetics.pth from Hara et al. which is available on their github repository. Note: Follow the link for the old pretrained weights.
  3. Run ./script/train_<abd, cmr>_<2D, 3D>.sh

Inference

Run ./script/test_<abd, cmr>_<2D, 3D>.sh

adnet's People

Contributors

sha168 avatar

Stargazers

He Jiabei avatar  avatar  avatar Dai X avatar  avatar pascalcpp avatar yfxie avatar  avatar zling avatar  avatar TZ Zhou avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Yuting Lin avatar EyesU Xiao avatar  avatar Michael Kampffmeyer avatar

Watchers

 avatar

adnet's Issues

Hello, I encountered KeyError: '/home/lijing/ADNet-main/data/CHAOST2/chaos_MR_T2_normalized/image_21.nii.gz' when running train_abd_3D.sh

bash scripts/train_abd_3D.sh
Namespace(EP1=False, all_slices=True, batch_size=1, bg_wt=0.1, data_root='/home/lijing/ADNet-main/data/CHAOST2', dataset='CHAOST2', fold=0, lr=0.001, lr_gamma=0.95, max_iterations=1000, max_slices=10, min_size=200, momentum=0.9, n_query=1, n_shot=1, n_sv=5000, n_way=1, save_root='/home/lijing/ADNet-main/results_abd_3d/train/fold0', seed=2021, steps=50000, t_loss_scaler=1.0, weight_decay=0.0005, workers=4)
Loading pre-trained weights!
Training on images not in test fold: ['/chaos_MR_T2_normalized/image_10.nii.gz', '/chaos_MR_T2_normalized/image_13.nii.gz', '/chaos_MR_T2_normalized/image_15.nii.gz', '/chaos_MR_T2_normalized/image_19.nii.gz', '/chaos_MR_T2_normalized/image_20.nii.gz', '/chaos_MR_T2_normalized/image_21.nii.gz', '/chaos_MR_T2_normalized/image_22.nii.gz', '/chaos_MR_T2_normalized/image_31.nii.gz', '/chaos_MR_T2_normalized/image_32.nii.gz', '/chaos_MR_T2_normalized/image_33.nii.gz', '/chaos_MR_T2_normalized/image_34.nii.gz', '/chaos_MR_T2_normalized/image_36.nii.gz', '/chaos_MR_T2_normalized/image_37.nii.gz', '/chaos_MR_T2_normalized/image_38.nii.gz', '/chaos_MR_T2_normalized/image_39.nii.gz']
Start training ...
Traceback (most recent call last):
File "main_train_3D.py", line 178, in
main()
File "main_train_3D.py", line 103, in main
scheduler, epoch, args)
File "main_train_3D.py", line 134, in train
for i, sample in enumerate(train_loader):
File "/home/lijing/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 628, in next
data = self._next_data()
File "/home/lijing/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1333, in _next_data
return self._process_data(data)
File "/home/lijing/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1359, in _process_data
data.reraise()
File "/home/lijing/anaconda3/lib/python3.7/site-packages/torch/_utils.py", line 543, in reraise
raise exception
KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/lijing/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/lijing/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 58, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/lijing/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 58, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/lijing/ADNet-main/dataloading/datasets_3D.py", line 213, in getitem
img = self.images[self.image_dirs[pat_idx]]
KeyError: '/home/lijing/ADNet-main/data/CHAOST2/chaos_MR_T2_normalized/image_21.nii.gz'

The preprocessing of the image follows ouyang, and it can be trained normally in the ouyang project, and the file generate_supervoxels.py can also be run.

A problem of Supervoxel generation

Supervoxels were generated for 3D data in AD-Net, but when I displayed the images in the generated Supervoxels, the quality of the generated Supervoxels was not good in terms of pure visual perception. I also displayed the superpix of ouyang under the same image, which felt good. Specific visible images.

image
image
a982f95ec063a13b31d8c9c7b07c9dac

This picture is the 33rd image of image_37.nii.gz, the top two images are taken from the supervoxel generated by AD-Net, and the following images are the superpix generated by ouyang.

This picture is the ground truth.
image

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.