Main Content

intrinsicToWorldMapping

Geometric transform between intrinsic and patient coordinates of medical image volume

Since R2022b

Description

example

tform = intrinsicToWorldMapping(R) computes the geometric transformation tform between the intrinsic and patient coordinate systems for the medical image volume defined by R. If the volume specified by R is non-affine, then this function computes the transformation for only the first slice along the third dimension.

Examples

collapse all

Get the geometric transformation between the intrinsic and patient coordinate systems for a chest CT volume saved as a directory of DICOM files. 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 a 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;

Calculate the transformation that maps between the intrinsic and patient coordinate systems by using the intrinsicToWorldMapping object function. The function returns an affinetform3d object, tform.

tform = intrinsicToWorldMapping(R)
tform = 
  affinetform3d with properties:

    Dimensionality: 3
                 A: [4×4 double]

The A property of the affinetform3d object contains a 4-by-4 geometric transformation matrix.

tform.A
ans = 4×4

         0    0.7285         0 -187.2285
    0.7285         0         0 -187.2285
         0         0    2.5000 -283.7500
         0         0         0    1.0000

Input Arguments

collapse all

Spatial referencing information, specified as a medicalref3d object.

Output Arguments

collapse all

Geometric transformation, returned as an affinetform3d object. If the volume specified by R is affine, then tform describes the transformation between the intrinsic and patient coordinate systems for the entire volume. If the volume is non-affine, then tform describes the transformation between the intrinsic and patient coordinate systems for the points in the first slice of the volume along the third dimension.

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.

The A property of tform contains a 4-by-4 3-D transformation matrix that maps triplets of voxel indices in the order (column, row, slice) to (x, y, z) triplets of patient coordinates in real-world units.

Version History

Introduced in R2022b