contains
Determine if affine image volume contains points specified in patient coordinate system
Since R2022b
Description
Examples
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);
The 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
Input Arguments
R
— Spatial referencing information
medicalref3d
object
Spatial referencing information, specified as a medicalref3d
object. 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.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
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 1
(true
) indicates that the
corresponding xyzWorld
point exists in the image volume, and a
value of 0
(false
) indicates that it does
not.
Version History
Introduced in R2022b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)