Skip to content

SR documents with a NUM content item that has an empty Measured Value Sequence cannot be read #475

Closed

Description

@DG47

The Measured Value Sequence (0040,A300) of a NUM content item is type 2. PS3.3 Table C.18.1-1 says "Zero or one Item shall be included in this Sequence", and the Numeric Value Qualifier Code Sequence (0040,A301) is "Required if Measured Value Sequence (0040,A300) is empty" and gives the reason the value is absent (CID 42, e.g. "Measurement failure", "Not a number").

highdicom raises an IndexError when it decodes such an item. Because the content tree is decoded when a document is read, hd.sr.srread() and Comprehensive3DSR.from_dataset() fail for the whole document.

Minimal reproduction:

from pydicom.dataset import Dataset
from pydicom.sr.codedict import codes
import highdicom as hd

item = Dataset()
item.RelationshipType = 'CONTAINS'
item.ValueType = 'NUM'
item.ConceptNameCodeSequence = [hd.sr.CodedConcept(*codes.SCT.Diameter)]
item.MeasuredValueSequence = []
item.NumericValueQualifierCodeSequence = [
    hd.sr.CodedConcept(*codes.DCM.MeasurementFailure)
]

hd.sr.NumContentItem.from_dataset(item)
  File ".../highdicom/sr/value_types.py", line 1239, in from_dataset
    item
  ...
IndexError: list index out of range

The same error occurs with hd.sr.srread() on data/test_files/sr_document.dcm after emptying the Measured Value Sequence of its NUM item and adding a Numeric Value Qualifier Code Sequence item.

Expected: the item and the document can be read. The measurement is reported with no value and the qualifier gives the reason.

Actual: IndexError: list index out of range from NumContentItem.from_dataset().

Measurement.from_sequence() (used by get_measurements()) also rebuilds the measurement by calling the constructor with item.value and item.unit, so it would fail for these items too.

Environment: highdicom 0.28.2 (master at 847fea5), pydicom 3.0.2, numpy 2.5.4, Python 3.12, macOS.

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