matlab-read-medical-data

Read, write, and manipulate DICOM, NIfTI, and NRRD medical imaging data in MATLAB.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-read-medical-data
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-read-medical-data
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/image-processing-and-computer-vision/matlab-read-medical-data
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-read-medical-data

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Working with medical imaging data in MATLAB requires choosing between Image Processing Toolbox and Medical Imaging Toolbox APIs, handling spatial referencing, orientation, and DICOM-specific workflows like RT structures and anonymization. This Skill guides an AI agent to pick the correct functions and avoid common mistakes such as manual slice indexing or missing rescale corrections.

Core Features & Use Cases

  • Unified Medical Data Reading: Read DICOM folders, NIfTI, and NRRD files with medicalVolume and medicalImage, with automatic rescaling to calibrated units like Hounsfield Units.
  • Spatial Referencing & Orientation: Extract oriented slices with extractSlice, change orientation with updateOrientation, and convert between voxel and patient coordinates using medicalref3d.
  • DICOM RT & Anonymization Workflows: Read, modify, and write DICOM RT structure sets with dicomContours, and anonymize DICOM series with shared UIDs using dicomanon and dicomuid.
  • Use Case: A researcher needs to load a CT DICOM series, extract a coronal slice, overlay an RT structure contour mask, and write an anonymized copy. The Skill directs the agent to detect available toolboxes, use medicalVolume for reading, extractSlice for slicing, and dicomanon with shared UIDs for anonymization.

Quick Start

Ask the agent to read a DICOM folder or NIfTI file into MATLAB and extract a transverse slice at a given index using the appropriate medical imaging functions.

Frequently Asked Questions about matlab-read-medical-data

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

FAQPage Schema
How do I read a DICOM folder in MATLAB?

Use medicalVolume("path/to/dicom/folder") if Medical Imaging Toolbox is installed, which auto-rescales voxel values and preserves spatial referencing. With only Image Processing Toolbox, use dicomreadVolume and always squeeze the output to remove the singleton fourth dimension.

How do I read NIfTI files in MATLAB?

With Medical Imaging Toolbox, call medicalVolume on the .nii or .nii.gz file for a unified container with spatial metadata. With only Image Processing Toolbox, use niftiread for voxel data and niftiinfo for metadata such as PixelDimensions.

medicalVolume vs dicomreadVolume: which should I use?

Prefer medicalVolume when Medical Imaging Toolbox is available because it auto-applies rescale slope and intercept, preserves spatial referencing via medicalref3d, and supports extractSlice and updateOrientation. Use dicomreadVolume only when Medical Imaging Toolbox is not installed.

How do I anonymize a DICOM series in MATLAB?

Use dicomanon on each file, generating shared StudyInstanceUID and SeriesInstanceUID values once with dicomuid and passing them via the update option. Without shared UIDs, viewers treat each anonymized slice as a separate study.

Why does my DICOM data have wrong intensity values in MATLAB?

dicomread returns raw stored values without applying RescaleSlope and RescaleIntercept, so CT data is not in Hounsfield Units. Multiply by RescaleSlope and add RescaleIntercept manually, or use medicalVolume which applies rescaling automatically.

Can I extract a coronal slice from a medicalVolume in MATLAB?

Yes, use extractSlice(vol, sliceIndex, "coronal") with the numeric index before the direction string. Do not manually index vol.Voxels(:,:,n), since extractSlice handles orientation and spatial metadata regardless of storage order.