Skip to content

Commit

Permalink
feat: add test for contour data size
Browse files Browse the repository at this point in the history
  • Loading branch information
asim-shrestha committed Apr 22, 2021
1 parent da56ff0 commit e28d38e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_rtstruct_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ def test_no_approximation_iou(new_rtstruct: RTStruct):
IOU_threshold = 0.95 # Expected accuracy
run_mask_iou_test(new_rtstruct, mask, IOU_threshold, approximate_contours=False)

def test_contour_data_sizes(new_rtstruct: RTStruct):
mask = get_empty_mask(new_rtstruct)
mask[50:100, 50:100, 0] = 1
mask[60:150, 40:120, 0] = 1

# Given we've added the same mask with and without contour approximation
new_rtstruct.add_roi(mask)
new_rtstruct.add_roi(mask, approximate_contours=False)

# Then using approximation leads to less data within the contour data
assert get_data_len_by_index(new_rtstruct, 0) < get_data_len_by_index(new_rtstruct, 1)

def get_data_len_by_index(rt_struct: RTStruct, i: int):
return len(rt_struct.ds.ROIContourSequence[i].ContourSequence[0].ContourData)

def run_mask_iou_test(rtstruct:RTStruct, mask, IOU_threshold, use_pin_hole=False, approximate_contours=True):
# Save and load mask
Expand Down

0 comments on commit e28d38e

Please sign in to comment.