Skip to content

Single frame images report every source image as missing from the referenced series #536

Done

Description

@CedricConday

In Image._build_luts_single_frame the source image UID is assigned with a trailing comma:

for source_image_item in self.get('SourceImageSequence', []):
    ref_uid = source_image_item.ReferencedSOPInstanceUID,

so ref_uid is a one-element tuple. The check that follows, if ref_uid not in all_referenced_sops, compares that tuple with UID strings and is always true. Every source image of a single frame image therefore lands in _missing_reference_instances, and get_source_image_uids() logs the "error with the integrity of the object" warning for it even when the instance is listed in the Referenced Series Sequence. The tuple also goes into the frame reference row in place of the UID.

Reproduction:

import pydicom
import highdicom as hd
from pydicom.data import get_testdata_file

ct = pydicom.dcmread(get_testdata_file('CT_small.dcm'))

src = pydicom.Dataset()
src.ReferencedSOPClassUID = ct.SOPClassUID
src.ReferencedSOPInstanceUID = '1.2.3.4'
ct.SourceImageSequence = [src]

ref = pydicom.Dataset()
ref.ReferencedSOPClassUID = ct.SOPClassUID
ref.ReferencedSOPInstanceUID = '1.2.3.4'
series = pydicom.Dataset()
series.SeriesInstanceUID = '1.2.3'
series.ReferencedInstanceSequence = [ref]
ct.ReferencedSeriesSequence = [series]

im = hd.Image.from_dataset(ct)
print(im.get_source_image_uids())
# WARNING: SOP instances ('1.2.3.4',) referenced in the source image sequence is not included in ...

The returned list is right, since it is built from the referenced instance table; the warning and the missing list are wrong. The multiframe path (_build_luts_multiframe) does not have the comma. A PR with the fix and a test follows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions