extracting-dicom-metadata
它能做什么
这项技能读取 DICOM 医学影像文件,提取其中的报告文本,并列出包含患者信息的文件头字段。适合为临床文本分析或安全共享而准备影像数据的团队。
适用场景
- ✓当你导入 DICOM 文件,需要分析其中的放射报告文本的时候。
- ✓当你在共享影像之前,必须列出包含患者信息的文件头标签的时候。
- ✓当 DICOM 结构化报告中包含需要去标识化的口述报告的时候。
技能链接
https://github.com/maziyarpanahi/openmed/blob/master/skills/extracting-dicom-metadata/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请读取这些 CT DICOM 文件,提取报告文本,并列出包含患者信息的文件头字段。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会读取文件头和结构化报告内容,提取叙述性文字,标记含有标识符的标签,并把报告文本交给去标识化步骤。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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:
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
- Read the dataset with
pydicom.dcmread(usestop_before_pixels=Truefor header-only/metadata work — faster, avoids loading pixels). - Walk the SR content tree.
ContentSequencenestsCONTAINER,TEXT,CODE,NUM,PNAMEnodes; concatenateTEXT.TextValue(and relevantCODE/NUMmeasurements) in document order to reconstruct the report. - 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. - De-identify → analyze the report narrative with OpenMed.
- 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.deidentify→openmed.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 `(
常见问题
它会分析图像像素吗?
不会。它只读取文件头和结构化报告文本,不读取图像本身。
它涵盖哪些影像类型?
它涵盖 CT、MR、CR 和超声等常见成像方式,以及放射结构化报告。
它会对报告文本本身进行去标识化吗?
提取出的报告文本会交给去标识化步骤,那是另一个独立的步骤。
详情
作者的原始描述
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.
repo: maziyarpanahi/openmed
热度
- GitHub 星标
- 5.8k
- 排名
- #14700
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
annotating-variants
5.8k帮你的智能体预测基因变异的作用,把 HGVS 名称转换为基因组位置,并使用免费的公共注释工具添加人群频率。
ask-openmed
5.8k帮你的智能体为临床文本请求选择合适的 OpenMed 工作流程,并在可能涉及患者数据时,先进行隐私检查。
assembling-fhir-bundles
5.8k把多份 FHIR 健康记录打包成一个事务 Bundle,可直接发送给 EHR 系统,并正确链接其中的内部引用。
auditing-deid-leakage
5.8k扫描已去标识化的临床文本,查找残留的标识符,例如社会安全号、银行卡号、电子邮件地址和日期,若仍有残留则阻止发布。