Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zEttOn86 committed May 18, 2019
1 parent aeac329 commit de4a179
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 7 deletions.
135 changes: 128 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Atlas guided em algorithm
Atlas guided EM Algorithm
---------------------------------

## About this repository
This implementation is based on [Shimizu, A., Ohno, R., Ikegami, T. et al. (2007) Segmentation of multiple organs in non-contrast 3D abdominal CT images, Int J CARS 2: 135. https://doi.org/10.1007/s11548-007-0135-z](https://link.springer.com/article/10.1007/s11548-007-0135-z).

This implementation is based on [Shimizu, A., Ohno, R., Ikegami, T. et al. (2007) Segmentation of multiple organs in non-contrast 3D abdominal CT images, Int J CARS 2: 135. https://doi.org/10.1007/s11548-007-0135-z](https://link.springer.com/article/10.1007/s11548-007-0135-z)
Note this is not official implementation.

Please use at your own responsibility.

## Requirements

Expand All @@ -13,9 +15,9 @@ Nuget package

- Boost

- Itk
- ITK

Another library
Another library (already contained)

- [mist](https://github.com/mist-team/mist)

Expand All @@ -25,5 +27,124 @@ Another library

- Visual Studio 2015

#### Note
In development
- Release x64

## Detail of data

Data I used is as follow:

Label correspondense

| Organs | Label number |
|:---:|:---:|
|others|0|
|liver|1|
|spleen|2|
|kidneyL|3|
|kidneyR|4|
|heart|5|
|gallbladder|6|
|pancreas|7|
|aorta|8|
|IVC|9|
|portal|10|
|stomachWall|11|
|oesophagus|12|

Note:
In this case, i didnt use heart label since it is not included in mask image region.

Example:

|Original|Label|Mask|
|:---:|:---:|:---:|
|<img src='assets/img/resize/fig1.png' width=75%>|<img src='assets/img/resize/fig2.png' width=75%>|<img src='assets/img/resize/fig3.png' width=75%>|

## How to use

First of all, please build all project.

And then, please put your data into `data/preprocessed` folder.

```
data
└─preprocessed
├─abdominal_cavity_mask <--- mask image e.g. region of interest image
├─label <--- label image
└─org <--- original image
```

I show flow chart as bellow:

<img src='assets/img/fig4.png' width=75%>

[Cite](https://www.jstage.jst.go.jp/article/mit/24/3/24_153/_pdf)

#### 1. generate_atlas

Generate atlas.

This program outputs into `results/generate_atlas`.

```
bat\generate_atlas.bat
```

#### 2. compute_features

Compute features each original image.

In this case, we calculate median image.

```
bat\compute_features.bat
```

#### 3. calc_init_val

Compute initial value for em algorithm using training data.

```
bat\calc_init_val.bat
```

#### 4. apply_em_algorithm

Apply em algorithm to test data

```
bat\apply_em_algorithm_using_atlas.bat
```

#### 5. apply_maximum_a_posteriori

Apply maximum a posteriori to test data

```
bat\apply_maximum_a_posteriori.bat
```

## Results

I show example of result.

|Predict|Ground truth|Original|
|:---:|:---:|:---:|
|<img src='assets/img/resize/fig6.png' width=75%>|<img src='assets/img/resize/fig7.png' width=75%>|<img src='assets/img/resize/fig5.png' width=75%>|

I evaluate my result in terms of Jaccard Index.

|organs|JI|
|:---:|:---:|
|liver|0.873291|
|spleen|0.561109|
|kidneyL|0.33408|
|kidneyR|0.0138403|
|gallbladder|0|
|pancreas|0|
|aorta|0.412388|
|IVC|0|
|portal|0|
|stomachWall|0.116285|
|oesophagus|0|
|other| 0.673242|
2 changes: 2 additions & 0 deletions apply_em_algorithm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ int main(int argc, char **argv) {
for (int l = 0; l < TESTTIME_NUM_LABELS; l++) {
std::string result_dir = output_dir + TESTTIME_LABEL_NAMES[l];
make_dir(result_dir);
save_param_as_csv(mean[l], result_dir + "/estimated_mean_param.csv");
save_param_as_csv(covariance[l], result_dir + "/estimated_covariance_param.csv");
write_raw_and_txt(mean[l], result_dir + "/estimated_mean_param");
write_raw_and_txt(covariance[l], result_dir + "/estimated_covariance_param");
} /* Label loop */
Expand Down
Binary file added assets/img/fig1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/fig2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/fig3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/fig4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/fig5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/fig6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/fig7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/resize/fig1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/resize/fig2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/resize/fig3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/resize/fig5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/resize/fig6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/resize/fig7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions calc_init_val/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ int main(int argc, char **argv) {
std::cout << "----- Save param -----" << std::endl;
std::string result_dir = output_dir + LABEL_NAMES[l];
make_dir(result_dir);
save_param_as_csv(total_feat_mean, result_dir + "/mean_param.csv");
save_param_as_csv(total_feat_covariance, result_dir + "/covariance_param.csv");
write_raw_and_txt(total_feat_mean, result_dir + "/mean_param");
write_raw_and_txt(total_feat_covariance, result_dir + "/covariance_param");

Expand Down
9 changes: 9 additions & 0 deletions headers/dataIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,12 @@ void read_raw_to_eigen(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& eigen,
eigen = Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>(&v[0], row_size, col_size);
}

template <class T>
void save_param_as_csv(Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &eigen, std::string filename) {

std::ofstream ofs(filename);
ofs << eigen;
ofs.close();

return;
}

0 comments on commit de4a179

Please sign in to comment.