Extracting Dicom Metadata logo

Extracting Dicom Metadata

CommunityPopular
maziyarpanahi
extracting-dicom-metadata

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.

Overview

Publishermaziyarpanahi
Repositoryopenmed
Skill nameextracting-dicom-metadata
Stars
5.3K
Forks
677
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by maziyarpanahi on GitHub. Read the source before you install it.

Installation

Install the Extracting Dicom Metadata AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/maziyarpanahi/openmed.git /tmp/openmed
mkdir -p .claude/skills
cp -r /tmp/openmed/skills/extracting-dicom-metadata .claude/skills/extracting-dicom-metadata
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Extracting Dicom Metadata in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Extracting Dicom Metadata on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Extracting Dicom Metadata is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

TagNameVRNotes
(0010,0010)PatientNamePNdirect identifier
(0010,0020)PatientIDLOMRN
(0010,0030)PatientBirthDateDADOB
(0010,1040)PatientAddressLOaddress
(0008,0090)ReferringPhysicianNamePNprovider
(0008,0020/0030)StudyDate / StudyTimeDA/TMdates
(0008,0050)AccessionNumberSHorder id
(0008,103E)SeriesDescriptionLOfree text — may leak PHI
(0020,4000)ImageCommentsLTfree text — may leak PHI
(0040,A730)ContentSequenceSQDICOM-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")

# 1) Enumerate PHI-bearing header tags (report, do not log values).
PHI_TAGS = [
    (0x0010, 0x0010), (0x0010, 0x0020), (0x0010, 0x0030), (0x0010, 0x1040),
    (0x0008, 0x0090), (0x0008, 0x0050), (0x0008, 0x0020), (0x0008, 0x0030),
]
present_phi = [hex_pair for hex_pair in PHI_TAGS if hex_pair in ds]

# 2) Extract report text from a DICOM-SR content tree (recursively).
def sr_text(dataset):
    chunks = []
    for item in dataset.get("ContentSequence", []):
        vt = item.get("ValueType")
        if vt == "TEXT" and "TextValue" in item:
            chunks.append(item.TextValue)
        if "ContentSequence" in item:          # nested CONTAINER
            chunks.append(sr_text(item))
    return "\n".join(c for c in chunks if c)

report = sr_text(ds)
# Some modalities stash narrative in free-text header tags too:
for tag in ("ImageComments", "SeriesDescription", "StudyDescription"):
    if tag in ds and isinstance(ds.get(tag), str):
        report += "\n" + ds.get(tag)

# 3) De-identify the narrative, then run NER.
if report.strip():
    deid = openmed.deidentify(report, method="replace", policy="hipaa_safe_harbor")
    result = openmed.analyze_text(deid.text, output_format="dict")

pydicom reads tags by keyword (ds.PatientName) or by (group, element). DICOM-SR text lives in the recursive ContentSequence content tree.

Workflow

  1. Read the dataset with pydicom.dcmread (use stop_before_pixels=True for header-only/metadata work — faster, avoids loading pixels).
  2. Walk the SR content tree. ContentSequence nests CONTAINER, TEXT, CODE, NUM, PNAME nodes; concatenate TEXT.TextValue (and relevant CODE/NUM measurements) in document order to reconstruct the report.
  3. Inventory PHI tags. Flag the standard identifier tags and free-text tags (ImageComments, *Description) that frequently leak PHI. Report tag presence — never echo the values into logs.
  4. De-identify → analyze the report narrative with OpenMed.
  5. Scrub the header before any image export using a DICOM de-identification profile (PS3.15 Annex E / Basic Application Level Confidentiality). OpenMed de-identifies the narrative; header scrubbing is a separate DICOM step.

Hand-off to / from OpenMed

  • To OpenMed: SR report text (and free-text header tags) → openmed.deidentifyopenmed.analyze_text.
  • Header de-id is out of scope for OpenMed — OpenMed handles the text narrative; use a DICOM-native de-identifier (pydicom + PS3.15 profile, or a PACS de-id node) to scrub (0010,xxxx) and burned-in-pixel PHI. This skill's job is to flag those tags so they aren't missed.
  • Re-link by UID, not PHI. Carry StudyInstanceUID/SeriesInstanceUID as rejoin keys; these are not identifiers but should be re-mapped consistently if the profile requires UID remapping.

Edge cases & gotchas

  • Pixel-burned PHI. Ultrasound and secondary-capture images often burn name/ MRN/date into the pixels — header scrubbing alone is insufficient; flag modalities (US, SC, XC) for pixel review/OCR. OpenMed's multimodal/OCR intake can read burned-in text for redaction screening.
  • Private tags. Vendor (gggg,eeee) odd-group private tags can hide PHI; PS3.15 requires removing or whitelisting them — don't trust unknown tags.
  • Date shifting must be consistent. If you date-shift StudyDate, shift all related dates by the same offset to preserve temporal relationships.
  • SR value types. Not all SR content is narrative — NUM (measurements), CODE (coded findings), PNAME (person names, PHI!) need different handling; don't dump PNAME into NLP text.
  • Character sets. Honor SpecificCharacterSet (0008,0005); non-Latin patient names need correct decoding before de-id.
  • Read-only intake. Treat source DICOM as immutable; write de-identified copies, never overwrite originals.

Standards & references

Frequently asked questions

What does the Extracting Dicom Metadata AI skill do?

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.

Why use Extracting Dicom Metadata on TypingMind?

Because you install it once and use it with any model. Extracting Dicom Metadata is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Extracting Dicom Metadata in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/maziyarpanahi/openmed/tree/master/skills/extracting-dicom-metadata. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Extracting Dicom Metadata?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Extracting Dicom Metadata?

As many as you like. As long as a model supports skills, you can use Extracting Dicom Metadata with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Extracting Dicom Metadata AI skill free?

Yes. It is published on GitHub by maziyarpanahi under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇