How to write Dcm file for RT Structure Set

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
IThirunarayanan
Posts: 12
Joined: Thu, 2021-03-18, 08:57

How to write Dcm file for RT Structure Set

#1 Post by IThirunarayanan »

Hello dcmtk team,

I am new to dcmtk and Dicom.
I populated all the tags of an DRTStructureSetIOD object. Now I want to write this object to a dcm file. Assuming rtStruct is my fully populated DRTStructureSetIOD object, is the following the correct way to do it?

DcmFileFormat fileformat;
auto status = rtStruct.write(*fileformat.getDataset());

auto fileMetaData = fileformat.getMetaInfo();
// Set all the file meta data //

if (status.good())
{
status = fileformat.saveFile(dcmFileName);
}

Thanks for your help.

J. Riesmeier
DCMTK Developer
Posts: 2498
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How to write Dcm file for RT Structure Set

#2 Post by J. Riesmeier »

Basically, yes, but there is no need to specify the element values of the file meta information manually (as this is done automatically when calling saveFile()).

IThirunarayanan
Posts: 12
Joined: Thu, 2021-03-18, 08:57

Re: How to write Dcm file for RT Structure Set

#3 Post by IThirunarayanan »

Thank you. How about tags like ImplementationVersionName or ImplementationClassUID or MediaStorageSOPInstanceUID that are specific to the manufacturer? Do we not set these tags in the file meta data?

J. Riesmeier
DCMTK Developer
Posts: 2498
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How to write Dcm file for RT Structure Set

#4 Post by J. Riesmeier »

How about tags like ImplementationVersionName or ImplementationClassUID or MediaStorageSOPInstanceUID that are specific to the manufacturer? Do we not set these tags in the file meta data?
If you use the DCMTK, ImplementationVersionName and ImplementationClassUID should be the ones of the DCMTK, i.e. they are added automatically. The values can be found in "dcmdata/include/dcuid.h":

Code: Select all

/// implementation version name for this version of the toolkit
#define OFFIS_DTK_IMPLEMENTATION_VERSION_NAME   "OFFIS_DCMTK_" PACKAGE_VERSION_NUMBER_TO_STRING(PACKAGE_VERSION_NUMBER)
[...]
/// Implementation class UID for this release of the toolkit
#define OFFIS_IMPLEMENTATION_CLASS_UID          OFFIS_UID_ROOT ".0." OFFIS_DCMTK_VERSION_STRING
MediaStorageSOPInstanceUID is also set automatically. Usually, it is copied from the dataset (attribute SOPInstanceUID). If SOPInstanceUID is not present, a new UID is being generated.

IThirunarayanan
Posts: 12
Joined: Thu, 2021-03-18, 08:57

Re: How to write Dcm file for RT Structure Set

#5 Post by IThirunarayanan »

Thank you.

IThirunarayanan
Posts: 12
Joined: Thu, 2021-03-18, 08:57

Re: How to write Dcm file for RT Structure Set

#6 Post by IThirunarayanan »

The following line of code returns OF_ok

Code: Select all

auto status = rtStruct.write(*fileformat.getDataset());
but the saveFile returns a status of OF_error with code 7 and text "Illegal call, perhaps wrong parameters". rtStruct is of type DRTStructureSetIOD and rtStruct.isValid() is true.

Code: Select all

OFFilename dcmFile("D:\\test.dcm");
status = fileformat.saveFile(dcmFile);
The dcm file is created in the location specified but is empty.
Would really appreciate if you can help me understand what the illegal call means. Thanks!

J. Riesmeier
DCMTK Developer
Posts: 2498
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How to write Dcm file for RT Structure Set

#7 Post by J. Riesmeier »

What is the output to the debug logger? It might also be useful to enable the trace logger...

IThirunarayanan
Posts: 12
Joined: Thu, 2021-03-18, 08:57

Re: How to write Dcm file for RT Structure Set

#8 Post by IThirunarayanan »

Seems like I needed to set the Transfer Syntax. I am able to now write the file. I am yet to verify the contents. Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest