Skip to content

modattributes

Description

CLI for extracting, caching, and printing DICOM Module Attributes tables from Part 3 of the DICOM standard.

This CLI downloads, caches, and prints the attributes of a given DICOM Module from Part 3 of the DICOM standard. Optionally, it can enrich the module with VR, VM, Keyword, or Status information from Part 6 (Data Elements dictionary).

The tool parses the specified Module Attributes table to extract all attributes, tags, types, and descriptions for the module. Optionally, it can merge in VR, VM, Keyword, or Status information from Part 6. The output can be printed as a table, tree, CSV, or Excel (OOXML) either to the console or to a specified file.

The resulting model is cached as a JSON file. The primary purpose of this cache file is to provide a structured, machine-readable representation of the module's attributes, which can be used for further processing or integration in other tools. As a secondary benefit, the cache file is also used to speed up subsequent runs of the CLI scripts.

For more information on configuration and caching location see the Configuration and Caching page.


Usage

poetry run python -m src.dcmspec.apps.cli.modattributes <table_id> [options]
<table_id>
The DICOM table ID to extract (e.g., table_C.7-1).
[options]
Additional command-line options (see below).

Options

--config <file>
Path to the configuration file.
--add-part6 [VR VM Keyword Status]
Specification(s) to merge from Part 6 (e.g., --add-part6 VR VM).
--force-update
Force update of the specifications merged from part 6, even if cached. Only applies when --add-part6 is used.
--print-mode <mode>
Print as 'table' (default), 'tree', 'csv', 'xlsx', or 'none' to skip printing.
  • xlsx: Writes an OOXML Excel file. Requires --output to specify the filename.
--output <file>
Path to output file. If not specified, prints to stdout (console).
  • When writing to a file, colorization is automatically disabled and plain text is used.
  • Mandatory when --print-mode xlsx is used.
--no-color
Disable colorized output (default: color enabled).
--include-depth <int>
Depth to which included tables should be parsed (default: unlimited, 0: none).
--force-parse
Force reparsing of the DOM and regeneration of the JSON model, even if the JSON cache exists.
--force-download
Force download of the input file and regeneration of the model, even if cached. Implies --force-parse.
-v, --verbose
Enable verbose (info-level) logging to the console.
-d, --debug
Enable debug logging to the console (overrides --verbose).
-h, --help
Show this help message and exit.

Examples

To parse the Patient Module Attributes Table and print it as a table:

poetry run python -m src.dcmspec.apps.cli.modattributes table_C.7-1

To enrich the table with VR and VM information from Part 6:

poetry run python -m src.dcmspec.apps.cli.modattributes table_C.7-1 --add-part6 VR VM

To print the specification model as a tree:

poetry run python -m src.dcmspec.apps.cli.modattributes table_C.7-1 --print-mode tree

To save the specification model as an ASCII table to a text file:

poetry run python -m src.dcmspec.apps.cli.modattributes table_C.7-1 --output patient_module.txt

To save the specification model as a CSV file:

poetry run python -m src.dcmspec.apps.cli.modattributes table_C.7-1 --print-mode csv --output patient_module.csv

To save the specification model as an Excel (OOXML) file:

poetry run python -m src.dcmspec.apps.cli.modattributes table_C.7-1 --print-mode xlsx --output patient_module.xlsx