Main Content

addContour

Add ROI sequence to ROI data

Description

example

contourOut = addContour(contourIn,number,name,contourData,geometry) adds a user-defined region of interest (ROI) sequence to the ROIs property of the dicomContours object. Then, you can use the convertToInfo function to export the new ROI data to the structure set and ROI contour modules of the DICOM metadata.

example

contourOut = addContour(___,color) also specifies the color for the contour data added to the input dicomContours object.

Examples

collapse all

This example shows how to add a ROI sequence to the ROI data extracted from the structure set and ROI contour modules of the DICOM metadata.

Read DICOM metadata from DICOM-RT structure set files.

info = dicominfo('rtstruct.dcm');

Extract ROI data from the structure set and ROI contour modules of the DICOM metadata. The output is a dicomContours object that stores the extracted ROI data.

contourIn = dicomContours(info);

Display the ROIs property of the dicomContours object.

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

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

Load another ROI contour data to the workspace. The contour data contains the 3-D coordinates of the contours in the ROI.

load('contours')

To create a ROI sequence that contain the new ROI contour data, specify its attributes. The attributes are

  • ROI number

  • User-defined name for the ROI

  • Geometric type of the contours

  • Color of the ROI

Assign a unique ROI number for the ROI sequence. The ROI name can be any user-defined name. All points in the new ROI contour data is coplanar and the last point is connected to the first point. Hence, specify the geometric type as 'Closed_planar'.

number = 3;
name = 'Organ';
geometricType = 'Closed_planar';

Specify the color of the ROI. if you do not specify color, the default value for color in the ROIs property is set to [].

color = [0;127;127];

Add the new ROI sequence to the ROIs property of dicomContours object. The output is also a dicomContours object containing the new ROI sequence as well as the original ones.

contourOut = addContour(contourIn,number,name,contours,geometricType,color)
contourOut = 
  dicomContours with properties:

    ROIs: [3x5 table]

Display the details of the new dicomContours object by viewing its ROIs property. You can use the convertToInfo function to export the modified ROI data to DICOM metadata.

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

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

Input Arguments

collapse all

Input ROI data, specified as a dicomContours object.

ROI number, specified as a scalar integer. ROI number references the user-defined identification number for the ROI.

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

User-defined name for the ROI, specified as a character vector or string scalar.

Data Types: char | string

3-D coordinates of contours in the ROI, specified as a cell array of N-by-3 matrices. The column elements in each row are the (x, y, z) triplets defining a contour in the patient based coordinate system.

Data Types: cell

Geometric type of the contour, specified as one of these values:

  • 'Point'

  • 'Open_Planar'

  • 'Open_nonplanar'

  • 'Closed_planar'

Data Types: char | string

Display color for the ROI, specified as a three-element vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0, 255].

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

Output Arguments

collapse all

Output ROI data, returned as a dicomContours object. The ROIs property of the output object contains both the input ROI and the user-defined ROI sequence.

Introduced in R2020a