A tool for checking DICOM compliance against a template
Project description
dicompare
dicompare is a DICOM validation tool designed to ensure compliance with study-specific imaging protocols and domain-specific guidelines while preserving data privacy. It provides multiple interfaces, including support for validation directly in the browser at dicompare-web.vercel.app, leveraging WebAssembly (WASM), Pyodide, and the underlying pip package dicompare. dicompare is suitable for multi-site studies and clinical environments without requiring software installation or external data uploads.
dicompare supports DICOM session validation against templates based on:
- Reference sessions: JSON schema files can be generated based on a reference MRI scanning session;
- [TESTING] domain guidelines: Flexible guidelines for specific domains (currently QSM);
- [FUTURE] landmark studies: Schema files based on landmark studies such as the HCP, ABCD, and UK BioBank projects.
Command-line interface (CLI) and application programming interface (API)
While you can run dicompare in your browser now without any installation, you may also use the underlying dicompare pip package if you wish to use the command-line interface (CLI) or application programming interface (API).
pip install dicompare
Command-line interface (CLI)
The package provides the following CLI entry points:
dcm-gen-session: Generate JSON schemas for DICOM validation from a reference sessiondcm-check-session: Validate DICOM sessions against JSON or Python schemas
1. Generate a JSON schema from a reference session
dcm-gen-session \
--in_session_dir /path/to/dicom/session \
--out_json_schema schema.json \
--reference_fields EchoTime RepetitionTime FlipAngle
This creates a JSON schema describing the session based on the specified reference fields.
2. Validate a DICOM session
dcm-check-session \
--in_session /path/to/dicom/session \
--json_schema schema.json \
--out_json compliance_report.json
The tool will output a compliance summary, indicating deviations from the schema.
Python API
The dicompare package provides a comprehensive Python API for programmatic schema generation, validation, and DICOM processing.
Loading DICOM data
Load a DICOM session:
from dicompare import load_dicom_session
session_df = load_dicom_session(
session_dir="/path/to/dicom/session",
show_progress=True
)
Load individual DICOM files:
from dicompare import load_dicom
dicom_data = load_dicom(
dicom_paths=["/path/to/file1.dcm", "/path/to/file2.dcm"],
show_progress=True
)
Load Siemens .pro files:
from dicompare import load_pro_session
pro_session = load_pro_session(
session_dir="/path/to/pro/files",
show_progress=True
)
Generate a JSON schema
from dicompare import load_dicom_session, create_json_schema
import json
# Load the reference session
session_df = load_dicom_session(
session_dir="/path/to/dicom/session",
show_progress=True
)
# Create a JSON schema
reference_fields = ["EchoTime", "RepetitionTime", "FlipAngle"]
json_schema = create_json_schema(
session_df=session_df,
reference_fields=reference_fields
)
# Save the schema
with open("schema.json", "w") as f:
json.dump(json_schema, f, indent=4)
Validate a session against a JSON schema
from dicompare import (
load_json_schema,
load_dicom_session,
check_session_compliance_with_json_schema,
map_to_json_reference
)
# Load the JSON schema
reference_fields, json_schema = load_json_schema(json_schema_path="schema.json")
# Load the input session
in_session = load_dicom_session(
session_dir="/path/to/dicom/session",
show_progress=True
)
# Map acquisitions to schema
session_map = map_to_json_reference(in_session, json_schema)
# Check compliance
compliance_summary = check_session_compliance_with_json_schema(
in_session=in_session,
ref_session=json_schema,
session_map=session_map
)
# Display results
for entry in compliance_summary:
print(entry)
Additional utilities
Assign acquisition and run numbers:
from dicompare import assign_acquisition_and_run_numbers
session_df = assign_acquisition_and_run_numbers(
session_df=session_df,
acquisition_fields=["ProtocolName"],
reference_fields=["EchoTime", "RepetitionTime"]
)
Get DICOM tag information:
from dicompare import get_tag_info, get_all_tags_in_dataset
# Get info about a specific tag
tag_info = get_tag_info("EchoTime")
print(tag_info) # {'tag': '(0018,0081)', 'name': 'Echo Time', 'type': 'float'}
# Get all tags in a dataset
all_tags = get_all_tags_in_dataset(dicom_metadata)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dicompare-0.1.35.tar.gz.
File metadata
- Download URL: dicompare-0.1.35.tar.gz
- Upload date:
- Size: 122.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
504e421c9a4875b03b17ab7f718603bace22b5510869100a819a626eb8ca2221
|
|
| MD5 |
20135bedcf3c29b9683fc36263826835
|
|
| BLAKE2b-256 |
889ff0d99592487cf34fb7e94d9ee192a55351afd08a2e20c256bba787ba27e2
|
File details
Details for the file dicompare-0.1.35-py3-none-any.whl.
File metadata
- Download URL: dicompare-0.1.35-py3-none-any.whl
- Upload date:
- Size: 143.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6a06f9cd2dafb436c176b08834b76d05efdc9975cd0789cc74936d5178f3c9c
|
|
| MD5 |
5662c692e5be41ea249581c41e7070ab
|
|
| BLAKE2b-256 |
770865063c959500c091372e47075860d372f9b24021b0c4b2c3bc71f2be8d76
|