How to visualize the RT Structure object?

Questions regarding the DCMRT library, a DCMTK add-on that implements support for the various DICOM Radiation Therapy (RT) IODs

Moderator: Moderator Team

Post Reply
Message
Author
candy
Posts: 24
Joined: Mon, 2008-10-20, 08:37

How to visualize the RT Structure object?

#1 Post by candy »

Hi J

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

No, unfortunately, not -- at least not at the moment. This is something that could possibly be handled by a higher level API which is still to be defined/developed ...

Oliver Nix
Posts: 18
Joined: Tue, 2009-09-22, 12:57
Location: DKFZ Heidelberg

#3 Post by Oliver Nix »

I can provide a piece of code that reads structures and returns the point coordinates as multidimensional stl::vector, if this would be helpful.

candy
Posts: 24
Joined: Mon, 2008-10-20, 08:37

#4 Post by candy »

Oliver Nix wrote:I can provide a piece of code that reads structures and returns the point coordinates as multidimensional stl::vector, if this would be helpful.
That will be very grateful to you!Please mail the piece of code to christcandy@yahoo.cn.
Best Regards,
Candy

bobsta
Posts: 1
Joined: Fri, 2010-11-05, 10:30

Extracting Structures and points from DICOM RT Structure Set as stl::vector

#5 Post by bobsta »

Hi,

I would like to extract the structures PTV(s) and OAR(s) including points e.g. isocentre, Dose normalisation point etc from a DICOM RT Structure set as stl::vectors. The code from Oliver Nix appears to do this. Could someone please post the code to me: markbgainey@yahoo.com


Thanks

Oliver Nix
Posts: 18
Joined: Tue, 2009-09-22, 12:57
Location: DKFZ Heidelberg

#6 Post by Oliver Nix »

How to extract structures by name

Structures by name can be extracted using this code.
This code searches for a ROI with the name VOIname.
The ROI name is stored in tag (3006,0026). This is of type 2. It must exist but it can remain empty. This code reads all ROI names in the ROI sequence (3006,0020) and compares them with the string VOIname. In case of a hit the ROI Number is extracted (3006,0022) from this sequence item. This tag is of type 1, so it must exist. Then the function getContourData(VOIid,VOIdata) is called which extracts the coordinate triplets of your ROI and stores them in FloatVector3D &VOIdata.
FloatVector3D is a typedef for
typedef OFVector<OFVector<OFVector<Float32> > > FloatVector3D;
and OFVector is a std::vector object.

Code: Select all

OFBool DRTStructureSet::getContourData(OFString VOIname, FloatVector3D &VOIdata)
{
 OFBool success = OFTrue;
 Uint32 VOIid=-1,ctr;
 DRTStructureSetROISequence &strset_sequence =  getStructureSetROISequence();
 if(!strset_sequence.isEmpty())
  { 
  if (strset_sequence.gotoFirstItem().good())
   {
    ctr = 0;
    do
     {
       DRTStructureSetROISequence::Item seq_item = strset_sequence.getCurrentItem();
       OFString name;
       seq_item.getROIName(name);
       if(name.compare(VOIname) == 0) 
        {
         OFString voi_number;
         if((seq_item.getROINumber(voi_number)).good())
          {
           VOIid = atoi(voi_number.c_str());
           break;
          }
        }  
      } while(strset_sequence.gotoNextItem().good());
    }
    else
    {
     DCMRT_ERROR("DRTStructure Set :: getContourData :: structure set sequence first item status bad");
     success = OFFalse;
    }
 } 
 else
 {
  DCMRT_ERROR("DRTStructure Set :: getContourData :: structure set sequence is empty");
  success = OFFalse;
 }

 if(VOIid > 0)
   if(!(getContourData(VOIid,VOIdata)))
    {
     DCMRT_ERROR("DRTStructure Set :: getContourData returned success false");
     success = OFFalse;
    }

return success;
}

Code: Select all

OFBool DRTStructureSet::getContourData(Uint32 VOIid, FloatVector3D &VOIdata)
{

DRTROIContourSequence &voi_sequence =  getROIContourSequence();
DRTROIContourSequence::Item &voi = voi_sequence.getItem(VOIid);
DRTContourSequence roi_sequence = voi.getContourSequence();
Uint32 num_rois = roi_sequence.getNumberOfItems();
VOIdata.resize(num_rois);

  for(Uint32 i = 0; i < roi_sequence.getNumberOfItems(); i++)
  {
    DRTContourSequence::Item roi = roi_sequence.getItem(i);
    OFString numpoints;
    roi.getNumberOfContourPoints(numpoints);
    VOIdata[i].resize(atoi(numpoints.c_str())); 
    for(Uint32 j=0;j<(Uint32)atoi(numpoints.c_str());j++)
    {
     VOIdata[i][j].resize(3);
    } 
  } 
 
Uint32 roi_ctr=0;

if(!roi_sequence.isEmpty())
 { 
 if (roi_sequence.gotoFirstItem().good())
  {
   roi_ctr = 0;
   do
    {
     DRTContourSequence::Item &roi = roi_sequence.getCurrentItem();
     if(!roi.isEmpty())
     {
      OFString num_cont_points = "-1";
      roi.getNumberOfContourPoints(num_cont_points);
      Uint32 num_poins = atoi(num_cont_points.c_str());
      for(Uint32 i = 0; i < num_poins; i++) 
        {
         for(Uint32 j = 0; j < 3; j++)
         {
          OFString roidata;
          roi.getContourData(roidata,i*3+j);
          VOIdata[roi_ctr][i][j] = OFstatic_cast(Float32,atof(roidata.c_str()));
         }
        }
       }
        ++roi_ctr;
       } while (roi_sequence.gotoNextItem().good());
    }
   } 
return OFTrue;
}

Dose Normalisation Point

The dose normalisation point is stored in the RT Dose module.
Open your dose file and read it to a DRTDoseIOD object in the using the read function of this class.
Use the member function
virtual OFCondition getNormalizationPoint(OFString &value, const signed long pos = 0) const;
to get the normalization point.
Since this tag is of type 3 it might not be present in your dataset.

I hope this helps

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#7 Post by Jörg Riesmeier »

Btw, there is also an integer variant of getROINumber(), so there is no need to use atoi() anymore.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest