Main Content

Display 3-D Medical Image Data in Patient Coordinate System

This example shows how to display volumetric CT data in the patient coordinate system using the volshow function. You can use the spatial referencing information from a medicalVolume object to transform intrinsic image coordinates, in voxel units, to patient coordinates in real-world units such as millimeters. This is particularly useful for visualizing anisotropic image voxels, which have unequal spatial dimensions. Viewing images in the patient coordinate system accurately represents the aspect ratio of anisotropic voxels, which avoids distortions in the image.

Download Image Volume Data

This example uses 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)
dataFolder = fullfile(filepath,"MedicalVolumeDICOMData","LungCT01");

Import Image Volume

Create a medical image volume object that contains the image data and spatial referencing information for the CT volume. The Voxels property contains a numeric array of the voxel intensities. The VoxelSpacing property indicates that the voxels are anisotropic, with a size of 0.7285-by-0.7285-by-2.5 mm.

medVol = medicalVolume(dataFolder)
medVol = 
  medicalVolume with properties:

                 Voxels: [512×512×88 int16]
         VolumeGeometry: [1×1 medicalref3d]
           SpatialUnits: "mm"
            Orientation: "transverse"
           VoxelSpacing: [0.7285 0.7285 2.5000]
           NormalVector: [0 0 1]
       NumCoronalSlices: 512
      NumSagittalSlices: 512
    NumTransverseSlices: 88
           PlaneMapping: ["sagittal"    "coronal"    "transverse"]
               Modality: "CT"
          WindowCenters: [88×1 double]
           WindowWidths: [88×1 double]

Display Image Volume Without Spatial Referencing

Extract the voxel data from the medicalVolume object.

V = medVol.Voxels;

Visualize the image volume by using the volshow function. The image volume appears squished in the transverse direction. The x-, y- and z-axis display markers are aligned with the first, second, and third dimensions of the image array, not the xyz-axes of the patient coordinate system.

volIntrinsic = volshow(V,RenderingStyle="MaximumIntensityProjection");

By default, volshow plots the volume in the intrinsic coordinate system, which assumes cubic voxels with uniform spatial dimensions. Therefore, if your image data is isotropic, then you can display the image in intrinsic coordinates without distortions.

The Transformation property of the object created by volshow controls whether a transformation is applied to the intrinsic coordinates. By default, the transformation value is a 4-by-4 identity matrix.

volIntrinsic.Transformation
ans = 
  affinetform3d with properties:

    Dimensionality: 3
                 A: [4×4 double]

volIntrinsic.Transformation.A
ans = 4×4

     1     0     0     0
     0     1     0     0
     0     0     1     0
     0     0     0     1

You can display the volume in patient coordinates by specifying the Transformation property as an affinetform3d object that maps between the intrinsic and patient coordinate systems.

Define Spatial Referencing

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

R = medVol.VolumeGeometry
R = 
  medicalref3d with properties:

                 VolumeSize: [512 512 88]
                   Position: [88×3 double]
             VoxelDistances: {[88×3 double]  [88×3 double]  [88×3 double]}
    PatientCoordinateSystem: "LPS+"
               PixelSpacing: [88×2 double]
                   IsAffine: 1
              IsAxesAligned: 1
                    IsMixed: 0

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]

Display Image Volume with Spatial Referencing

Visualize the image volume by using the volshow function, specifying the Transformation property as tform to include the spatial referencing information. The image volume no longer appears squished in the transverse direction. The transformed volume is also rotated so that the x-, y-, and z-axis display markers are aligned with the patient coordinate axes and point in the directions specified by the PatientCoordinateSystem property of R.

volPatient = volshow(V,Transformation=tform,RenderingStyle="MaximumIntensityProjection");

See Also

| | |

Related Topics