Skip to content

Reject evidence from multiple studies in Key Object Selection Documents - #503

Merged
CPBridge merged 1 commit into
ImagingDataCommons:masterfrom
DG47:bugfix/kos-multi-study-evidence
Nov 2, 2026
Merged

CPBridge merged 1 commit into
ImagingDataCommons:masterfrom
DG47:bugfix/kos-multi-study-evidence

Conversation

@DG47

@DG47 DG47 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #502

KeyObjectSelectionDocument.__init__ is meant to raise a ValueError when the provided evidence spans more than one study, since the Key Object Document Module requires the Current Requested Procedure Evidence Sequence (Type 1) to list every instance referenced in the content and referencing more than one study additionally requires the Identical Documents Sequence, which highdicom does not create.

Since #373 split the collected evidence into same-study and other-study items, the guard has compared the number of other studies against 1 instead of 0. With evidence from exactly two studies no error is raised, the other-study instances are silently dropped from the evidence sequence, and the resulting document references SOP instances that are not listed in the Current Requested Procedure Evidence Sequence. resolve_reference() then fails for those instances.

Changes:

  • Raise the existing ValueError whenever any other-study evidence is collected, and set the Current Requested Procedure Evidence Sequence unconditionally (it is Type 1 and the first evidence item always belongs to the document's study).
  • Add a test constructing a document with evidence from two studies.

Tests: pytest tests/test_ko.py tests/test_sr.py (344 passed); flake8 src/highdicom/ko/sop.py tests/test_ko.py and mypy src/highdicom/ko/sop.py are clean.

@CPBridge CPBridge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@CPBridge
CPBridge merged commit 962ed03 into ImagingDataCommons:master Nov 2, 2026
13 checks passed
@CPBridge CPBridge added the bug Something isn't working label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KeyObjectSelectionDocument silently drops evidence from a second study instead of raising

2 participants