pydicom

Read, write, modify, and analyze DICOM medical imaging files with pydicom.

Updated Mar 10, 2026
One-click install
npx skills add https://github.com/Yezez9/Research-Agent --skill pydicom-yezez9
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pydicom
Source: https://github.com/Yezez9/Research-Agent/tree/main/scientific-skills/pydicom
Command: npx skills add https://github.com/Yezez9/Research-Agent --skill pydicom-yezez9

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pydicom, numpy, pillow, matplotlib, pylibjpeg, pylibjpeg-libjpeg, pylibjpeg-openjpeg, python-gdcm, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill simplifies the complex task of working with DICOM (Digital Imaging and Communications in Medicine) files, the standard for medical imaging, enabling seamless data manipulation and analysis.

Core Features & Use Cases

  • Read & Write DICOM: Load, modify, and save DICOM files and datasets.
  • Pixel Data Handling: Extract, process, and visualize image data from CT, MRI, X-ray, etc.
  • Metadata Management: Access, modify, and anonymize DICOM tags and headers.
  • Image Conversion: Convert DICOM images to standard formats like PNG or JPEG.
  • Use Case: A researcher needs to extract patient information and pixel data from a large set of MRI scans for a study, then anonymize the data before sharing. This Skill provides the tools to perform these operations efficiently.

Quick Start

Use the pydicom skill to read the DICOM file 'patient_scan.dcm' and print the patient's name.

Frequently Asked Questions about pydicom

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract pixel data from a DICOM file for image analysis?

To extract pixel data from a DICOM file, use the pydicom library to load the dataset and access the PixelData attribute. NumPy and Pillow are then used to process and visualize the image data from CT, MRI, or X-ray scans.

What is the best way to anonymize patient metadata in medical imaging files?

Anonymizing patient metadata in medical imaging files involves accessing and modifying specific DICOM tags and headers. The pydicom library allows you to load the dataset, overwrite identifying fields, and save the anonymized data for secure sharing.

Can I convert DICOM images to standard formats like PNG or JPEG?

Yes, you can convert DICOM images to standard formats like PNG or JPEG. By reading the DICOM file with pydicom and extracting the pixel data, you can use Pillow to process the array and save it as a standard image file for easier viewing.

Does pydicom support reading and writing compressed DICOM datasets?

Yes, pydicom supports reading and writing compressed DICOM datasets. It relies on installed dependencies like pylibjpeg, pylibjpeg-libjpeg, pylibjpeg-openjpeg, and python-gdcm to decode and handle various compressed pixel data transfer syntaxes.

How do I access and modify DICOM headers for research datasets?

To access and modify DICOM headers for research datasets, load the file using pydicom to retrieve the dataset object. You can then directly query specific tags by name or keyword, update their values programmatically, and save the modified dataset.

Why do I need numpy and pillow to handle DICOM pixel arrays?

You need NumPy and Pillow to handle DICOM pixel arrays because raw pixel data requires transformation into multidimensional arrays for manipulation. NumPy provides the array structure, while Pillow enables image rendering and conversion to formats like PNG.