pydicom DICOM Toolkit
A safety-first guide and CLI toolkit for reading, writing, converting and de-identification-preflighting local DICOM data with pydicom 3.0.2.
Dev & CodingAdvanced★ 33,030⑂ 3,248AI score 9/10Last updated: Aug 9, 2026
What it does
- Safe dataset reads: shows
dcmread()patterns withstop_before_pixels,specific_tagsanddefer_size, and explicitly forbidsprint(ds), full JSON dumps or logging element values because DICOM metadata can carry PHI. - Transfer syntax & codec preflight: decodes Transfer Syntax UIDs and maps out pinned plugin combinations (pylibjpeg, pyjpegls, python-gdcm, Pillow) plus supply-chain advice on hash-verified, internally mirrored wheels.
- Pixel data handling: frame-scoped decoding via
pydicom.pixels, array shape semantics, the correct Modality LUT → VOI LUT order, MONOCHROME1 inversion and Palette Color LUTs. - Compression / encapsulation: notes that
compress()anddecompress()mutate Pixel Data and mint a new SOP Instance UID, plusencapsulate()andgenerate_frames()usage. - Bounded de-identification workflow: a nine-step PS3.15 Annex E–aligned process covering original preservation, recursive sequence actions, one-to-one UID replacement, date-shift policy, burned-in annotation review and secret handling for UID keys/maps.
- Seven helper CLIs: aggregate metadata, technical inventory, codec inspector, frame/memory planner, single non-diagnostic frame render, pseudonymizer + audit, and UID map validator.
Who it's for
- Researchers and data engineers preprocessing medical imaging datasets in Python
- Developers building PACS or imaging pipelines who must pin codec dependencies
- Privacy/IRB engineers designing pseudonymization and audit trails before data sharing
- Teams migrating pydicom 2.x code to the 3.0 API
Example uses
- Dataset triage: "Summarize modality, image size and transfer syntax across authorized/" → run
scripts/dicom_inventory.py authorized/ --recursivefor an aggregate report with no per-patient values exposed. - Fixing decode errors: a JPEG 2000 CT series fails to open, so
transfer_syntax_inspector.pyreveals which plugins are installed and which pinned package to add. - Research pseudonymization: generate a project key, run
anonymize_dicom.py --uid-key-file project.key --uid-scope export-v1, thendeidentification_audit.pyon the derivative before expert sign-off.
· · · Install guide · · ·
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the skills/pydicom folder from the GitHub repo K-Dense-AI/scientific-agent-skills into my ~/.claude/skills/pydicom/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git && mkdir -p ~/.claude/skills && cp -r scientific-agent-skills/skills/pydicom ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal and clone the repository:
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git - Copy the skill into Claude Code's skills folder:
mkdir -p ~/.claude/skills && cp -r scientific-agent-skills/skills/pydicom ~/.claude/skills/ - Create and activate a Python virtual environment (e.g.
python3 -m venv .venv && source .venv/bin/activate). Python 3.10+ is required. - Install the reviewed pinned release:
uv pip install "pydicom==3.0.2"(orpip install "pydicom==3.0.2"). - For pixel arrays and rendering add
numpy==2.5.1andPillow==12.3.0; for compressed syntaxes install only the plugins you actually need (pylibjpeg family, pyjpegls, or python-gdcm). - Restart Claude Code and ask something like "use pydicom to inspect this DICOM folder" — the skill triggers automatically.
- Only point it at local data you are authorized to access, keep originals untouched, and never commit, sync or share the generated UID key files.
View source on GitHub ↗License: MIT