Giter Club home page Giter Club logo

pytorch-iterativefcn's Introduction

Iterative fully convolutional neural networks for automatic vertebra segmentation

This is a Pytorch implementation of the paper Iterative fully convolutional neural networks for automatic vertebra segmentation accepted in MIDL2018. This paper provides and automatic mechanism for precise vertebrae segmentation on CT images. I create this project for polishing up my knowledge of deep learning in medical image. There is an updated version Iterative fully convolutional neural networks for automatic vertebra segmentation and identificationin 2019 with similiar structure. For the reason of computational cost, I decided to implement the early version in 2018.

Model

This is the model illustration from the paper. This model contains a similiar shape like 3D U-Net but with constant channel in every layer and a extend branch for classification propose. There are 2 inputs for this model, inclusing image patch and correspond instanace memory patches. Instance Memory is used to remind the model to segment the first 'unsegmented vertebrae' so as to make sure the vertebrae are segmented one by one.

ad

Dataset and Pre-processsing

1. Dataset

I choose one of the dataset used in the paper, The spine segmentation challenge in CSI2014. The dataset can be obtain in the Dataset 2 posted on SpineWeb

2. Data preprocessing

The preprocessing steps of each CT images and corresponded masks(both train and test set) includes:

  • Resample the images and masks to isotropic (1mm * 1mm * 1mm)
  • Calculate the weight penalty coefficient for each images via distance transform.
  • Crop the images and masks to remove the vertebrae that not have labels in masks.
  • Prepare the training patches, including "image patches", "instance memory patches", "mask patches" and "weight patches".

3. Illustration of training patches.

A normal set of a training patches is showned as follows:

ad

Since our model using slide window to segment the vertebrae, we need to teach it to produce empty prediction when their is no vertebrae in the image or all vertebrae are segmented and recorded in instnace memory:

ad

Training Detail

I apply the same setting as suggested in papers:

  • Batch-size = 1 due to GPU memory limitation.
  • Adam with learning rate = 1e-3
  • Apply data augmentation via elastic deformation, gaussain blur, gaussian noise, random crop along z-axis
  • Produce empty mask training example every 5th iteratons.

I trained this model on Google Colab, which has similiar CUDA Memory(12GB) with NVIDIA TITANX. The provided pretrained weight here is trained only with around 25000 iterations. The initial learning rate at 1e-3 from 1 to 10000 iterations, 1e-4 for 10001 to 20000 and 1e-5 for the rest of iterations, which is different from paper that using 1e-3 for whole training.

Segmentation Result

The following are some segmentation result from both train and test data.

(1)Visual Result

ad

(2)Averge Dice Coefficient

Result Paper
0.918 0.958

P.S. None of refine technique for preprocessing and postprocessing are used in this repo.

Usage

Setup the Environment

The requirment.txt are provided in the repo

pip install -r requirements.txt

Preprocessing the CSI dataset

python -m data.preprocessing --dataset 'the root path of CSI dataset'

Start Training

python train.py --dataset 'the directory of preprocessed CSI dataset'

Instance Segmentation

python instance_segmentation.py --test_dir 'the directory of test images' --weights 'pretrained weights'

Evaluation the Dice Coefficient with labels

python eval.py --label_dir 'directory of test labels' --pred_dir 'the directory of prediction segmetnation'

Authors

  • HSU, CHIH-CHAO - Professional Machine Learning Master Student at Mila

Reference

Thanks to the information from following sources and kind answer from the paper authors:

pytorch-iterativefcn's People

Contributors

leohsuofnthu 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pytorch-iterativefcn's Issues

It seems that the model was trained with only one subject?

In train.py, you use next(iter(train_loader)) to fetch the patches every iteration.

However , in such way you build an iterator of train_loader every iteration,and next() would return the first element of the iterator every time, which means during the whole iteration there is only one subject is used to training.

I'm just confused about this.Could anyone give me some explanation or discussion?

Step into an endless loop when instance segment images

Hi CHIH CHAO,
When I'm testing the code (instance_segment.py), I found the program will step into an endless loop when segment images (case6, case9...) .
There are two situations in converge iterations:
1.The Modified centre is always the same as prev centre and will not break out of the loop
2.when iters=lim_alternate_times, converge ,update ins and mask, to this point, z_up may exceed the image shape, cause the program to crash. Why does this happen after doing correction to be in-frame?
Looking forward to hearing from you, thank you~

Some question

Hello, Thanks for your great work. The code is very neat and readable, from which I learned a lot.
But I have some questions while implementing this repo on csi2014 dataset.

  1. I set batch_size to 64(model's num_channels=64) but only consumes about 4500Mbit in my GPU(GTX 1080). You said you set batch_size to 1 due to memory limitation. Do you think there is something wrong about my setting considering my low memory use?
  2. In utils.py->force_inside_img(func), you set coordinate inside the image using img_shape[2]. I think it is more reasonable to limit z by img_shape[0], y by img_shape[1] and x by img_shape[2]. I'm not sure if it should be like that.
    Very grateful if you can give me some guide according to my question.

visual results

How can we get 2d visual result from 3d .nrrd or 3d .mhd?

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.