본문으로 건너뛰기
Skillpedia
데이터베이스51k · #3539

pydicom

하는 일

pydicom은 의료 영상 파일(DICOM)을 다루는 도구입니다. 환자 정보나 영상 세부 사항처럼 파일에 담긴 정보를 읽고, 수정하고, 저장할 수 있습니다.

사용하는 경우

  • ✓DICOM 파일에서 특정 정보를 추출해야 할 때.
  • ✓의료 영상의 메타데이터를 수정하고 싶을 때.
  • ✓DICOM 파일의 구조와 내용을 확인할 때.

스킬 링크

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pydicom/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pydicom/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“‘patient_exam.dcm’ DICOM 파일을 읽고 검사 종류와 영상 크기를 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

DICOM 파일을 읽고 파일 안의 데이터에 정리된 방식으로 접근하거나 변경할 수 있게 합니다. 어떤 정보를 읽거나 저장할지 지정할 수 있습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

pydicom

Use pydicom for DICOM dataset I/O and pixel processing. Version 3.0.2 is the current stable release reviewed here. It fixes CVE-2026-32711, a crafted DICOMDIR path-traversal issue. pydicom 3.0.2 declares Python >=3.10; its bundled DICOM dictionary is 2024c; the current DICOM Standard reviewed here is 2026d. No PACS, DIMSE, DICOMweb endpoint, or authenticated service is exercised by this local-file skill.

Mandatory safety boundary

  • Work only with local data that the user is authorized to access.
  • DICOM metadata, file names, private elements, overlays, structured content, and pixels may contain protected health information (PHI).
  • Never print Dataset, export full metadata/JSON, or log element values by default. Use a documented allowlist and aggregate output.
  • pydicom is a general DICOM framework, not a diagnostic viewer. Pixel output, validation, conversion, and plugin availability are not diagnostic claims.
  • De-identification is profile-, purpose-, recipient-, jurisdiction-, and threat-context-specific. It requires privacy/DICOM expert verification.
  • Never claim that a tag-removal script is DICOM PS3.15, HIPAA, GDPR, or other compliance. Preserve originals and audit derived outputs.
  • Treat deterministic pseudonymization keys and UID maps as re-identification secrets: use least privilege and encrypted/managed secret storage, never commit, sync, log, or share them with derivatives, and define backup, rotation, revocation, and destruction procedures. A leaked key invalidates the intended separation; rotation also changes deterministic mappings.
  • Set explicit input-file, file-count, frame-count, decoded-byte, and output limits before parsing untrusted or unusually large datasets.

Installation

Create or activate an isolated environment, then install the reviewed release (the pixel-stack pins below require Python 3.12+ because of NumPy):

uv pip install "pydicom==3.0.2"

Uncompressed pixel arrays and image rendering:

uv pip install "pydicom==3.0.2" "numpy==2.5.3" "Pillow==12.3.0"

Install only the transfer-syntax plugins required by the deployment:

# JPEG/JPEG-LS, JPEG 2000/HTJ2K, and faster RLE through pylibjpeg
uv pip install "numpy==2.5.3" "pylibjpeg==2.1.0" \
  "pylibjpeg-libjpeg==2.4.0" "pylibjpeg-openjpeg==2.6.0" \
  "pylibjpeg-rle==2.2.0"

# JPEG-LS encoder/decoder
uv pip install "numpy==2.5.3" "pyjpegls==1.5.1"

# Alternative decoder with platform-specific wheels
uv pip install "python-gdcm==3.2.6"

Plugin licenses and wheels differ by package/platform; review them before deployment. Pillow has documented decoding limitations and pydicom cautions that plugin output must be independently checked.

Native codec wheels widen the supply-chain and memory-safety boundary. For a controlled deployment, resolve these exact pins on a trusted build host, lock and verify wheel hashes/provenance, mirror approved artifacts internally, scan them, and install with hash enforcement rather than resolving from the public index at runtime.

Choose the workflow

  1. Need an aggregate overview: run scripts/extract_metadata.py.
  2. Need bounded technical checks: run scripts/dicom_inventory.py.
  3. Need codec deployment preflight: run scripts/transfer_syntax_inspector.py.
  4. Need frame/memory planning: run scripts/pixel_frame_planner.py.
  5. Need one non-diagnostic rendered frame: run scripts/dicom_to_image.py.
  6. Need a pseudonymized derivative: read the de-identification section, create a site-reviewed action profile, then run scripts/anonymize_dicom.py and scripts/deidentification_audit.py.
  7. Need to check a sensitive UID map: run scripts/uid_mapping_validator.py.

Read datasets safely

dcmread() returns a FileDataset, a Dataset subclass with File Format state such as file_meta, preamble, and original encoding.

from pathlib import Path
import pydicom

path = Path("authorized/input.dcm")
ds = pydicom.dcmread(
    path,
    stop_before_pixels=True,
    specific_tags=[
        "SOPClassUID",
        "Modality",
        "Rows",
        "Columns",
        "NumberOfFrames",
    ],
)

technical = {
    "sop_class": ds.get("SOPClassUID"),
    "modality": ds.get("Modality"),
    "rows": ds.get("Rows"),
    "columns": ds.get("Columns"),
}

Use:

  • stop_before_pixels=True for metadata-only work.
  • specific_tags=[...] for a minimum allowlist.

…

자주 묻는 질문

DICOM 파일이란 무엇인가요?

DICOM은 의료 영상과 관련 정보의 표준입니다. X선, CT, MRI 같은 장비에서 널리 사용됩니다.

pydicom으로 이미지를 볼 수 있나요?

pydicom은 의료 소프트웨어처럼 이미지를 표시하기보다는 파일의 데이터를 읽고 다루는 데 초점을 둡니다. 영상을 보기 위한 데이터를 준비하는 데 도움을 줄 수 있습니다.

환자 데이터를 pydicom으로 다루는 것은 안전한가요?

네, 하지만 주의가 필요합니다. pydicom은 민감한 정보(PHI)에 대해 경고하며, 기본적으로 모든 것을 표시하지 않고 필요할 때 익명화하는 등 사용자가 데이터를 보호하도록 요구합니다.

상세 정보

작성자의 원본 설명

Reads, inspects, writes, transforms, and preflights local DICOM datasets and pixel data. Applies to DICOM metadata, transfer syntaxes, compression plugins, frames, private elements, JSON, and bounded de-identification review.

repo: K-Dense-AI/scientific-agent-skills

인기도

GitHub 스타
51k
순위
#3539
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬