# Extracting Dicom Metadata

Reads DICOM file headers and DICOM-SR (Structured Report) content to pull study/series...

- Repository: https://github.com/maziyarpanahi/openmed (5755 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add maziyarpanahi/openmed --skill extracting-dicom-metadata -g -a claude-code -y`
Codex: `npx skills add maziyarpanahi/openmed --skill extracting-dicom-metadata -g -a codex -y`
Cursor: `npx skills add maziyarpanahi/openmed --skill extracting-dicom-metadata -g -a cursor -y`
Gemini CLI: `npx skills add maziyarpanahi/openmed --skill extracting-dicom-metadata -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add maziyarpanahi/openmed`

## Description

Reads DICOM file headers and DICOM-SR (Structured Report) content to pull study/series metadata and embedded report text, and flags PHI carried in header tags. Use before OpenMed processing when ingesting imaging data (CT/MR/CR/US, radiology SR) and you need the report narrative de-identified and analyzed, plus a list of header tags that must be scrubbed. Hand SR/report text to openmed.deidentify and openmed.analyze_text; use pydicom to read tags. Trigger keywords: DICOM, pydicom, DICOM-SR, structured report, PatientName, study metadata, PACS, radiology report, PS3.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Extracting DICOM Metadata & Report Text for OpenMed

DICOM (Digital Imaging and Communications in Medicine) files carry far more than
pixels: a **header** of tagged attributes (patient, study, series, equipment)
and, for **DICOM-SR (Structured Reports)**, a content tree holding the actual
radiology/cardiology *report text*. Two jobs sit here: pull the report narrative
for NLP, and **flag the PHI in the header** so it gets scrubbed. This skill does
both, then hands narrative to OpenMed. Header tags are read with `pydicom`
(external, MIT-licensed); de-identification of the extracted text is OpenMed's.

## When to use

- You ingest DICOM from PACS/VNA or a research archive and want the SR report
  text mined with clinical NLP.
- You must enumerate PHI-bearing header tags before sharing/exporting images.
- You have DICOM-SR objects (e.g. radiology measurements + impression) whose
  content tree contains the dictated report.

## DICOM headers in one minute

Every attribute has a **tag** `(gggg,eeee)` (group, element), a **VR** (value
representation, e.g. `PN` person name, `DA` date, `UI` UID), and a value. PHI
clusters in well-known tags:

| Tag | Name | VR | Notes |
| --- | --- | --- | --- |
| (0010,0010) | PatientName | PN | direct identifier |
| (0010,0020) | PatientID | LO | MRN |
| (0010,0030) | PatientBirthDate | DA | DOB |
| (0010,1040) | PatientAddress | LO | address |
| (0008,0090) | ReferringPhysicianName | PN | provider |
| (0008,0020/0030) | StudyDate / StudyTime | DA/TM | dates |
| (0008,0050) | AccessionNumber | SH | order id |
| (0008,103E) | SeriesDescription | LO | free text, may leak PHI |
| (0020,4000) | ImageComments | LT | free text, may leak PHI |
| (0040,A730) | ContentSequence | SQ | DICOM-SR report tree |

## Quick start

Read the header, pull SR report text, flag PHI tags, hand off to OpenMed:

```python
import pydicom
import openmed

ds = pydicom.dcmread("study.dcm")

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/extracting-dicom-metadata/SKILL.md
