DICOM De-identification & Redaction Engine
Project description
DICOM-DRE
A fast, deterministic DICOM de-identification and redaction engine.
dicom-dre removes protected health information (PHI) from DICOM instances in
two places where it commonly hides:
- Burned-in pixel PHI. A declarative device catalog matches each instance to a known device and acquisition variant (by manufacturer, model, modality, software version, image dimensions, SOP class, and image type) and blanks the fixed pixel regions where that device is known to burn in text. For JPEG Baseline images, regions are zeroed directly in the DCT domain, so unblanked pixels are preserved bit-for-bit with no recompression loss.
- Free-text metadata PHI. Description fields that frequently carry PHI
(
SeriesDescription,StudyDescription,ProtocolName) are redacted token-by-token against an allowlist: any token not on the allowlist is masked, while known clinical terms pass through.
Instance metadata is also scrubbed against a configurable de-identification profile, and instance/study/series UIDs are deterministically re-derived, so the same input plus the same parameters always yields the same output.
Deterministic by design
The engine performs no hashing lookups, no network calls, and no randomization of its own. De-identification parameters (patient ID, accession number, UID root, salt, etc.) are consumed exactly as supplied. Given identical inputs and parameters, output is byte-reproducible. Callers are responsible for supplying already-hashed or already-mapped identifier values.
This determinism is guarded by a regression test suite built from sampled DICOM studies. Each fixture records the technical matching tags and the expected catalog filtering and pixel-scrub decisions (with no PHI or pixel data), and the tests assert that the engine still reaches the recorded decision for every case, so catalog or profile changes that alter existing outcomes are caught.
Provenance and portability caveat
The bundled device catalog and free-text allowlist were derived from studies on
a single PACS at one medical research center. The catalog's device rules,
pixel scrub regions, and allowlisted vocabulary reflect the scanner fleet and
reporting conventions observed there. They are unlikely to be complete or
correct for a different site. Before relying on dicom-dre elsewhere:
- Validate pixel scrubbing against your own devices; unmatched or mismatched devices will not have their burned-in text blanked.
- Review and extend the allowlist for your local vocabulary to avoid over-redaction (masking legitimate terms) or under-redaction (leaking PHI).
Treat the shipped catalog and allowlist as a starting point that requires local validation, not as a turnkey configuration.
Outcomes
Each instance resolves to one terminal outcome:
DEIDENTIFIED— metadata scrubbed, pixel regions blanked as required, written to the output directory.FILTERED— the instance matched a deny rule (for example an unsupported modality or device) and was intentionally not emitted.QUARANTINED— processing failed; the instance was not emitted.
Installation
This project uses uv for package management and
requires Python 3.12.
uv pip install -e .
Command-line usage
De-identify files or directories into an output directory:
# Single file
dicom-dre deidentify scan.dcm -o out/
# Recurse a directory tree (mirrored under out/)
dicom-dre deidentify studies/ -o out/ -r
# Mixed sources, parallel workers, chosen profile and parameters
dicom-dre deidentify a.dcm b.dcm dir/ -o out/ \
--profile default \
-p PATIENT_ID=TEST -p ACCESSION_NUMBER=TESTING \
-j 8
Sources are read but never modified. The command exits non-zero if any instance
is QUARANTINED; FILTERED instances are a normal outcome.
Profiles
Select a de-identification profile with --profile:
default— full metadata scrub with re-derived UIDs.lds— HIPAA limited data set (retains dates).lds-no-dob— limited data set without date of birth.pixels-only— pixel scrubbing with minimal metadata changes.
Free-text redaction tools
The redactor subcommands operate on CSV files of free text, using the same
allowlist mechanism as description-field redaction:
# Redact every cell of a CSV against the allowlist
dicom-dre redactor redact --input input.csv --output output.csv
# Preview redactions side by side
dicom-dre redactor quality-check input.csv
# List unique tokens to help curate an allowlist
dicom-dre redactor show-tokens --input input.csv
Pass --allowlist <file.csv-or-path> to use a custom allowlist and
--preserve-dates to keep dates and times intact for limited data sets.
These commands are useful when you can dump every SeriesDescription,
StudyDescription, and ProtocolName value from your PACS: run them over that
export to review the distinct tokens and build an allowlist tailored to your
site's vocabulary.
Library usage
from dicom_dre import deidentify_paths, ProfileSpec
for item in deidentify_paths(
sources=["studies/"],
output_dir="out/",
recursive=True,
profile_spec=ProfileSpec(name="default", parameters={"PATIENT_ID": "TEST"}),
):
print(item.input_file, item.result.outcome)
The public API also exposes deidentify_file, build_profile,
get_default_catalog, DeviceCatalog, TextRedactor, and the profile
factories. See the module docstrings and docs/ for details.
Development
uv run pytest # run the test suite
License
Apache-2.0. The JPEG DCT-domain scrubber is a port of the PixelMed JPEG
Selective Block Redaction Codec and is distributed under that codec's BSD
license; see the source header in src/dicom_dre/jpeg_dct_scrubber.py and the
NOTICE file.
Acknowledgements
This project would not have been possible without our years of working with and learning from the MIRC CTP (Clinical Trial Processor) engine, for which we are grateful.
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 Distributions
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 dicom_dre-1.0.0.dev2.tar.gz.
File metadata
- Download URL: dicom_dre-1.0.0.dev2.tar.gz
- Upload date:
- Size: 354.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c848ff2720ee218db593051b1f8511dc40d944675b3f4792d023878d7c06cf5
|
|
| MD5 |
702336ec79e79849604495eb71df494e
|
|
| BLAKE2b-256 |
2709dd7ca936b2e866a1949bd0b8dd0250b279170aa85b72b658d37526ce94e2
|
Provenance
The following attestation bundles were made for dicom_dre-1.0.0.dev2.tar.gz:
Publisher:
deploy.yml on susom/dicom-dre
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom_dre-1.0.0.dev2.tar.gz -
Subject digest:
2c848ff2720ee218db593051b1f8511dc40d944675b3f4792d023878d7c06cf5 - Sigstore transparency entry: 2239658349
- Sigstore integration time:
-
Permalink:
susom/dicom-dre@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Branch / Tag:
refs/heads/development - Owner: https://github.com/susom
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dicom_dre-1.0.0.dev2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: dicom_dre-1.0.0.dev2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 217.2 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fa1c405f2fef0776e6766a20c09673c8e679b75bdd81e23db3a2f3cd09dd9f6
|
|
| MD5 |
f254336d719a0ffff07b4b44ea28a6ae
|
|
| BLAKE2b-256 |
198333a8202781dc1073e2670e4355ecf12410969760280b1b0083b143ca80cc
|
Provenance
The following attestation bundles were made for dicom_dre-1.0.0.dev2-cp312-cp312-win_amd64.whl:
Publisher:
deploy.yml on susom/dicom-dre
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom_dre-1.0.0.dev2-cp312-cp312-win_amd64.whl -
Subject digest:
5fa1c405f2fef0776e6766a20c09673c8e679b75bdd81e23db3a2f3cd09dd9f6 - Sigstore transparency entry: 2239659115
- Sigstore integration time:
-
Permalink:
susom/dicom-dre@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Branch / Tag:
refs/heads/development - Owner: https://github.com/susom
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dicom_dre-1.0.0.dev2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: dicom_dre-1.0.0.dev2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 241.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f91d76410b019841c54ee2b33cc26418ec412bfc9bf197ac84f1ddc2fa52282
|
|
| MD5 |
5a63fcc5decdc0ecb94d175fd993c551
|
|
| BLAKE2b-256 |
dc0155d58d3da21da5fdb2badab6e4b7dda12031969471e69f35ffaed16ab849
|
Provenance
The following attestation bundles were made for dicom_dre-1.0.0.dev2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
deploy.yml on susom/dicom-dre
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom_dre-1.0.0.dev2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
4f91d76410b019841c54ee2b33cc26418ec412bfc9bf197ac84f1ddc2fa52282 - Sigstore transparency entry: 2239660345
- Sigstore integration time:
-
Permalink:
susom/dicom-dre@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Branch / Tag:
refs/heads/development - Owner: https://github.com/susom
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dicom_dre-1.0.0.dev2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: dicom_dre-1.0.0.dev2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 240.6 kB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06fd8eaf9bfdb61992152edca263960ba3be5d4909b7137d1245b1d7e91ee539
|
|
| MD5 |
d1deb37d07b2cacaf234a9a46e5b6798
|
|
| BLAKE2b-256 |
3a29390224ac61bd1db27e1bb129b9e4bca2dfc7b88bbacf9c50446ee681b8ad
|
Provenance
The following attestation bundles were made for dicom_dre-1.0.0.dev2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:
Publisher:
deploy.yml on susom/dicom-dre
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom_dre-1.0.0.dev2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl -
Subject digest:
06fd8eaf9bfdb61992152edca263960ba3be5d4909b7137d1245b1d7e91ee539 - Sigstore transparency entry: 2239660738
- Sigstore integration time:
-
Permalink:
susom/dicom-dre@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Branch / Tag:
refs/heads/development - Owner: https://github.com/susom
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dicom_dre-1.0.0.dev2-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: dicom_dre-1.0.0.dev2-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 210.5 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d897313f5dcc051d3f1aea54084c23ecc098a37770dded989bd1827ece2f61d
|
|
| MD5 |
67747bad4f2b89649ce73facf4482ce4
|
|
| BLAKE2b-256 |
5475f56167262d5f75687ed5c890211ed2fd2a51b86b73e186116268e8e934e0
|
Provenance
The following attestation bundles were made for dicom_dre-1.0.0.dev2-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
deploy.yml on susom/dicom-dre
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom_dre-1.0.0.dev2-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
2d897313f5dcc051d3f1aea54084c23ecc098a37770dded989bd1827ece2f61d - Sigstore transparency entry: 2239661057
- Sigstore integration time:
-
Permalink:
susom/dicom-dre@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Branch / Tag:
refs/heads/development - Owner: https://github.com/susom
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@80e26c99e5f270528dfa2ddb8551b0baf3fdc7b7 -
Trigger Event:
push
-
Statement type: