Can I convert a TID300 Measurement object to a DcmDataset?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
anyone
Posts: 4
Joined: Tue, 2018-05-22, 10:14

Can I convert a TID300 Measurement object to a DcmDataset?

#1 Post by anyone »

I'm using the version 3.6.3 of dcmtk. I would like to save diffrent measurements in dicom with the Template 300 Measurement. My question is:
Is there a possibility to convert a measurement object to a DcmDataset? Or are there any other similar formats to convert it?

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

Re: Can I convert a TID300 Measurement object to a DcmDatase

#2 Post by J. Riesmeier »

TID300_Measurement is a sub-template that can be inserted into a root template (or the internally stored sub-tree can be inserted into a document tree) and then into an instance of DSRDocument. The latter provides a write() method that outputs its content to a DcmDataset. In principle, you could also write the DSRDocumentTree into a DcmDataset but this would probably make no sense.

anyone
Posts: 4
Joined: Tue, 2018-05-22, 10:14

Re: Can I convert a TID300 Measurement object to a DcmDatase

#3 Post by anyone »

I try creating a TID1500 Measurement Report and save the measurement also as TID300 Measurement in the measurement group. The report and the group as well as the measurement is valid. But when I want to verify the measurement reading the dataset there is no measurement group and also no measurement in the dataset. Also when I save the dataset to a dcm file, there is only the sr header but no measurement information.

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

Re: Can I convert a TID300 Measurement object to a DcmDatase

#4 Post by J. Riesmeier »

Did you actually insert the TID1500_MeasurementReport into the DSRDocument instance (e.g. using setTreeFromRootTemplate())? Could you post a minimal example that demonstrates what you've described?

anyone
Posts: 4
Joined: Tue, 2018-05-22, 10:14

Re: Can I convert a TID300 Measurement object to a DcmDatase

#5 Post by anyone »

Code: Select all

TID1500_MeasurementReport report( CMR_CID7021::ImagingMeasurementReport );
status = report.addIndividualMeasurements( true );
auto group = report.getIndividualMeasurements();
char* uid  = new char[100];
dcmGenerateUniqueIdentifier( uid );
status = group.setTrackingUniqueIdentifier( uid, true );
status = group.setTrackingIdentifier( "Diameter1" );
const CMR_SRNumericMeasurementValueWithUnits<CID7181_AbstractMultiDimensionalImageModelComponentUnits>
    value("12", CID7181_AbstractMultiDimensionalImageModelComponentUnits::EnumType::Millimeter, true);
status = group.addMeasurement(CID7469_GenericIntensityAndSizeMeasurements::EnumType::Diameter, value, true);
auto measurement = group.getMeasurement();
/* add spatial coordinates and real world value map to measurement (for the beginning I only added those items) */
DSRDocument* doc = new DSRDocument();
DcmFileFormat fileformat;
if ( doc->setTreeFromRootTemplate( report ).good() )
  doc->print( cout, DSRTypes::PF_printConceptNameCodes );
status = doc->write( *fileformat.getDataset() );
if ( status.good() )
{
  status = fileformat.saveFile( "test.dcm", EXS_LittleEndianExplicit );
}
Yes I have.
The 'status' is always good. I also added an observer context, a language and a procedure reported to the report. If I call

Code: Select all

report.isValid();
it is true (the same with group and measurement). But there isn't any measurement information in the dcm file (or dataset) only the observer context, language...

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

Re: Can I convert a TID300 Measurement object to a DcmDatase

#6 Post by J. Riesmeier »

I guess that the "auto" keyword in your code creates a local variable of the required type (i.e. a copy). However, what you actually need is a reference in order to modify the internally managed measurements (i.e. "auto &" or the respective by-reference type, which is what prefer).

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

Re: Can I convert a TID300 Measurement object to a DcmDatase

#7 Post by J. Riesmeier »

Btw, instead of CID7469_GenericIntensityAndSizeMeasurements::EnumType::Diameter you could also write CMR_CID7469::Diameter, which is much shorter.

anyone
Posts: 4
Joined: Tue, 2018-05-22, 10:14

Re: Can I convert a TID300 Measurement object to a DcmDatase

#8 Post by anyone »

Thank you very much!!

Post Reply

Who is online

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