createMask

Create volumetric mask from dicomContours object

Description

example

BW = createMask(rtContours,ROIindex,Spatial) returns the 3-D logical mask BW, a voxel representation of the ROI specified by ROIindex, in the dicomContours object, rtContours. ROIindex specifies the contour in rtContours to be densified. Spatial specifies location, resolution, and orientation of the 3-D data.

Examples

collapse all

Use dicomInfo and imref3d to create a mask of a dicomContours object.

Read the metadata of a DICOM-RT Structure Set.

info = dicominfo('rtstruct.dcm');

Construct a dicomContours object.

rtContours = dicomContours(info);  

Display all the ROI information as a table.

rtContours.ROIs
ans=2×5 table
    Number          Name           ContourData    GeometricType       Color    
    ______    _________________    ___________    _____________    ____________

      1       {'Body_Contour' }    {90×1 cell}     {90×1 cell}     {3×1 double}
      2       {'Tumor_Contour'}    {21×1 cell}     {21×1 cell}     {3×1 double}

Plot the contours of all ROIs using plotContours. This object function plots the contours in world coordinates. Use this plot to define world coordinate limit boundaries for an imref3d object to create a dense mask within.

plotContour(rtContours)

Create an imref3d object with same world limits as the plot from plotContours so that the image is in the same space as the contours.

referenceInfo = imref3d([128,128,50],xlim,ylim,zlim);

Create a 3-D logical mask of the first contour ('Body_Contour') in the rtContours. Specify the imref3d object

contourIndex = 1;  
rtMask = createMask(rtContours, contourIndex, referenceInfo);

View this mask using the Volume Viewer

volshow(rtMask);

Input Arguments

collapse all

DICOM contours, specified as a dicomContours object.

Data Types: dicomContours

ROI in DICOM contours object, specified by number or by name in the ROIs table in the dicomContours object.

ROI IdentifierTypeExample
NumberNumeric integer identifying a row of the ROIs table in the rtContours object. Number is the first column in the ROIs table.rtMask = createMask(rtContours,1, spatialInfo)
Name Name identifying an ROI in the ROIs table in the rtContours object, specified as a char array or string scalar. Name is the second column in the ROIs table.rtMask = createMask(rtContours,'Body_Contour',spatialInfo)

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string

Spatial referencing information, specified as a Spatial struct returned by dicomreadVolume or an imref3d object. Spatial referencing information provides the location, resolution, and orientation of the 3-D coordinate data.

Data Types: struct | imref3d

Output Arguments

collapse all

Logical mask, returned as a 3-D logical array.

Introduced in R2020b