Main Content

sliceViewer

Browse slices of medical image volume in patient coordinates

Since R2023a

Description

Medical Imaging Toolbox™ extends the functionality of the sliceViewer (Image Processing Toolbox™) object to display the slices of a medicalVolume object in the patient coordinate system. The function uses the medicalVolume properties to orient slices, set the intensity display range, and scale anisotropic voxels. If you do not have Medical Imaging Toolbox installed, see sliceViewer (Image Processing Toolbox).

When it opens a figure, the sliceViewer object displays the middle image in the stack. The viewer displays slices along the primary direction of the volume, specified by the Orientation property of the medicalVolume object. Use the slider to navigate through the volume and view individual slices.

The Slice Viewer window displaying the middle slice of a CT scan with a slider to navigate slices

The sliceViewer object supports properties, object functions, and events that you can use to customize its appearance and behavior. The sliceViewer object can send notifications when certain events occur, such as the slider moving. For more information, see Events.

Note

By default, clicking and dragging the mouse in any slice view changes the brightness and contrast, a technique called window/level. Drag the mouse left and right to change the contrast. Drag the mouse up and down to change the brightness. Hold Ctrl while you click and drag to accelerate changes. Hold Shift while you click and drag to slow the rate of change. To control this behavior, use the DisplayRangeInteraction property.

Creation

Description

Medical Volume Object

sliceViewer(medVol) displays the slices of the medicalVolume object medVol in a scrollable figure window. The sliceViewer object uses the medicalVolume properties to orient slices, set the intensity display range, and scale anisotropic voxels. See the medVol argument description for details.

example

sliceViewer(medVol,AnatomicalConvention=convention) orients the medical volume according to the display convention convention.

Numeric Array

sliceViewer(V) displays the grayscale or RGB volume V, where V is a numeric array. Use this syntax to display image file formats not supported by medicalVolume.

example

Additional Options

sliceViewer(___,Name=Value) sets Properties using one or more name-value arguments, in addition to any combination of input arguments from previous syntaxes. For example, sliceViewer(medVol,Colormap=cmap) specifies the colormap used to display the volume.

sv = sliceViewer(___) returns a handle to the sliceViewer object, sv. Use sv to access and modify properties that control the visualization of the slice images.

Input Arguments

expand all

Medical volume, specified as a medicalVolume object. The sliceViewer object displays the slices using the properties of medVol:

  • The sliceViewer uses the WindowCenters and WindowWidths properties, if specified, to set the DisplayRange property.

  • The sliceViewer uses the VoxelSpacing property to resize the display axes to accurately display anisotropic voxels.

  • The sliceViewer displays slices in the plane specified by the Orientation property of medVol:

    • If the Orientation property value is "transverse", the viewer displays transverse slices with the anterior side of the patient on the top of the image and the right side of the patient on the left side of the image. To display the right side of the patient on the right side of the image, specify the convention argument as "neurological".

    • If the Orientation property value is "coronal", the viewer displays coronal slices with the superior end of the patient on the top of the image and the right side of the patient on the left side of the image. To display the right side of the patient on the right side of the image, specify the convention argument as "neurological".

    • If the Orientation property value is "sagittal", the viewer displays sagittal slices with the superior end of the patient on the top of the image and the anterior side of the patient on the left side of the image.

If the patient coordinate system is undefined, then sliceViewer displays the data in the Voxels property of medVol as a numeric array with default display settings. The patient coordinate system is undefined if the PatientCoordinateSystem property of the medicalref3d object in the VolumeGeometry property of medVol is "unknown".

Anatomical display orientation convention, specified as one of these values:

  • "radiological" — Display the left side of the patient on the right side of transverse and coronal slice images.

  • "neurological" — Display the left side of the patient on the left side of transverse and coronal slice images.

The convention argument has no effect when displaying sagittal slices.

Data Types: char | string

Input volume, specified as an m-by-n-by-p-by-c numeric array. For grayscale volumes, c is 1. For RGB volumes, c is 3. RGB volumes must be of data type uint8, uint16, single, or double.

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

Properties

expand all

Colormap, specified as an m-by-3 numeric array with values in the range [0 1]. The Colormap property has no effect when medVol contains an RGB image volume.

Intensity display range, specified as a two-element vector of the form [low high]. Intensity values less than or equal to low appear black, or as the first color in the colormap. Intensity values greater than or equal to high appear white, or as the last color in the colormap. If you specify an empty matrix ([]), then sliceViewer uses the minimum and maximum values in the image. The default display range depends on the input image:

  • If you specify a medicalVolume with the WindowCenters and WindowWidths properties specified, then sliceViewer uses the property values to set the display range. If WindowCenters and WindowWidths are empty, then sliceViewer uses the minimum and maximum values in the image.

  • If you specify a numeric array, V, as input, sliceViewer uses the minimum and maximum values in the image.

DisplayRange has no effect when displaying RGB image data.

Enable interactive control of display range, specified as one of these values. To learn more about interactive behavior, see Events.

ValueDescription
"on" (default for grayscale intensity volumes)Control the display range of an image stack by left-clicking the mouse and dragging it on the axes.
"off" (default for logical and RGB volumes)No display range interactivity.

Parent of the sliceViewer object, specified as a handle to a uipanel or a figure created with the figure or uifigure commands. If you do not specify a parent, the parent of the sliceViewer object is gcf.

Scale factors used to rescale the volume, specified as a 3-element positive numeric row vector. The values in the vector specify the scale factor applied in the x-, y-, and z-directions, respectively.

Note

If you specify a medicalVolume with anisotropic voxels as input, the slice viewer scales the display axes to accurately display voxel sizes. In this case, sliceViewer does not update the ScaleFactors value.

Direction in which to browse the image stack, specified as one of the logical vectors or strings in the table. If you specify a medicalVolume object as input, sliceViewer does not support setting the SliceDirection property. The Orientation property of medVol determines the slice direction.

For numeric array inputs, the values correspond to the dimensions of the input array V, not the patient coordinate system axes.

StringLogical VectorDescription
"X" [1 0 0]Browse in the first direction
"Y"[0 1 0]Browse in the second direction
"Z" (default)[0 0 1]Browse in the third direction

Index of the slice to display when sliceViewer opens the figure, specified as a positive numeric scalar.

Object Functions

addlistenerCreate event listener bound to event source
getAxesHandleGet handle to axes in slice viewer

Examples

collapse all

Run this code to download a data set from the MathWorks® website and unzip the downloaded folder. The data set contains three CT volumes that are each saved as a directory of DICOM files. The size of the entire data set is approximately 81 MB.

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

The folder dataFolder contains the downloaded scan used by this example, LungCT01.

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

Create a medical image volume object that contains the image data and spatial referencing information for the CT volume. The Orientation property indicates that the primary slice direction is "transverse".

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]

View the transverse slices of the volume in the slice viewer. By default, the viewer uses the properties of medVol to scale anisotropic voxels, set the intensity display range, and orient slices. The viewer opens on the center slice. Use the scroll bar to navigate to other slices.

sv = sliceViewer(medVol,Parent=figure)
sv = 
  sliceViewer with properties:

             SliceDirection: [0 0 1]
                SliceNumber: 45
                     Parent: [1×1 Panel]
                   Colormap: [256×3 double]
               DisplayRange: [-160 240]
               ScaleFactors: [1 1 1]
    DisplayRangeInteraction: 'on'

If you are working with 3-D medical image data stored as a DICOM, NIfTI, or NRRD file, create a medicalVolume object before displaying the volume. Passing a medicalVolume object as input allows sliceViewer to use the medicalVolume properties to automatically adjust display settings. If your medical image volume data is stored in a format that is not supported by medicalVolume, you can pass a numeric array as input to the sliceViewer object. The viewer displays the rows, columns, and slices of the data without any knowledge of a patient coordinate system.

Load a MAT file that contains an MRI image volume. The file loads the 3-D numeric array mristack into the workspace.

load mristack.mat

Display the slices of the MRI volume. By default, sliceViewer displays slices along the third direction of the numeric array.

sliceViewer(mristack,Parent=figure)
ans = 
  sliceViewer with properties:

             SliceDirection: [0 0 1]
                SliceNumber: 11
                     Parent: [1×1 Panel]
                   Colormap: [256×3 double]
               DisplayRange: [0 255]
               ScaleFactors: [1 1 1]
    DisplayRangeInteraction: 'on'

More About

expand all

Version History

Introduced in R2023a