pydicom
Python library for working with DICOM (Digital Imaging and Communications in Medicine) files. Use this skill when reading, writing, or modifying medical imaging data in DICOM format, extracting pixel data from medical images (CT, MRI, X-ray, ultrasound), anonymizing DICOM files, working with DICOM metadata and tags, converting DICOM images to other formats, handling compressed DICOM data, or processing medical imaging datasets. Applies to tasks involving medical image analysis, PACS systems, radiology workflows, and healthcare imaging applications.
Author
Category
Image ProcessingInstall
Hot:9
Download and extract to your skills directory
Copy command and send to OpenClaw for auto-install:
Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-scientific-skills-pydicom&locale=en&source=copy
Pydicom - Python Medical Imaging DICOM File Handling Skill
Skill Overview
The Pydicom skill helps you read, write, and process DICOM medical imaging files using Python. It supports data extraction, conversion, and anonymization for various medical imaging formats such as CT, MRI, and X-ray.
Applicable Scenarios
1. Medical Imaging Data Research and Analysis
When you need to process CT, MRI, X-ray, ultrasound, PET, and other medical imaging data, this skill enables quick reading of DICOM files and extraction of pixel data for image analysis, 3D volume reconstruction, or medical AI model training. It supports batch processing of entire image series, automatically sorts slices by position, and constructs 3D datasets.
2. Medical Data De-identification and Sharing
Before conducting medical research or sharing data across institutions, use this skill to anonymize DICOM files by automatically removing or replacing protected health information (PHI) such as patient name, ID, and birth date, ensuring data compliance while preserving complete medical imaging data.
3. Radiology and PACS System Integration
When integrating with a hospital PACS system or handling radiology workflows, this skill supports reading and modifying DICOM metadata tags, handling images in various compressed formats, and converting medical images to common formats like PNG/JPG for report generation and remote viewing.
Core Features
DICOM File Reading and Metadata Extraction
Quickly read DICOM files with
pydicom.dcmread(), accessing all metadata tags such as patient information, study date, and imaging device parameters. Supports direct access to data elements via attribute names or tag numbers, automatically handles missing attributes, and provides a structured presentation of the full dataset.Pixel Data Processing and Image Conversion
Extract pixel arrays from medical images, supporting grayscale images (CT/MRI) and color images (RGB/YBR). Built-in VOI LUT window width and level adjustment ensures correct display of medical images. You can convert DICOM files to common image formats such as PNG, JPEG, and TIFF with one command for easy sharing and further processing.
DICOM Anonymization and Data Modification
Provides full DICOM data modification capabilities to safely remove or replace patient-sensitive information, edit study descriptions, and add custom tags. Supports creating entirely new DICOM files, generating standard-compliant UIDs, and handling compression and decompression operations while maintaining file integrity and compatibility.
Frequently Asked Questions
How does Pydicom read DICOM files?
Use
pydicom.dcmread('file_path.dcm') to read a DICOM file, which returns a Dataset object. Access metadata via attributes like ds.PatientName and ds.StudyDate, and get image pixel data with ds.pixel_array. Ensure pydicom and numpy (for handling pixel arrays) are installed before reading.How do I convert DICOM to common image formats?
After reading the DICOM file, get the
pixel_array, normalize its values to the 0–255 range and convert to uint8, then use PIL's Image.fromarray() to create an image object and save as PNG or JPG. The skill provides a dicom_to_image.py script for direct use: python scripts/dicom_to_image.py input.dcm output.png.How to anonymize DICOM to protect patient privacy?
Tags that need removal or replacement include PatientName, PatientID, PatientBirthDate, PatientAddress, ReferringPhysicianName, and other fields containing PHI. The skill includes an
anonymize_dicom.py script to automatically handle common sensitive tags; after anonymization, verify that no personally identifiable information remains in the file.