본문으로 건너뛰기
cccskills
무료GitHub에 공개

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(7)

  • SKILL.md8.8 KB
  • manifest.yaml523 B
  • references/dicom-anonymization.md3.3 KB
  • references/dicom-rt-workflows.md7.4 KB
  • references/ipt-reading-writing.md4.8 KB
  • references/mit-medical-volume.md7.9 KB
  • references/mit-spatial-referencing.md5.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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.

% 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

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

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)

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.


리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guide for accessing financial and economic data in MATLAB using the Datafeed Toolbox. Covers Bloomberg (market data via bloomberg/blp/bloombergHypermedia), FRED (Federal Reserve economic data via fredrs), Haver Analytics (economic data via haver/haverdirect/haverview), and LSEG Datastream (historical data via datastreamws). Use when connecting to any of these data providers from MATLAB.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

Read BEFORE writing any code that adds Additive White Gaussian Noise (AWGN) to signals and converts between SNR, Eb/No, Es/No, and per-subcarrier SNR for communications simulations, using awgn(), convertSNR(), berawgn(). The default MATLAB patterns for AWGN (e.g., 'measured' option, manual SNR formulas) produce subtly incorrect results. This skill specifies the correct calling conventions, required function usage, and critical anti-patterns that must be avoided.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

Analyze AMS waveform data using Mixed-Signal Blockset utilities: phase noise measurement, clock jitter, anti-aliased resampling, timing measurements, lock time, INL/DNL, ADC/DAC calibration, HSpice import. Use when analyzing time-domain voltage from PLL/VCO/clock simulations, measuring phase noise from variable-step solver output, computing jitter, or resampling non-uniform data.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

Design and analyze electrically large antenna structures using MATLAB Antenna Toolbox. Covers reflector antennas (parabolic, Cassegrain, Gregorian, offset, corner, cylindrical, spherical, custom STL), reflectarrays and reconfigurable intelligent surfaces (RIS), antennas installed on platforms (vehicles, aircraft, ships, satellites), and radar cross section (RCS) analysis. Includes solver selection (MoM-PO, PO, MoM, FMM), mesh control, and GPU acceleration. Use when the user wants to design a dish/reflector antenna, reflectarray, analyze an antenna on a platform, or compute RCS.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

Analyze data using MATLAB. Use when the task involves tables, timetables, time-series data, numeric arrays, sensor matrices, or gridded data — including but not limited to exploring, row filtering, sorting, cleaning, transforming, aggregating, smoothing, padding, trimming, and answering questions about data. MATLAB provides extensive, easy-to-use built-in functions for these workflows with no additional products required.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

S-parameters, insertion loss, fields, currents, mesh control, and solver selection for RF PCB performance validation. TRIGGER: user asks to compute S-parameters, analyze insertion/return loss, extract fields or currents, compare MoM vs FEM, or control mesh for any RF PCB component. Invoke BEFORE writing sparameters() or solver code — API is non-obvious. SKIP: designing or creating components (use the specific matlab-design-pcb-* skill), material/stackup setup only (use matlab-manage-pcb-material), optimization sweeps (use matlab-optimize-pcb-design), PDN/IR-drop analysis (use matlab-analyze-pcb-pdn).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

matlab의 스킬 모두 보기

이 스킬의 문제 신고