Skip to content

Commit

Permalink
add phase classification test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wasserth committed Jul 23, 2024
1 parent 4eec38e commit 47e7330
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/reference_files/phase_prediction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pi_time": -0.04,
"phase": "native",
"probability": 1.0,
"pi_time_min": -0.13,
"pi_time_max": 0.14,
"stddev": 0.0993
}
6 changes: 6 additions & 0 deletions tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ def test_prediction_dicom(self):
dice = dice_score(img_ref, img_new)
images_equal = dice > 0.99
self.assertTrue(images_equal, f"Dicom prediction not correct (dice: {dice:.6f})")

def test_phase_prediction(self):
pred_ref = json.load(open("tests/reference_files/phase_prediction.json"))
pred_new = json.load(open("tests/unittest_phase_prediction.json"))
self.assertDictEqual(pred_ref, pred_new)



if __name__ == '__main__':
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_multilabel_
TotalSegmentator -i tests/reference_files/example_ct_sm.nii.gz -o tests/unittest_prediction_fast_body_seg.nii.gz --fast --ml -bs -d cpu
pytest -v tests/test_end_to_end.py::test_end_to_end::test_prediction_multilabel_fast_body_seg

# Test phase prediction
totalseg_get_phase -i tests/reference_files/example_ct_sm.nii.gz -o tests/unittest_phase_prediction.json
pytest -v tests/test_end_to_end.py::test_end_to_end::test_phase_prediction

# Cleanup generated files and directories
rm -rf tests/unittest_prediction_roi_subset
rm -rf tests/unittest_prediction_fast
rm tests/unittest_prediction.nii.gz
rm tests/unittest_prediction_fast.nii.gz
rm tests/unittest_prediction_fast_force_split.nii.gz
rm tests/unittest_prediction_fast_body_seg.nii.gz
rm tests/unittest_phase_prediction.json
# rm tests/statistics.json
1 change: 1 addition & 0 deletions tests/update_test_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TotalSegmentator -i tests/reference_files/example_ct_sm.nii.gz -o tests/referenc
# TotalSegmentator -i tests/reference_files/example_ct_sm.nii.gz -o tests/reference_files/example_seg_tissue_types -ta tissue_types -d cpu -l $1
# TotalSegmentator -i tests/reference_files/example_ct_sm.nii.gz -o tests/reference_files/example_seg_appendicular_bones -ta appendicular_bones -d cpu
TotalSegmentator -i tests/reference_files/example_ct_dicom -o tests/reference_files/example_seg_dicom.nii.gz --fast --ml -d cpu
totalseg_get_phase -i tests/reference_files/example_ct_sm.nii.gz -o tests/reference_files/phase_prediction.json

# Manually check if segmentations in tests/reference_files/example_seg_fast_force_split.nii.gz look correct
# (all others have too small FOV for manual inspection)

0 comments on commit 47e7330

Please sign in to comment.