Skip to content

Commit

Permalink
update readme and test name examples
Browse files Browse the repository at this point in the history
  • Loading branch information
taigw committed Jan 13, 2018
1 parent c4c85df commit 304638d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 32 deletions.
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Overview
This repository provides source code and pre-trained models for brain tumor segmentation with BraTS dataset. The method is detailed in [1], and it won the 2nd place of MICCAI 2017 BraTS Challenge.
This repository provides source code and pre-trained models for brain tumor segmentation with BraTS dataset. The method is detailed in [1], and it won the 2nd place of MICCAI 2017 BraTS Challenge. In addition, it is adapted to deal with BraTS 2015 dataset.

This implementation is based on NiftyNet and Tensorflow. While NiftyNet provides more automatic pipelines for dataloading, training, testing and evaluation, this naive implementation only makes use of NiftyNet for network definition, so that it is lightweight and extensible. A demo that makes more use of NiftyNet for brain tumor segmentation is proivde at
https://cmiclab.cs.ucl.ac.uk/CMIC/NiftyNet/tree/dev/demos/BRATS17
Expand All @@ -26,60 +26,60 @@ An example of brain tumor segmentation result.
pip install niftynet
```

* BraTS dataset. Data can be downloaded from http://braintumorsegmentation.org/
* BraTS 2015 or 2017 dataset. Data can be downloaded from http://braintumorsegmentation.org/

# How to use
## 1, Prepare data
* Download BraTS dataset, and uncompress the file to `./data` folder. For example, the training set will be in `./data/Brats17TrainingData` and the validation set will be in `./data/Brats17ValidationData`.
* Download BraTS dataset, and uncompress the training and tesing zip files. For example, the training set will be in `data_root/BRATS2015_Training` or `data_root/Brats17TrainingData` and the validation set will be in `data_root/BRATS2015_Validation`.

* Process the data. Run:

```bash
python pre_process.py
```

## 2, Use pre-trained models
* Download pre-trained models from https://drive.google.com/open?id=1moxSHiX1oaUW66h-Sd1iwaTuxfI-YlBA, and save these files in `./model_pretrain`.
* Obtain binary segmentation of whole tumors, run:
## 2, Use pre-trained models to segment images
* To segment BraTS 2015 data, run:

```bash
python test.py config/test_wt.txt
python test.py config15/test_all_class.txt
```
* Obtain segmentation of all the tumor subregions, run:
* To segment BraTS 2017 data, run:

```bash
python test.py config/test_all_class.txt
python test.py config17/test_all_class.txt
```


## 3, How to train
The trainig process needs 9 steps, with axial view, sagittal view, coronal view for whole tumor, tumor core, and enhancing core, respectively.

The following commands are examples for these steps. However, you can edit the corresponding `*.txt` files for different configurations.
The following commands are examples for BraTS 2017. However, you can edit the corresponding `*.txt` files for different configurations.

* Train models for whole tumor in axial, sagittal and coronal views respectively. Run:

```bash
python train.py config/train_wt_ax.txt
python train.py config/train_wt_sg.txt
python train.py config/train_wt_cr.txt
python train.py config17/train_wt_ax.txt
python train.py config17/train_wt_sg.txt
python train.py config17/train_wt_cr.txt
```
* Train models for tumor core in axial, sagittal and coronal views respectively. Run:

```bash
python train.py config/train_tc_ax.txt
python train.py config/train_tc_sg.txt
python train.py config/train_tc_cr.txt
python train.py config17/train_tc_ax.txt
python train.py config17/train_tc_sg.txt
python train.py config17/train_tc_cr.txt
```
* Train models for enhancing core in axial, sagittal and coronal views respectively. Run:

```bash
python train.py config/train_en_ax.txt
python train.py config/train_en_sg.txt
python train.py config/train_en_cr.txt
python train.py config17/train_en_ax.txt
python train.py config17/train_en_sg.txt
python train.py config17/train_en_cr.txt
```

* To save the time for training, you may use the modals in axial view as initalizations for sagittal and coronal views. Copy variales in axial view to those in sagittal or coronal view by running:
```bash
python util/rename_variables.py
```
You may need to edit this file to set different parameters. As an example for Brats 2015, after running this command, you will see a model named `model15/msnet_tc32sg_init` that is copied from `model15/msnet_tc32_20000.ckpt`. Then just set `start_iteration=1` and `model_pre_trained=model15/msnet_tc32sg_init` in `config15/train_tc_sg.txt`.

## 4, How to test
Similar to 'Use pre-trained models', write a configure file that is similar to `config/test_wt.txt` or `config/test_wt.txt` and
Similar to 'Use pre-trained models', write a configure file that is similar to `config15/test_all_class.txt` or `config17/test_all_class.txt` and
set the value of model_file to your own model files. Run:
```bash
python test.py your_own_config_for_test.txt
Expand All @@ -88,6 +88,6 @@ python test.py your_own_config_for_test.txt
## 5, Evaluation
Calcuate dice scores between segmentation and the ground truth, run:
```bash
python evaluation.py
python util/evaluation.py
```
You may need to edit the parameters for segmentation folder and ground truth folder.
You may need to edit this file to specify folders for segmentation and ground truth.
2 changes: 1 addition & 1 deletion config15/test_all_class.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[data]
data_root = /home/guotwang/data/BRATS2015_Training
save_folder = result15
data_names = config15/test_names.txt
data_names = config15/test_names_temp.txt
modality_postfix = [Flair, T1, T1c, T2]
file_postfix = mha

Expand Down
2 changes: 2 additions & 0 deletions config15/test_names_temp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HGG/brats_tcia_pat417_0001
HGG/brats_tcia_pat205_0001
2 changes: 1 addition & 1 deletion config15/test_wt.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[data]
data_root = /home/guotwang/data/BRATS2015_Training
save_folder = result15
data_names = config15/test_names.txt
data_names = config15/test_names_temp.txt
modality_postfix = [Flair, T1, T1c, T2]
file_postfix = mha

Expand Down
2 changes: 1 addition & 1 deletion config17/test_all_class.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[data]
data_root = /home/guotwang/data/Brats17TrainingData
save_folder = result17
data_names = config17/test_names.txt
data_names = config17/test_names_temp.txt
modality_postfix = [flair, t1, t1ce, t2]
file_postfix = nii.gz

Expand Down
2 changes: 2 additions & 0 deletions config17/test_names_temp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HGG/Brats17_CBICA_ATX_1
HGG/Brats17_CBICA_AXN_1
2 changes: 1 addition & 1 deletion config17/test_wt.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[data]
data_root = /home/guotwang/data/Brats17TrainingData
save_folder = result17
data_names = config17/test_names.txt
data_names = config17/test_names_temp.txt
modality_postfix = [flair, t1, t1ce, t2]
file_postfix = nii.gz

Expand Down

0 comments on commit 304638d

Please sign in to comment.