Skip to main content

A tool for checking DICOM compliance against a reference model using Pydantic

Project description

dcm-check

dcm-check is a command-line tool and Python library for validating DICOM files against specified reference models. This tool supports JSON, DICOM, and Pydantic-based reference models to facilitate compliance checks for DICOM attributes. Features

  • Validate DICOM files against JSON, DICOM, or Pydantic reference models.
  • Generate detailed compliance reports, including expected and actual values for each parameter.
  • Output results in JSON format for further analysis or logging.

Installation

To install dcm-check, clone the repository and run:

pip install .

dcm-check requires Python >=3.10.

Usage

The tool can be used as a command-line interface (CLI) or as an API within Python scripts.

Command-Line Usage

The CLI provides options to specify a reference model and validate a DICOM file. Command Syntax

dcm-check --ref <reference-file> --type <json|dicom|pydantic> --acquisition <acquisition-type> --in <dicom-file> [--fields <field1 field2 ...>] [--out <output-file>]

Arguments:

  • --ref: Path to the reference file (JSON, DICOM, or Python module).
  • --type: Type of reference model (json, dicom, or pydantic).
  • --acquisition: Acquisition type (e.g., T1, T2w, etc.) when using JSON or Pydantic references; inferred if not given.
  • --in: Path to the DICOM file to validate.
  • --fields: (Optional) List of specific DICOM fields to include in validation for DICOM reference types.
  • --out: (Optional) Path to save the compliance report as a JSON file.

Example Commands:

Validate a DICOM file using a JSON reference model:

dcm-check --ref reference.json --acquisition T1 --in dicom_file.dcm

Validate a DICOM file using another DICOM as a reference:

dcm-check --ref reference.dcm --in dicom_file.dcm --fields EchoTime RepetitionTime

Validate a DICOM file using a Pydantic model in a Python module:

dcm-check --ref reference.py --acquisition T1_MPR --in dicom_file.dcm

Output

The compliance report is printed to the terminal in tabular format. You can also save it to a JSON file using the --out argument.

    Parameter          Expected                                       Actual       Pass
--  -----------------  ---------------------------------------------  -----------  ------
 0  EchoTime           Input should be greater than or equal to 5.74  3.0          False
 1  RepetitionTime     29.0                                           8.0          False
 2  SeriesDescription  String should match pattern '.*t1.*'           T1-weighted  False

Example JSON report:

[
    {
        "Parameter": "EchoTime",
        "Expected": "Input should be greater than or equal to 5.74",
        "Actual": 2.96,
        "Pass": false
    },
    {
        "Parameter": "RepetitionTime",
        "Expected": "29.0",
        "Actual": 2300.0,
        "Pass": false
    }
]

Python API Usage

To use dcm-check programmatically, import the appropriate functions from dcm_check:

from dcm_check.dcm_check import load_ref_json, load_ref_dicom, load_ref_pydantic, get_compliance_summary, is_compliant

# Example for loading a JSON reference model and checking compliance
reference_model = load_ref_json("reference.json", "T1")
dicom_values = load_dicom("dicom_file.dcm")
compliance_summary = get_compliance_summary(reference_model, dicom_values)

# Print compliance summary
print(compliance_summary)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dcm_check-0.1.1.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

dcm_check-0.1.1-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file dcm_check-0.1.1.tar.gz.

File metadata

  • Download URL: dcm_check-0.1.1.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for dcm_check-0.1.1.tar.gz
Algorithm Hash digest
SHA256 653ab757d4e1c90a0a3c928c3046d7573418dacc3704d865fc4c7a46465fdde6
MD5 7c9b956dcd8e5e0e566eb751a8c1a1f1
BLAKE2b-256 5dec7016800f53747e9f14758b8dda4b8c6f26b6f9b7f930398b11b2b19f1532

See more details on using hashes here.

File details

Details for the file dcm_check-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dcm_check-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for dcm_check-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62b4d79628f0eb2b6ebdb1b99382f86c147d7b7054a1551788ca382a556a08eb
MD5 3fad87a635719195a2ac30cac678bd5f
BLAKE2b-256 01b5fa0ffa2654585e42d902beb0e789f5df4a73282408211ee47720c4815cba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page