dcmspec is a versatile Python toolkit designed to provide processing of DICOM® specifications such as the DICOM standard or IHE profiles.
Designed as a general-purpose, extensible framework, dcmspec enables flexible extraction, parsing, and processing of DICOM specifications.
- An API to programmatically access, parse, and process DICOM and IHE specifications.
- Command-Line Interface (CLI) sample scripts which extract, parse, and process specific DICOM and IHE specifications.
- User Interface (UI) sample application for interactive exploration of DICOM IODs.
Note: CLI and UI sample applications are provided as developer examples and are not intended to be full-featured or production-grade applications.
To install the core package:
pip install dcmspecFor information on installing optional features (UI sample, PDF parsing), see the Installation Guide.
This example downloads and prints the DICOM Patient Module table as a tree:
from dcmspec.spec_factory import SpecFactory
from dcmspec.spec_printer import SpecPrinter
patient_module = SpecFactory().create_model(
url="https://dicom.nema.org/medical/dicom/current/output/html/part03.html",
table_id="table_C.7-1",
cache_file_name="Part3.xhtml",
json_file_name="patient_module.json",
)
SpecPrinter(patient_module).print_tree(
attr_names=["elem_tag", "elem_type", "elem_name"], attr_widths=[11, 2, 64]
)Note:
The first time you run this, the full DICOM Part 3 HTML file (~30MB) will be downloaded and parsed. Subsequent runs will use the cached file and be much faster.
See the Release Notes for a summary of changes, improvements, and breaking updates in each version.
See Configuration & Caching for details on configuring cache and other settings.
See CONTRIBUTING.md for guidelines and instructions on how to contribute to the project.
There are a few great related open source projects worth checking out:
- innolitics/dicom-standard: Tools and data for parsing and working with the DICOM standard in a structured format.
- pydicom/dicom-validator: A DICOM file validator based on the DICOM standard.
How dcmspec differs:
- The above projects focus on parsing specific sections of the DICOM standard to support targeted use cases, such as browsing or validation.
- dcmspec is designed with a broader scope. It provides a flexible framework for parsing any DICOM specification document, including the DICOM Standard itself, DICOM Conformance Statements, and IHE Integration Profiles.
- The object-oriented architecture of dcmspec is extensible, making it possible to support additional sources, and to define custom structured data models as output.
DICOM® is the registered trademark of the National Electrical Manufacturers Association for its Standards publications relating to digital communications of medical information.
National Electrical Manufacturers Association (NEMA), Rosslyn, VA USA.
PS3 / ISO 12052 Digital Imaging and Communications in Medicine (DICOM) Standard.
http://www.dicomstandard.org