Dicom Metadata Extract
NVIDIAOfficialCreated by NVIDIA MedTech Team
- Skill
- Tool integration
- Science and research
- Apache-2.0
- Medium risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The dicom-metadata-extract skill provides a programmatic interface for reading DICOM files to retrieve core metadata and identify the presence of Protected Health Information (PHI) based on a subset of standard tags. It is designed for technical evaluation and data processing workflows rather than clinical or regulatory use. The skill outputs structured JSON containing modality, transfer syntax, and grouped study information, while explicitly warning against its use for anonymization or clinical decision-making.
What it does
- Extracts study, series, and image metadata from a single DICOM file.
- Flags the presence of PHI based on standard DICOM tags.
- Outputs metadata in a structured JSON format.
- Provides a command-line interface for integration into automated pipelines.
- Supports validation of output quality through dedicated verification tools.
When to use it
- When you need to inspect DICOM file headers for technical metadata.
- When performing initial data screening to identify standard PHI tags.
- When building automated data processing pipelines for medical imaging research.
- When verifying the structure of DICOM files during development or testing.
Advantages
- Provides a lightweight and standardized way to access DICOM metadata.
- Includes built-in PHI flagging for common standard tags.
- Integrates easily with existing Python-based medical imaging workflows.
- Supports trusted execution patterns for evidence-based review.
Usage examples
- “Extract metadata from the file scan_01.dcm and save it to output.json.”
- The agent runs the extraction script on the specified file and generates a JSON file containing the extracted metadata and PHI flags.
- “Check if the DICOM file at /data/ct_scan.dcm contains any standard PHI tags.”
- The agent processes the file and returns a report indicating whether PHI was detected and which specific tags were identified.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/nvidia/dicom-metadata-extract/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip dicom-metadata-extract.zip -d .agents/skills
Documentation by NVIDIA MedTech Team
DICOM Metadata Extract
Purpose
Used for extracting selected metadata from one DICOM file and flagging standard-tag PHI presence. Not for anonymization or clinical use.
Use the wrapper exactly as documented; do not replace the upstream entrypoint with a handwritten implementation.
Manifest I/O: inputs are
dicom_path; outputs aremetadata_json.
Instructions
Read
skill_manifest.yamlbefore changing arguments, side effects, or validation gates.Run
scripts/extract_metadata.pythrough the documented command below; keep outputs under a caller-provided run directory.If a host agent exposes
run_script, userun_script("scripts/extract_metadata.py", args=[...]); otherwise run the Bash/Python command shown below.Check the emitted JSON and run
medagent.verifiers.dicom_metadata_quality_v1on evidence packs before treating the run as reviewed evidence.
Available Scripts
| Script | Purpose | Arguments |
|---|---|---|
scripts/extract_metadata.py | Primary entrypoint declared by skill_manifest.yaml. | PATH_TO_DICOM [--output OUT.json] |
Prerequisites
Runtime requirements: Python packages listed in
runtime.side_effects.pip_packages.Run commands from the repository root unless an existing section below says otherwise.
Limitations
Small PS3.15-inspired standard-tag subset only; not a complete Basic Application Confidentiality Profile implementation.
Private tags not checked
Burnt-in pixel PHI not detected
Multi-frame handling minimal
Not for clinical deployment, regulatory de-identification, autonomous diagnosis, patient-facing use.
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
| Missing dependency or import error | Runtime package drift from skill_manifest.yaml. | Install the packages declared in the manifest or use the documented setup command. |
| Empty or schema-invalid output | Wrong input path, unsupported modality, or upstream failure. | Re-run with a known fixture and inspect the wrapper JSON plus stderr. |
| Validation gate failure | Output violated a declared engineering invariant. | Keep the failed evidence pack and use the gate message to repair inputs or wrapper code. |
Reads one DICOM file with pydicom and emits JSON on stdout.
python scripts/extract_metadata.py PATH_TO_DICOM
python scripts/extract_metadata.py PATH_TO_DICOM --output result.jsonOutput includes transfer_syntax, modality, grouped study/series/image
metadata, phi_present, and phi_tags_found.
Use this as the smallest end-to-end example of a Medical AI Skills skill. Do not use it for anonymization, private-tag review, pixel PHI detection, or clinical interpretation.
For second-pass evidence review, generate a trusted run:
python -m eval_engine.run_trusted skills/dicom-metadata-extract \
--fixture skills/dicom-metadata-extract/fixtures/sample_ct.dcm \
--out runs/dicom_metadata_trustedFiles
- AGENTS.md508 B
- ATTRIBUTION.mdAdded by AutoGineer937 B
- BENCHMARK.md7.0 KiB
- LICENSELicence file added by AutoGineer11.2 KiB
- SKILL.md3.2 KiB
- evals/baseline.yaml2.2 KiB
- evals/evals.json1.8 KiB
- fixtures/generate_sample.pyScript3.0 KiB
- scripts/extract_metadata.pyScript5.3 KiB
- skill-card.md4.5 KiB
- skill.oms.sig6.1 KiB
- skill_manifest.yaml5.0 KiB
- tests/test_basic.pyScript2.5 KiB
- validators/output_schema.json2.3 KiB
scripts/extract_metadata.py
#!/usr/bin/env python3
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""DICOM metadata extraction skill.
Reads a DICOM file and emits structured JSON with metadata + a PHI-tag-presence flag.
Scope: standard DICOM PS3.15 basic-profile tags only. NOT a de-identifier.
Private tags and burnt-in pixel PHI are explicitly out of scope.
"""
import json
from pathlib import Path
from typing import Any
import pydicom
import typer
app = typer.Typer(add_completion=False)
# Standard PHI tag names from DICOM PS3.15 Basic Application Confidentiality Profile.
# Subset sufficient for engineering verification — NOT for clinical de-identification.
PHI_TAGS_STANDARD = [
"PatientName",
"PatientID",
"PatientBirthDate",
"PatientSex",
"PatientAge",
"PatientWeight",
"PatientAddress",
"PatientTelephoneNumbers",
"InstitutionName",
"InstitutionAddress",
"InstitutionalDepartmentName",
"ReferringPhysicianName",
"PerformingPhysicianName",
"OperatorsName",
"OtherPatientIDs",
"OtherPatientNames",
"EthnicGroup",
"Occupation",
"PatientComments",
]
PHI_SCOPE_DISCLAIMER = (
"Standard DICOM PS3.15 basic-profile tags only. "
"Private tags (odd group) NOT checked. "
"Burnt-in pixel text NOT detected. "
"Use a proper de-identifier for clinical or regulatory work."
)
def _safe_str(value: Any) -> str | None:
if value is None:
return None
try:
return str(value)
except Exception:
return repr(value)
def _public_path(path: Path) -> str:
try:
return str(path.resolve().relative_to(Path.cwd().resolve()))
except ValueError:
return str(path)
def extract(path: Path) -> dict:
"""Extract metadata from a DICOM file. Returns a JSON-serialisable dict."""
try:
ds = pydicom.dcmread(str(path), stop_before_pixels=True)
except Exception as e:
raise typer.BadParameter(f"could not read DICOM header from {path}: {e}") from e
ts_uid = None
ts_name = None
if hasattr(ds, "file_meta") and ds.file_meta is not None:
if hasattr(ds.file_meta, "TransferSyntaxUID"):
ts_uid = str(ds.file_meta.TransferSyntaxUID)
ts_name = ds.file_meta.TransferSyntaxUID.name
study = {
"StudyInstanceUID": _safe_str(getattr(ds, "StudyInstanceUID", None)),
"StudyDate": _safe_str(getattr(ds, "StudyDate", None)),
"StudyTime": _safe_str(getattr(ds, "StudyTime", None)),
"StudyDescription": _safe_str(getattr(ds, "StudyDescription", None)),
"AccessionNumber": _safe_str(getattr(ds, "AccessionNumber", None)),
}
series = {
"SeriesInstanceUID": _safe_str(getattr(ds, "SeriesInstanceUID", None)),
"SeriesNumber": _safe_str(getattr(ds, "SeriesNumber", None)),
"SeriesDescription": _safe_str(getattr(ds, "SeriesDescription", None)),
"Modality": _safe_str(getattr(ds, "Modality", None)),
"BodyPartExamined": _safe_str(getattr(ds, "BodyPartExamined", None)),
}
image = {
"SOPInstanceUID": _safe_str(getattr(ds, "SOPInstanceUID", None)),
"InstanceNumber": _safe_str(getattr(ds, "InstanceNumber", None)),
"Rows": getattr(ds, "Rows", None),
"Columns": getattr(ds, "Columns", None),
"BitsAllocated": getattr(ds, "BitsAllocated", None),
"PixelRepresentation": getattr(ds, "PixelRepresentation", None),
"PhotometricInterpretation": _safe_str(getattr(ds, "PhotometricInterpretation", None)),
"NumberOfFrames": getattr(ds, "NumberOfFrames", None),
}
phi_tags_found = []
for tag_name in PHI_TAGS_STANDARD:
if hasattr(ds, tag_name):
value_str = _safe_str(getattr(ds, tag_name, None))
if value_str is not None and value_str.strip() != "":
phi_tags_found.append(tag_name)
return {
"path": _public_path(path),
"transfer_syntax": {"uid": ts_uid, "name": ts_name},
"modality": _safe_str(getattr(ds, "Modality", None)),
"study": study,
"series": series,
"image": image,
"phi_present": len(phi_tags_found) > 0,
"phi_tags_found": phi_tags_found,
"phi_scope_disclaimer": PHI_SCOPE_DISCLAIMER,
}
@app.command()
def main(
dicom_path: Path = typer.Argument(..., exists=True, dir_okay=False, readable=True),
output: Path = typer.Option(None, "--output", "-o", help="JSON output path; stdout if omitted"),
) -> None:
"""Extract metadata from a DICOM file."""
result = extract(dicom_path)
payload = json.dumps(result, indent=2, default=str)
if output:
output.write_text(payload)
print(f"wrote {output}")
else:
print(payload)
if __name__ == "__main__":
app()
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Needs Python
Security
What our scanner noticed· Medium risk
- Large base64-encoded blobs
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- NVIDIA MedTech Team
- Publisher
- NVIDIA (Official)
- Source
- NVIDIA/skills · skills/dicom-metadata-extract · commit fce3cca
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE-APACHE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by NVIDIA MedTech Team or NVIDIA.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download dicom-metadata-extract.zip