Skip to content

Commit

Permalink
Add further debug information in the warning
Browse files Browse the repository at this point in the history
  • Loading branch information
CPBridge committed Jun 22, 2023
1 parent 8617e6f commit 311d2f0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/highdicom/seg/sop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Module for SOP classes of the SEG modality."""
import logging
from collections import defaultdict
from collections import Counter, defaultdict
from contextlib import contextmanager
from copy import deepcopy
from os import PathLike
Expand Down Expand Up @@ -2163,8 +2163,15 @@ def _get_ref_instance_uids(self) -> List[Tuple[str, str, str]]:
# the list without changing the order
unique_instance_data = list(dict.fromkeys(instance_data))
if len(unique_instance_data) != len(instance_data):
counts = Counter(instance_data)
duplicate_sop_uids = [
f"'{key[2]}'" for key, value in counts.items() if value > 1
]
display_str = ', '.join(duplicate_sop_uids)
logger.warning(
'Duplicate entries found in the ReferencedSeriesSequence.'
'Duplicate entries found in the ReferencedSeriesSequence. '
f"Segmentation SOP Instance UID: '{self.SOPInstanceUID}', "
f'duplicated referenced SOP Instance UID items: {display_str}.'
)

return list(unique_instance_data)
Expand Down

0 comments on commit 311d2f0

Please sign in to comment.