Skip to content

Commit

Permalink
series selector op log + documentation updates
Browse files Browse the repository at this point in the history
Signed-off-by: bluna301 <[email protected]>
  • Loading branch information
bluna301 committed Oct 1, 2024
1 parent d064aff commit 5d211f4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions monai/deploy/operators/dicom_series_selector_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def __init__(
rules (Text): Selection rules in JSON string.
all_matched (bool): Gets all matched series in a study. Defaults to False for first match only.
sort_by_sop_instance_count (bool): If all_matched = True and multiple series are matched, sorts the matched series in
descending SOP instance count. Defaults to False for no sorting.
descending SOP instance count (i.e. the first Series in the returned List[StudySelectedSeries] will have the highest #
of DICOM images); Defaults to False for no sorting.
"""

# rules: Text = "", all_matched: bool = False,
Expand Down Expand Up @@ -142,10 +143,11 @@ def filter(
Args:
selection_rules (object): JSON object containing the matching rules.
dicom_study_list (list): A list of DICOMStudiy objects.
dicom_study_list (list): A list of DICOMStudy objects.
all_matched (bool): Gets all matched series in a study. Defaults to False for first match only.
sort_by_sop_instance_count (bool): If all_matched = True and multiple series are matched, sorts the matched series in
descending SOP instance count. Defaults to False for no sorting.
descending SOP instance count (i.e. the first Series in the returned List[StudySelectedSeries] will have the highest #
of DICOM images); Defaults to False for no sorting.
Returns:
list: A list of objects of type StudySelectedSeries.
Expand Down Expand Up @@ -223,7 +225,8 @@ def _select_series(
attributes (dict): Dictionary of attributes for matching
all_matched (bool): Gets all matched series in a study. Defaults to False for first match only.
sort_by_sop_instance_count (bool): If all_matched = True and multiple series are matched, sorts the matched series in
descending SOP instance count. Defaults to False for no sorting.
descending SOP instance count (i.e. the first Series in the returned List[StudySelectedSeries] will have the highest #
of DICOM images); Defaults to False for no sorting.
Returns:
List of DICOMSeries. At most one element if all_matched is False.
Expand Down Expand Up @@ -313,6 +316,9 @@ def _select_series(
# if sorting indicated and multiple series found
if sort_by_sop_instance_count and len(found_series) > 1:
# sort series in descending SOP instance count
logging.info(
"Multiple series matched the selection criteria; choosing series with the highest number of DICOM images."
)
found_series.sort(key=lambda x: len(x.get_sop_instances()), reverse=True)

return found_series
Expand Down

0 comments on commit 5d211f4

Please sign in to comment.