Main Content

convertToInfo

Write ROI data to DICOM metadata

Description

example

info = convertToInfo(contour) creates metadata for a DICOM-RT structure set file by using the region of interest (ROI) data in the dicomContours object. The function parses the ROIs property of the dicomContours object. Then, it writes to the structure set and ROI contour modules of the existing DICOM metadata appropriately.

Examples

collapse all

This example shows how to add a ROI contour sequence to an existing ROI data and export the new ROI data to DICOM-RT structure set format.

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

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';

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);
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}     {0x0 double}

Export the modified ROI data to DICOM metadata.

info = convertToInfo(contourOut);

Write the metadata to a DICOM-RT structure set file by using the dicomwrite function. If the DICOM image associated with the ROI contour data is not available, set the first input argument value in dicomwrite function to empty. Set the 'CreateMode' parameter to 'copy' in order to copy the metadata to a new DICOM-RT structure set file rtfile.dcm.

dicomwrite([],'rtfile.dcm',info,'CreateMode','copy');

Input Arguments

collapse all

ROI data, specified as a dicomContours object.

Output Arguments

collapse all

DICOM metadata, returned as a structure array.

Introduced in R2020a