Main Content

convertToInfo

Write ROI data to DICOM metadata

Since R2020a

Description

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

example

Examples

collapse all

Add an ROI contour sequence to existing ROI data, and then export the new ROI data to the DICOM-RT structure set format.

Read the DICOM metadata from a DICOM-RT structure set file.

info = dicominfo("RTSTRUCT-VS-SEG-001.dcm");

Extract the 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=4×5 table
    Number       Name        ContourData    GeometricType       Color    
    ______    ___________    ___________    _____________    ____________

      1       {'TV'     }    {13x1 cell}     {13x1 cell}     {3x1 double}
      2       {'Cochlea'}    { 5x1 cell}     { 5x1 cell}     {3x1 double}
      3       {'Vol2016'}    {12x1 cell}     {12x1 cell}     {3x1 double}
      4       {'*Skull' }    {79x1 cell}     {79x1 cell}     {3x1 double}

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

load("contours")

To create an ROI sequence that contain the new ROI contour data, specify these attributes of the ROI sequence:

  • 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. Because all points in the new ROI contour data are coplanar, and the last point is connected to the first point, specify the geometric type as "Closed_planar".

number = 5;
name = "Organ";
geometricType = "Closed_planar";

Add the new ROI sequence to the ROIs property of the 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=5×5 table
    Number       Name        ContourData    GeometricType       Color    
    ______    ___________    ___________    _____________    ____________

      1       {'TV'     }    {13x1 cell}     {13x1 cell}     {3x1 double}
      2       {'Cochlea'}    { 5x1 cell}     { 5x1 cell}     {3x1 double}
      3       {'Vol2016'}    {12x1 cell}     {12x1 cell}     {3x1 double}
      4       {'*Skull' }    {79x1 cell}     {79x1 cell}     {3x1 double}
      5       {'Organ'  }    {21x1 cell}     {21x1 cell}     {0x0 double}

Export the modified ROI data as 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, specify the first input argument value in the dicomwrite function as an empty array. Set the CreateMode parameter to "copy" to copy the metadata to a new DICOM-RT structure set file, rtfile.dcm. Setting the create mode to "copy" copies the metadata directly without verifying the metadata attributes.

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.

Tips

  • A dicomContours object stores the metadata of the file used in its creation as a hidden property. Therefore, the metadata attributes of the output structure info match the original DICOM file, with updated ROI data specified by contour.

Extended Capabilities

Version History

Introduced in R2020a

expand all