Skip to content

Commit

Permalink
Exception to warning if warn_only is True
Browse files Browse the repository at this point in the history
Change the Exception  to a warning message if warn_only is set to True
  • Loading branch information
Zhack47 authored and asim-shrestha committed Jan 8, 2023
1 parent 2858381 commit 64bf9ba
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions rt_utils/rtstruct_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def validate_rtstruct_series_references(ds: Dataset, series_data: List[Dataset])

@staticmethod
def validate_contour_image_in_series_data(
contour_image: Dataset, series_data: List[Dataset]
contour_image: Dataset, series_data: List[Dataset], warning_only: bool = False
):
"""
Method to validate that the ReferencedSOPInstanceUID of a given contour image exists within the series data
Expand All @@ -79,7 +79,13 @@ def validate_contour_image_in_series_data(
return

# ReferencedSOPInstanceUID is NOT available
raise Exception(
f"Loaded RTStruct references image(s) that are not contained in input series data. "
+ f"Problematic image has SOP Instance Id: {contour_image.ReferencedSOPInstanceUID}"
)
if warning_onlyu:
warnings.warn(
f"Loaded RTStruct references image(s) that are not contained in input series data. "
+ f"Problematic image has SOP Instance Id: {contour_image.ReferencedSOPInstanceUID}"
)
else:
raise Exception(
f"Loaded RTStruct references image(s) that are not contained in input series data. "
+ f"Problematic image has SOP Instance Id: {contour_image.ReferencedSOPInstanceUID}"
)

0 comments on commit 64bf9ba

Please sign in to comment.