Skip to content

Structured reports (TID 1500)

Author and read TID 1500 Measurement Report SRs — the standard writetid1500 / readtid1500 capability. The SR pydcm writes is conformant (sr_validate finds no errors).

Write a measurement report

A report is a list of measurement dicts. Each carries a coded concept, a value with UCUM units, and an optional image reference + graphic annotation:

import pydcm

measurements = [
    {"concept_value": "103355008", "concept_scheme": "SCT", "concept_meaning": "Width",
     "value": 23.4, "unit_code": "mm", "unit_meaning": "millimeter",
     "ref_sop_class_uid":    "1.2.840.10008.5.1.4.1.1.2",
     "ref_sop_instance_uid": "1.2.3.4.5.6.7.8.9",
     "graphic_type": "POLYLINE", "scoord": [10.0, 20.0, 33.4, 20.0]},
    {"concept_value": "33747003", "concept_scheme": "SCT", "concept_meaning": "Mean",
     "value": -512.7, "unit_code": "[hnsf'U]", "unit_meaning": "Hounsfield unit"},
]

pydcm.write_report(
    measurements,
    patient_name="DOE^JANE", patient_id="PID-1", study_date="20260605",
    output="report.dcm",
)

Omit output to get Part-10 bytes. Pass reference (a source instance path) to inherit study/patient context instead of supplying it by hand.

Read it back

items = pydcm.read_report("report.dcm")
for m in items:
    m["concept_meaning"], m["value"], m["unit_meaning"]

Arbitrary SR content trees

For SRs that are not measurement reports, write_sr authors a Comprehensive SR from a content-tree dict (containers, code / num / text / image content items):

pydcm.write_sr(document_tree, output="sr.dcm")