Determine if affine image volume contains points specified in patient coordinate system
Determine If Medical Image Volume Contains Patient Coordinates
Determine if a chest CT volume, saved as a directory of DICOM files, contains a set of coordinates specified in the patient coordinate system. The 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","MedicalVolumeDICOMData.zip"); filepath = fileparts(zipFile); unzip(zipFile,filepath);
Specify the directory of the DICOM files for the first CT volume in the data set.
dataFolder = fullfile(filepath,"MedicalVolumeDICOMData","LungCT01");
Create a medical volume object that contains the image and spatial metadata for the CT volume.
medVol = medicalVolume(dataFolder);
VolumeGeometry property of the medical volume object contains a
medicalref3d object that specifies the spatial referencing for the volume. Extract the
medicalref3d object for the chest CT.
R = medVol.VolumeGeometry;
Specify the patient coordinates, in millimeters, of three sample points.
xyzWorld = [-100 -100 -200; 0 0 -100; 300 200 -80]
xyzWorld = 3×3 -100 -100 -200 0 0 -100 300 200 -80
Check whether the sample points are inside the image boundary. The values of
tf indicate that the third point lies outside the image.
tf = contains(R,xyzWorld)
tf = 3×1 logical array 1 1 0
R — Spatial referencing information
Spatial referencing information, specified as a
R must specify an affine image volume. An image volume is
affine if these conditions are met:
All slices are parallel to each other.
The spacing between slices in each dimension is uniform.
The upper-left voxels of all slices are collinear.
No two slices are coincident, meaning no two slices are located at the same position in space.
xyzWorld — Patient coordinates of points to query
n-by-3 numeric matrix
Patient coordinates of points to query, specified as an n-by-3 numeric matrix, where n is the number of points. The patient coordinates are in real-world units defined by the patient coordinate system.
tf — Image volume contains specified points
n-element logical vector
Image volume contains the specified points, returned as an
n-element logical vector, where n is the number of
points. A value of
true) indicates that the
xyzWorld point exists in the image volume, and a
false) indicates that it does
Introduced in R2022b