Matlab Read Medical Data logo

Matlab Read Medical Data

OrganizationPopular
matlab
matlab-read-medical-data

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.

Overview

Publishermatlab
Repositorymatlab-agentic-toolkit
Skill namematlab-read-medical-data
Stars
1.2K
Forks
138
Bundled files
6
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 6 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by matlab on GitHub. Read the source before you install it.

Installation

Install the Matlab Read Medical Data AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/image-processing-and-computer-vision/matlab-read-medical-data
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/matlab/matlab-agentic-toolkit.git /tmp/matlab-agentic-toolkit
mkdir -p .claude/skills
cp -r /tmp/matlab-agentic-toolkit/skills-catalog/image-processing-and-computer-vision/matlab-read-medical-data .claude/skills/matlab-read-medical-data
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Matlab Read Medical Data in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Matlab Read Medical Data on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Matlab Read Medical Data is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Read and Write 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.

When to Use

  • Reading or writing DICOM, NIfTI, or NRRD files
  • Listing DICOM series with dicomCollection
  • Extracting spatial referencing or coordinate transforms
  • Changing volume orientation or extracting oriented slices
  • Working with DICOM RT structures (contours, masks, modify/write)
  • Anonymizing DICOM data

When NOT to Use

  • Displaying or visualizing volumes (use matlab-display-volume skill)
  • Displaying 2-D medical images with annotations (use matlab-display-image skill)
  • Reading non-medical image formats (PNG, TIFF, JPEG) — use imread

Toolbox Detection — CRITICAL FIRST STEP

Always 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 → Function Quick Reference

TaskIPT onlyWith Medical Imaging Toolbox (preferred)
Read single DICOM filedicomread + dicominfomedicalImage
Read DICOM folderdicomreadVolumemedicalVolume
Read NIfTIniftiread + niftiinfomedicalVolume
Read NRRD— (requires MIT)medicalVolume or nrrdread + nrrdinfo
List DICOM seriesdicomCollectiondicomCollection
Spatial referencingimref3dmedicalref3d
Extract oriented sliceManual indexingextractSlice
Change orientationManual permuteupdateOrientation
Read DICOM RT structuredicomContours(dicominfo(file))Same
Anonymize DICOMdicomanon + dicomuidSame
Visualize volumevolumeViewermedicalVolumeViewer or volshow(medVol)

Top 4 Patterns

1. Read DICOM folder

Call medicalVolume or dicomreadVolume directly on the DICOM folder path. Do NOT call dicomCollection first — it is unnecessary when reading a single-series folder.

matlab
% 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

2. Read NIfTI file

matlab
% 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);

3. List DICOM series and read one

Use dicomCollection only when:

  • The user says the folder contains multiple series or volumes
  • medicalVolume or dicomreadVolume fails with an error (e.g., "not a DICOM file" or "multiple volumes detected")
  • You need to identify what series exist before deciding which one to read

dicomCollection scans the directory, excludes non-DICOM files, and returns a table where each row is one series. It does not read pixel data.

matlab
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");

4. Extract slice / change orientation (Requires Medical Imaging Toolbox)

matlab
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.

Detailed Reference Files

IMPORTANT: Before generating code for any task below, read the matching reference file first.

Task triggerReferenceRead BEFORE
Reading/writing DICOM or NIfTI with IPTreferences/ipt-reading-writing.mdWriting dicomreadVolume, niftiread, imref3d, or rescale logic
Using medicalVolume, medicalImage, slices, or orientationreferences/mit-medical-volume.mdWriting medicalImage, medicalVolume, extractSlice, or updateOrientation calls
Spatial referencing or coordinate transformsreferences/mit-spatial-referencing.mdWriting medicalref3d, intrinsicToWorld, or worldToIntrinsic calls
RT structures (contours, labelmaps, RTSTRUCT)references/dicom-rt-workflows.mdReading, editing, displaying, or plotting contours/RTSTRUCT files, or writing any dicomContours, plotContour, createMask, addContour, deleteContour call
Anonymizing DICOM filesreferences/dicom-anonymization.mdWriting any dicomanon or dicomuid call

Legacy Patterns to Avoid

Do NOT useUse insteadWhy
dicomread + dicominfo for single filemedicalImage (MIT)Unified access, auto-rescale
dicomreadVolume for DICOM foldermedicalVolume (MIT)Preserves spatial referencing
niftiread + niftiinfomedicalVolume (MIT)Unified container
V.Voxels(:,:,n) or V(:,:,n) for slice extractionextractSlice(medVol, n, medVol.Orientation) (MIT)Handles orientation, spatial metadata, works regardless of storage order
Manual permute for orientationupdateOrientation(medVol, orient) (MIT)Updates spatial metadata
Manual struct parsing for RTdicomContours(info)Clean tabular output
volumeViewermedicalVolumeViewer (MIT, R2026a)Medical-specific features
imshow for medical imagesimageshowBetter defaults for medical data

Conventions

  • Always detect available toolboxes before choosing functions
  • Prefer Medical Imaging Toolbox APIs (medicalVolume, medicalImage) when available
  • Always capture output from immutable methods (deleteContour, updateOrientation)
  • Always use CreateMode="Copy" when writing RT Structure DICOM files
  • Do NOT call dicomCollection before medicalVolume/dicomreadVolume by default — call the reader directly on the folder path
  • Use dicomCollection only when: the folder contains multiple series, medicalVolume fails with an error, or you need to identify what series exist without reading pixel data
  • Always squeeze the output of dicomreadVolume for grayscale data
  • Always use extractSlice 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 disk
  • Never manually parse nested DICOM structs — use dicomContours
  • extractSlice argument order: (vol, sliceIndex, direction) — numeric before string
  • intrinsicToWorld returns 3 separate outputs: [x, y, z] — not a single vector

Copyright 2026 The MathWorks, Inc.


Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Matlab Read Medical Data AI skill do?

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.

Why use Matlab Read Medical Data on TypingMind?

Because you install it once and use it with any model. Matlab Read Medical Data is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Matlab Read Medical Data in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/image-processing-and-computer-vision/matlab-read-medical-data. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Matlab Read Medical Data?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Matlab Read Medical Data?

As many as you like. As long as a model supports skills, you can use Matlab Read Medical Data with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Matlab Read Medical Data AI skill free?

It is published on GitHub by matlab. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇