How to visualize the RT Structure object?
Moderator: Moderator Team
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
-
- Posts: 18
- Joined: Tue, 2009-09-22, 12:57
- Location: DKFZ Heidelberg
That will be very grateful to you!Please mail the piece of code to christcandy@yahoo.cn.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.
Best Regards,
Candy
Extracting Structures and points from DICOM RT Structure Set as stl::vector
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
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
-
- Posts: 18
- Joined: Tue, 2009-09-22, 12:57
- Location: DKFZ Heidelberg
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.
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
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;
}
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
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Btw, there is also an integer variant of getROINumber(), so there is no need to use atoi() anymore.
Who is online
Users browsing this forum: No registered users and 0 guests