read dicom structure set write contour points to txt file

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
gregthom
Posts: 1
Joined: Thu, 2008-02-28, 09:48

read dicom structure set write contour points to txt file

#1 Post by gregthom »

Greetings

I am new to this forum and new to using DCMTK. I am corrently learing how to use the library and I have installed and compiled everything completely without errors. My next task is reading a DICOM RT structure file and writing the contents of the structure contours to file.

The test code below works fine.
What I can't do now is use something like : DCM_ROIContourSequence to get the contour data.

Code: Select all

void SimpleView::fileOpen()
{
  
  
  QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
                                                 "/home",
												 tr("Dicom Images (*.dcm)")); 
  
  QFileInfo fi(fileName);
  std::string strfname = fileName.toStdString();
  //std::string strdname = fi.path().toStdString();

  DcmFileFormat fileformat; 
  OFCondition status = fileformat.loadFile(strfname.c_str()); 
  if (status.good()) 
  { 
    OFString patientsName; 
    if (fileformat.getDataset()->findAndGetOFString(DCM_PatientsName, patientsName).good()) 
    { 
      cout << "Patient's Name: " << patientsName << endl; 
    } else 
      cerr << "Error: cannot access Patient's Name!" << endl; 
  } else 
    cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl; 
  

}
My question is: How do I access contour data of the file with DCMTK to be able to write the contents to file ? Or even pass to vtk for further processing ?
I know the contour points are in the ROIContourSequence : arranged as such ROIContourSequence.Item_N.ContourSequence.Item_M.ContourData

ROIContourSequence and ContourSequence are sequences (VR = SQ).
Has someone any information that might help ?

I also intend to read RTPLAND and RTDOSE files in future but first things first.

Hope to hear from someone.


GT

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1444
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#2 Post by Marco Eichelberg »

Method DcmItem::findAndGetSequenceItem() is what you would like to use here. Code would roughly look like this (note: untested)

Code: Select all

signed long i = 0;
DcmItem *roiitem = NULL;
DcmItem *contouritem = NULL;
while (fileformat.getDataset()->findAndGetSequenceItem(DCM_ROIContourSequence, roiitem, i++).good())
{
  // roiitem now points to one item in the ROIContourSequence
  signed long j = 0;
  while (roiitem->findAndGetSequenceItem(DCM_ContourSequence, contouritem , j++).good())
  {
    // contouritem now points to some item in the ContourSequence
    // There are different ways to access the contour data.
    // The following approach is simple but not the most efficient one.
    Float64 v = 0.0;
    unsigned long k = 0;
    while (contouritem->findAndGetFloat64(DCM_ContourData, v, k++).good())
    {
       // here's one number from the contour data array,
       // already converted to floating point (i.e., double).
       cout << v << ", ";
    }   
  }  
}

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest