Skip to Content
go-dicom(3)
Command line

sr

Prints a Structured Report (PS3.3 C.17) as the document it is: a header, then its content items as an indented tree, one item to a line.

When to use it

Use sr to read a measurement report, a key object selection or a CAD result without walking nested Content Sequences by hand. Each line gives the item's relationship to its parent, its value type, its concept name as a meaning and [code, scheme], and its value. --json gives the same tree for a program.

It reads only; it does not validate the report against its template (use validate for the IOD) and it does not write reports. On a file that is not an SR it fails. The closest tools are dcmtk's dsrdump and, in Python, highdicom's SR classes.

Examples

go-dicom sr report.dcm
Comprehensive SR
Patient: Test^S R
Completion: COMPLETE  Verification: VERIFIED
Verifying observer: Riesmeier^Jörg, OFFIS e.V., 2001-02-13 18:47:46 "JR" [1705, 99_OFFIS_DCMTK]
Verifying observer: Observer^Verifying, Organisation, 2001-02-13 18:47:46
Predecessor document: Comprehensive SR [1.2.840.10008.5.1.4.1.1.88.33] 1.2.276.0.7230010.3.1.4.2139363186.7819.982086466.1 (series …, study …)
Content date/time: 2001-02-13 18:47:46
29 content item(s)

CONTAINER  "Diagnosis" [1111, TEST] = SEPARATE  @ 2001-02-13 18:47:46
  has obs context UIDREF  "Some UID" [1234.0, 99_OFFIS_DCMTK] = 1.2.3.4.5
  contains CONTAINER = CONTINUOUS
    contains TEXT  "Text Code" [1234, 99_OFFIS_DCMTK] = "A mass of"
      has concept mod CODE  "Code" [1234, 99_OFFIS_DCMTK] = "Sample Code 1" [2222, 99_OFFIS_DCMTK]
      …
    contains NUM  "Diameter" [1234, 99_OFFIS_DCMTK] = 3 cm "Length Unit" [cm, 99_OFFIS_DCMTK]
  …
    has properties SCOORD  "SCoord Code" [1234, 99_OFFIS_DCMTK] = CIRCLE 0/0 255/255
    has properties TCOORD  "TCoord Code" [1234, 99_OFFIS_DCMTK] = SEGMENT offsets 1.000000,2.500000
      selected from -> 1.3.2
  …
  contains IMAGE = CT Image [1.2.840.10008.5.1.4.1.1.2] 1.2.3.4.5.0 frames 5,2 shown with Grayscale Softcopy Presentation State [1.2.840.10008.5.1.4.1.1.11.1] 1.2.3.5.6.7  @ 2001-02-13 18:47:46
…

How to read a line:

  • A TEXT value is quoted, a line break written as \n. A NUM is the number, its unit and the unit's code. DATE, TIME and DATETIME are written as 2000-12-06, 12:00:00 and both.
  • An IMAGE, WAVEFORM or COMPOSITE names the SOP class and instance it references, with an image's frames and presentation state and a waveform's channels.
  • -> 1.3.2 is a by-reference item: it points at the item in that position, counted as dotted ordinals from the root (1.3.2 is the second child of the root's third child).
  • @ and a time ends an item observed at a time of its own. # TID and a number ends an item built from a template other than the root's.

A simpler report

go-dicom sr reportsi.dcm
Basic Text SR
Patient: Last Name^First Name
Completion: PARTIAL  Verification: UNVERIFIED
Content date/time: 2005-05-30 16:05:27
9 content item(s)

CONTAINER  "Document Title" [IHE.01, 99_OFFIS_DCMTK] = SEPARATE
  has obs context CODE  "Observation Context Mode" [IHE.02, 99_OFFIS_DCMTK] = "DIRECT" [IHE.03, 99_OFFIS_DCMTK]
  has obs context PNAME  "Recording Observer's Name" [IHE.04, 99_OFFIS_DCMTK] = "Enter text"
  …

As JSON

go-dicom sr report.dcm --json
{
  "schemaVersion": 1,
  "file": "report.dcm",
  "document": {
    "sopClassUID": "1.2.840.10008.5.1.4.1.1.88.33",
    "sopClassName": "Comprehensive SR",
    "patientName": "Test^S R",
    "completionFlag": "COMPLETE",
    "verificationFlag": "VERIFIED",
    …
  },
  "content": {
    "position": "1",
    "valueType": "CONTAINER",
    "conceptName": {
      "value": "1111",
      "scheme": "TEST",
      "meaning": "Diagnosis"
    },
    "observationDateTime": "20010213184746",
    "continuityOfContent": "SEPARATE",
    "children": [
      {
        "position": "1.1",
        "relationship": "HAS OBS CONTEXT",
        "valueType": "UIDREF",
        …
        "uid": "1.2.3.4.5"
      },
…

The top level holds document (the header), content (the root item, its children nested under children) and warnings. Each value sits in a field of its own kind (text, uid and so on), and a field is present only where the document has it.

Notes

  • A file that is not an SR document is refused with exit status 1: Error: sr: ct.dcm: sr: the data set has no Value Type (0040,A040), so it is not an SR document; its root item would say CONTAINER.
  • The header lists the verifying observers and the predecessor documents; the report's identical documents are not printed.
  • New JSON fields are added without a new schemaVersion; it changes only when a field is renamed, removed or changes meaning.

See also

Options

COMMAND: sr - Print the content tree of a structured report

USAGE:
  go-dicom sr <file> [options]

DESCRIPTION:
  Print a Structured Report (PS3.3 C.17) as the document it is: a header, then
  the content items as an indented tree. Each line is the item's relationship
  to its parent (contains, has obs context, inferred from, ...), its value
  type, its concept name as a meaning and a [code, scheme], and its value:

    TEXT       the text, quoted, a line break written as \n
    CODE       the code
    NUM        the number and its unit, the unit's code, and a qualifier
    DATE, TIME, DATETIME    written as 2000-12-06, 12:00:00 and both
    UIDREF, PNAME           the UID, the name
    IMAGE, WAVEFORM, COMPOSITE   the SOP class and instance referenced, an
               image's frames, segments and presentation state, a waveform's
               channels
    SCOORD, SCOORD3D   the graphic type and its points
    TCOORD     the range type and the samples, offsets or times it covers
    CONTAINER  SEPARATE or CONTINUOUS

  An item that only points at another prints -> and the position of its
  target, which is the item's place as dotted ordinals from the root: 1.2.3 is
  the third child of the root's second child. Positions are given in --json.
  An item observed at another time ends with @ and the time. An item built
  from a template other than the root's ends with # TID and its number and
  mapping resource. An image that has Real World Value Mapping instances ends
  with "mapped by" and them.

  The header lists the verifying observers (name, organization, time and
  code) and the predecessor documents, an instance to a line with its series
  and study. The identical documents of a report are not printed.

OPTIONS:
  -h, --help    Show help for this command
  --json        Print the report as JSON, with "schemaVersion" 1: the header,
                and the tree as nested "content" items with their position,
                relationship, value type, concept name and the value in a
                field of its own kind. A field is present only where the
                document has it: "verifyingObservers" and
                "predecessorDocuments" in the header, "template" on an item,
                "realWorldValueMappings" in an image reference. They were
                added without a new schemaVersion, which changes only when a
                field is renamed, removed or changes meaning.

EXAMPLES:
  go-dicom sr report.dcm
  go-dicom sr report.dcm --json
  go-dicom sr -h

On this page