8000 Handle cross-study source references correctly by michaelonken · Pull Request #560 · QIICR/dcmqi · GitHub
[go: up one dir, main page]

Skip to content

Handle cross-study source references correctly - #560

Merged
fedorov merged 1 commit into
masterfrom
cross_study_references
Sep 5, 2026
Merged

fedorov merged 1 commit into
masterfrom
cross_study_references

Conversation

@michaelonken
Copy link
Copy Markdown
Member

Follow-up to the cross-study gap discussed in #554: the Common Instance
Reference module filed every referenced source instance in
ReferencedSeriesSequence, whose items implicitly belong to the study of the
created object. References to images from another study were therefore
misfiled — hierarchical resolution (PACS prefetch, DICOMweb) looks in the
wrong study — and the type 1C condition of
StudiesContainingOtherReferencedInstancesSequence was violated.

SourceImageIndex now records the Study Instance UID of every source dataset,
and populateCommonInstanceReference() takes the study of the created object:
same-study instances go into ReferencedSeriesSequence as before, foreign
ones are filed under their study in the studies sequence, grouped by series
within. Instances without a Study Instance UID are treated as same-study, with
a warning. Both converters pass their document's study; no DCMTK changes
needed.

Out of scope (pre-existing): with mixed-study input, the study of the created
object itself still follows the first input dataset, and the geometric mapping
does not check Frame of Reference UIDs.

Tests: CommonInstanceReferenceTest derives an in-memory instance with a
foreign Study/Series/SOP Instance UID and asserts it is referenced per frame,
absent from ReferencedSeriesSequence, and filed under exactly its study and
series; the assertion fails with the routing disabled. Single-study outputs
stay identical to a master build; dciodvfy accepts the cross-study output.

Note: this PR and #558 both touch SourceImageIndex; whichever merges second
gets a small rebase.

The Common Instance Reference module put every referenced instance into
the Referenced Series Sequence, whose items implicitly belong to the
study of the created object. Source images from a different study were
therefore misfiled: consumers resolving references hierarchically looked
for their series in the wrong study, and the type 1C condition of the
Studies Containing Other Referenced Instances Sequence (PS3.3 C.12.2)
was violated. Follow-up to the discussion in #554.

SourceImageIndex now records the Study Instance UID of every source
dataset, and populateCommonInstanceReference() takes the study of the
created object: instances of that study go into the Referenced Series
Sequence as before, instances of other studies are filed under their
study in the Studies Containing Other Referenced Instances Sequence,
grouped by series within. Instances without a Study Instance UID are
treated as belonging to the object's study, with a warning. Both the
SEG and the PM converter pass their document's study.

CommonInstanceReferenceTest gains a derived instance from a foreign
study and asserts it appears under its study and nowhere else; the
assertion fails when the routing is disabled. Outputs for single-study
inputs are unchanged, verified by dcmdump diff against a master build
for binary, labelmap, multi-file, geometry-check-off and parametric
map conversions; dciodvfy accepts the cross-study output.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud
sonarqubecloud Bot commented Sep 4, 2026
Copy link
Copy Markdown

@fedorov
fedorov merged commit be88235 into master Sep 5, 2026
9 checks passed
@fedorov
fedorov deleted the cross_study_references branch September 5, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0