Main Content


Extract coordinates of corner voxels for one slice of medical volume

Since R2022b



xyzCorners = sliceCorners(medVol,slice,direction) extracts the xyz-coordinates of the four corner voxels for one slice, slice, in the specified direction direction of the medicalVolume object medVol. The function returns the corner coordinates in the patient coordinate system.


collapse all

Extract corner coordinates for a slice of a medical volume created using a chest CT volume saved as a directory of DICOM files. The CT volume is part of a data set containing three CT volumes. The size of the entire data set is approximately 81 MB. Download the data set from the MathWorks® website, then unzip the folder.

zipFile = matlab.internal.examples.downloadSupportFile("medical","");
filepath = fileparts(zipFile);

The dataFolder folder contains the downloaded CT volume.

dataFolder = fullfile(filepath,"MedicalVolumeDICOMData","LungCT01"); 

Create a medical volume object for the CT volume.

medVol = medicalVolume(dataFolder);

Extract the xyz-coordinates, in millimeters, of the corner voxels for the second slice in the coronal direction.

xyzCorners = sliceCorners(medVol,2,"coronal")
xyzCorners = 4×3

 -186.5000 -185.7715 -281.2500
 -186.5000 -185.7715  -63.7500
  185.7717 -185.7715  -63.7500
  185.7717 -185.7715 -281.2500

Input Arguments

collapse all

Medical volume, specified as a medicalVolume object.

Slice index, specified as a positive integer scalar in the range [1, numSlices], where numSlices is the number of slices in the volume along the direction specified by direction.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Direction along which to extract the slice limits, specified as "coronal", "sagittal", or "transverse".

Data Types: char | string

Output Arguments

collapse all

Coordinates of the four corner voxels in the patient coordinate system, returned as a 4-by-3 numeric matrix. Each row contains the xyz-coordinates for one corner, returned in clockwise order from the upper-left corner.

Version History

Introduced in R2022b