> Read, write, and manipulate medical imaging data (DICOM, NIfTI, NRRD) in MATLAB. Covers Image Processing Toolbox functions (dicomreadVolume, niftiread, dicomContours, dicomanon) and Medical Imaging Toolbox enhanced APIs (medicalVolume, medicalImage, medicalref3d, extractSlice, updateOrientation). Use when reading medical files, listing DICOM series, extracting spatial referencing, changing orientation, working with RT structures, or anonymizing DICOM data. Some features require Medical Imaging Toolbox — see skill body and references for details.
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-read-medical-data
Read, write, and manipulate medical imaging data in MATLAB. This skill covers both Image Processing Toolbox (IPT) functions and Medical Imaging Toolbox (MIT) enhanced APIs.
dicomCollectionmatlab-display-volume skill)matlab-display-image skill)imreadAlways check which toolboxes are available before choosing an approach. If Medical Imaging Toolbox is installed, prefer its APIs. If only Image Processing Toolbox is available, use IPT patterns.
| Task | IPT only | With Medical Imaging Toolbox (preferred) |
|------|----------|------------------------------------------|
| Read single DICOM file | dicomread + dicominfo | medicalImage |
| Read DICOM folder | dicomreadVolume | medicalVolume |
| Read NIfTI | niftiread + niftiinfo | medicalVolume |
| Read NRRD | — (requires MIT) | medicalVolume or nrrdread + nrrdinfo |
| List DICOM series | dicomCollection | dicomCollection |
| Spatial referencing | imref3d | medicalref3d |
| Extract oriented slice | Manual indexing | extractSlice |
| Change orientation | Manual permute | updateOrientation |
| Read DICOM RT structure | dicomContours(dicominfo(file)) | Same |
| Anonymize DICOM | dicomanon + dicomuid | Same |
| Visualize volume | volumeViewer | medicalVolumeViewer or volshow(medVol) |
Call medicalVolume or dicomreadVolume directly on the DICOM folder path. Do NOT call dicomCollection first — it is unnecessary when reading a single-series folder.
% WITH Medical Imaging Toolbox (preferred):
medVol = medicalVolume("path/to/dicom/folder");
V = medVol.Voxels; % Auto-rescaled (e.g., HU for CT)
spacing = medVol.VoxelSpacing; % [dx dy dz] in mm
orientation = medVol.Orientation; % "transverse", "coronal", "sagittal"
modality = medVol.Modality; % "CT", "MR"
% Access spatial referencing via VolumeGeometry (medicalref3d object)
geom = medVol.VolumeGeometry;
geom.VolumeSize; % [rows cols slices]
geom.PatientCoordinateSystem; % "LPS+" or "RAS+"
geom.Position; % [slices×3] slice positions in patient coords
geom.VoxelDistances; % {[slices×3] [slices×3] [slices×3]} per-axis distances
geom.PixelSpacing; % [slices×2] in-plane pixel spacing per slice
geom.IsAffine; % true if uniform spacing (affine transform)
geom.IsAxesAligned; % true if volume axes align with patient axes
geom.IsMixed; % true if slices have varying pixel spacing
% IPT only:
[V, spatial, dim] = dicomreadVolume("path/to/dicom/folder");
V = squeeze(V); % Remove singleton 4th dimension
% WITH Medical Imaging Toolbox (preferred):
medVol = medicalVolume("path/to/file.nii.gz");
% IPT only:
V = niftiread("path/to/file.nii.gz");
info = niftiinfo("path/to/file.nii.gz");
voxelSize = info.PixelDimensions(1:3);
Use dicomCollection only when:
medicalVolume or dicomreadVolume fails with an error (e.g., "not a DICOM file" or "multiple volumes detected")dicomCollection scans the directory, excludes non-DICOM files, and returns a table where each row is one series. It does not read pixel data.
collection = dicomCollection("path/to/directory");
disp(collection); % Table with Modality, SeriesDescription, Rows, Columns, Frames
% WITH Medical Imaging Toolbox:
medVol = medicalVolume(collection, "s1");
% IPT only:
[V, spatial] = dicomreadVolume(collection, "s1");
medVol = medicalVolume("path/to/file.nii");
% Extract slices — works for any orientation
[axialSlice, position, spacings] = extractSlice(medVol, 50, "transverse");
[coronalSlice, ~, ~] = extractSlice(medVol, 30, "coronal");
[sagittalSlice, ~, ~] = extractSlice(medVol, 45, "sagittal");
% If medVol.Orientation is not empty, use it as the third input
[sliceData, position, spacings] = extractSlice(medVol, 50, medVol.Orientation);
% Change orientation — do NOT use permute
medVolCoronal = updateOrientation(medVol, "coronal"); % Returns NEW object
updateOrientation was introduced in R2025a.
IMPORTANT: Before generating code for any task below, read the matching reference file first.
| Task trigger | Reference | Read BEFORE |
|--------------|-----------|-------------|
| Reading/writing DICOM or NIfTI with IPT | references/ipt-reading-writing.md | Writing dicomreadVolume, niftiread, imref3d, or rescale logic |
| Using medicalVolume, medicalImage, slices, or orientation | references/mit-medical-volume.md | Writing medicalImage, medicalVolume, extractSlice, or updateOrientation calls |
| Spatial referencing or coordinate transforms | references/mit-spatial-referencing.md | Writing medicalref3d, intrinsicToWorld, or worldToIntrinsic calls |
| RT structures (contours, labelmaps, RTSTRUCT) | references/dicom-rt-workflows.md | Reading, editing, displaying, or plotting contours/RTSTRUCT files, or writing any dicomContours, plotContour, createMask, addContour, deleteContour call |
| Anonymizing DICOM files | references/dicom-anonymization.md | Writing any dicomanon or dicomuid call |
| Do NOT use | Use instead | Why |
|------------|-------------|-----|
| dicomread + dicominfo for single file | medicalImage (MIT) | Unified access, auto-rescale |
| dicomreadVolume for DICOM folder | medicalVolume (MIT) | Preserves spatial referencing |
| niftiread + niftiinfo | medicalVolume (MIT) | Unified container |
| V.Voxels(:,:,n) or V(:,:,n) for slice extraction | extractSlice(medVol, n, medVol.Orientation) (MIT) | Handles orientation, spatial metadata, works regardless of storage order |
| Manual permute for orientation | updateOrientation(medVol, orient) (MIT) | Updates spatial metadata |
| Manual struct parsing for RT | dicomContours(info) | Clean tabular output |
| volumeViewer | medicalVolumeViewer (MIT, R2026a) | Medical-specific features |
| imshow for medical images | imageshow | Better defaults for medical data |
medicalVolume, medicalImage) when availabledeleteContour, updateOrientation)CreateMode="Copy" when writing RT Structure DICOM filesdicomCollection before medicalVolume/dicomreadVolume by default — call the reader directly on the folder pathdicomCollection only when: the folder contains multiple series, medicalVolume fails with an error, or you need to identify what series exist without reading pixel datasqueeze the output of dicomreadVolume for grayscale dataextractSlice to get slices from a medicalVolume — never use V.Voxels(:,:,n) manual indexing. extractSlice handles orientation, spatial metadata, and works correctly regardless of how the volume is stored on diskdicomContoursextractSlice argument order: (vol, sliceIndex, direction) — numeric before stringintrinsicToWorld returns 3 separate outputs: [x, y, z] — not a single vector----
Copyright 2026 The MathWorks, Inc.
----
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.
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.
Best practices for Remotion - Video creation in React
Generate AI-powered podcast-style audio narratives using Azure OpenAI's GPT Realtime Mini model via WebSocket. Use when building text-to-speech features, audio narrative generation, podcast creation from content, or integrating with Azure OpenAI Realtime API for real audio output. Covers full-stack implementation from React frontend to Python FastAPI backend with WebSocket streaming.
Best practices for Remotion - Video creation in React
Port an existing Remotion (React) composition''s source to HyperFrames HTML. Use ONLY on an explicit ask to port/convert/migrate/translate a Remotion source — one-way, Remotion-only. A passing Remotion mention, reference-only code, or "make something like my Remotion video" is a fresh build (/general-video). Unclear → /hyperframes.
Use this skill when building applications with Gemini API hosted models, including Gemini and Gemma 4, working with multimodal content (text, images, audio, video), implementing function calling, using structured outputs, or needing current model specifications. Covers SDK usage...
Turn error logs, screenshots, voice notes, and rough bug reports into crisp, developer-ready GitHub issues with repro steps, impact, and evidence.
Take matlab/matlab-read-medical-data from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.