Skip to content

Implement dicom-xml CLI tool with DICOM Part 19 Native XML support#23

Merged
SureshKViswanathan merged 5 commits into
mainfrom
copilot/next-task-development
Feb 7, 2026
Merged

Implement dicom-xml CLI tool with DICOM Part 19 Native XML support#23
SureshKViswanathan merged 5 commits into
mainfrom
copilot/next-task-development

Conversation

Copilot AI commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Implements bidirectional DICOM ↔ XML conversion following DICOM PS3.19 Native XML Model specification. Completes Milestone 11.2 Phase 3 tool #2 of 4.

Implementation

DICOMWeb Module Extensions

  • DICOMXMLEncoder: Serializes DataElements to Part 19 Native XML format
    • Handles sequences, person names, binary data (inline Base64 or bulk data URIs)
    • Configurable: pretty-printing, keyword attributes, binary threshold
    • Proper XML escaping for special characters
  • DICOMXMLDecoder: Parses Native XML back to DataElements
    • XMLParser-based implementation with nested sequence support
    • VR inference from dictionary when missing
    • Bulk data URI placeholders

CLI Tool

  • dicom-xml: Bidirectional converter with ArgumentParser interface
    • Forward: dicom-xml file.dcm --output file.xml --pretty
    • Reverse: dicom-xml file.xml --output file.dcm --reverse
    • Options: tag filtering, metadata-only, bulk data configuration
    • Verbose mode with timing statistics

Example Usage

# Convert DICOM to pretty-printed XML
dicom-xml ct-scan.dcm --output ct-scan.xml --pretty

# Convert back to DICOM
dicom-xml ct-scan.xml --output restored.dcm --reverse

# Extract metadata only, specific tags
dicom-xml study.dcm --metadata-only \
  --filter-tag PatientName \
  --filter-tag StudyDate \
  --pretty

XML Format Sample

<NativeDicomModel xmlns="http://dicom.nema.org/PS3.19/models/NativeDICOM">
  <DicomAttribute tag="00100010" vr="PN" keyword="PatientName">
    <PersonName number="1">
      <Alphabetic>
        <FamilyName>Doe</FamilyName>
        <GivenName>John</GivenName>
      </Alphabetic>
    </PersonName>
  </DicomAttribute>
  <DicomAttribute tag="00081110" vr="SQ" keyword="ReferencedStudySequence">
    <Item number="1">
      <DicomAttribute tag="00081150" vr="UI">
        <Value number="1">1.2.840.10008.3.1.2.3.1</Value>
      </DicomAttribute>
    </Item>
  </DicomAttribute>
</NativeDicomModel>

Testing

  • 23 encoder tests: encoding variants, person names, sequences, binary data, XML escaping
  • 18 decoder tests: parsing, VR inference, nested sequences, roundtrip conversion
  • All tests passing, builds clean

Changes to Package.swift

  • Added dicom-xml executable product and target
  • Dependencies: DICOMKit, DICOMCore, DICOMWeb, DICOMDictionary, ArgumentParser

Progress

Phase 3 (Format Conversion): 2/4 tools complete (dicom-json, dicom-xml)
Overall CLI Tools: 59% complete (17/29 tools)

Original prompt

Work on the next task


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 7, 2026 01:53
Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
…(23 encoder tests, 18 decoder tests)

Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
…s done, 59% overall progress)

Co-authored-by: SureshKViswanathan <257696045+SureshKViswanathan@users.noreply.github.com>
Copilot AI changed the title [WIP] Work on next task development Implement dicom-xml CLI tool with DICOM Part 19 Native XML support Feb 7, 2026
@SureshKViswanathan SureshKViswanathan marked this pull request as ready for review February 7, 2026 03:42
@SureshKViswanathan SureshKViswanathan merged commit 748a520 into main Feb 7, 2026
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