Skip to content

Commit

Permalink
add test for roi subset
Browse files Browse the repository at this point in the history
  • Loading branch information
wasserth committed Aug 29, 2023
1 parent e257f07 commit e09dde7
Show file tree
Hide file tree
Showing 10 changed files with 513 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ tmp_weights_DELETE/
store/
unittest_prediction
unittest_prediction_fast
unittest_prediction_roi_subset

*.tfstate
*.tfstate.backup
Expand Down
3 changes: 3 additions & 0 deletions bin/TotalSegmentator
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def main():
parser.add_argument("-rs", "--roi_subset", type=str, nargs="+",
help="Define a subset of classes to save (space separated list of class names). If running 1.5mm model, will only run the appropriate models for these rois.")

# When this is used together with --roi_subset and --ml, then statistics will be calculated for all classes
# in the class_map_part_X with is calculated. Some of the rois will be cropped and therefore the volume will
# only be of the cropped region, making it an incorrect volume.
parser.add_argument("-s", "--statistics", action="store_true",
help="Calc volume (in mm3) and mean intensity. Results will be in statistics.json",
default=False)
Expand Down
43 changes: 29 additions & 14 deletions tests.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
set -e

# Test organ predictions
TotalSegmentator -i tests/reference_files/example_ct.nii.gz -o tests/unittest_prediction --test 1
pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_liver
pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_vertebrae
echo "License key: $1"

# Test multilabel prediction
TotalSegmentator -i tests/reference_files/example_ct.nii.gz -o tests/unittest_prediction.nii.gz --ml --test 1
pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_multilabel
# # Test organ predictions
# TotalSegmentator -i tests/reference_files/example_ct.nii.gz -o tests/unittest_prediction --test 1
# pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_liver
# pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_vertebrae

# # Test multilabel prediction
# TotalSegmentator -i tests/reference_files/example_ct.nii.gz -o tests/unittest_prediction.nii.gz --ml --test 1
# pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_multilabel

# Test organ prediction - roi subset
# 20 cpu
# example_ct_sm.nii.gz: 20s, 3.1GB
# example_ct.nii.gz: 22s, 3.1GB
# 2 cpus:
# example_ct_sm.nii.gz: 34s, 3.0GB
# example_ct.nii.gz: 36s, 3.0GB
TotalSegmentator -i tests/reference_files/example_ct_sm.nii.gz -o tests/unittest_prediction_roi_subset -rs liver brain -d cpu
pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_liver_roi_subset

# Test organ predictions - fast
TotalSegmentator -i tests/reference_files/example_ct.nii.gz -o tests/unittest_prediction_fast --fast --statistics
pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_liver_fast
pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_vertebrae_fast
pytest -v tests/test_end_to_end.py::test_end_to_end::test_statistics
# 2 cpus: (w/o statistics)
# example_ct_sm.nii.gz: 13s, 4.1GB
# example_ct.nii.gz: 16s, 4.1GB
# TotalSegmentator -i tests/reference_files/example_ct_sm.nii.gz -o tests/unittest_prediction_fast --fast --statistics -d cpu
# pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_liver_fast
# pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_vertebrae_fast
# pytest -v tests/test_end_to_end.py::test_end_to_end::test_statistics

# Test vessel predictions
TotalSegmentator -i tests/reference_files/example_ct.nii.gz -o tests/unittest_prediction -ta lung_vessels --test 3
pytest -v tests/test_end_to_end.py::test_end_to_end::test_lung_vessels
# # Test vessel predictions
# TotalSegmentator -i tests/reference_files/example_ct.nii.gz -o tests/unittest_prediction -ta lung_vessels --test 3 -d cpu
# pytest -v tests/test_end_to_end.py::test_end_to_end::test_lung_vessels
Binary file added tests/reference_files/example_ct_sm.nii.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit e09dde7

Please sign in to comment.