how to work with nesting data set (with SQ as VR)

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
VMMF
Posts: 4
Joined: Fri, 2014-09-26, 08:29

how to work with nesting data set (with SQ as VR)

#1 Post by VMMF »

Hello, im trying to save a DICOM image using DCMTK and i´m experiencing problems while trying to save the tags with SQ Value representation, which require nested elements to be stored within them. Can i get some help or an example of how to do it with DCMTK. I,ve just read the DICOM Standard apendix 7.5 and and don´t know which of the two methods(fixed or undefined data length) to use or how to use them with DCMTK.
Thanks a lot

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: how to work with nesting data set (with SQ as VR)

#2 Post by Michael Onken »

Hi,

in DCMTK you only specify while saving a DICOM dataset to disk or transfer it, how the sequences are encoded (there is even a default so you do not usually care about it at all). Inserting, reading and so in memory on does not require that information.

Look at the second example in the dcmdata online documentation.

To insert a sequence with one item into the dataset, use this additional call:

Code: Select all

DcmItem newItem = NULL;
if (dataset->findOrCreateSequenceItem(DCM_WaveformSequence, newItem, 0)).good())
{
  // work on the content of the new item
  newItem->doSomething();
}
findOrCreateSequenceItem and similar calls are described in the DcmItem API documentation.

As you can see, no knowledge about the length encoding is required. An optional parameter in saveFile() on DcmFileFormat decides how the sequences and items are encoded (default: undefined length).

HTH,
Michael

Best,
Michael

VMMF
Posts: 4
Joined: Fri, 2014-09-26, 08:29

Re: how to work with nesting data set (with SQ as VR)

#3 Post by VMMF »

Oh thanks Michael. At last it worked very good this way

DcmItem *anatomicRegionSequence ;
if ((dataset->findOrCreateSequenceItem(DCM_AnatomicRegionSequence, anatomicRegionSequence, 0)).good())
{
//addons de 0x0008
reultadoOperacion = anatomicRegionSequence->putAndInsertString(DCM_CodeValue, m_DCM_AnatomicRegionSequence_CodeValue);
if(reultadoOperacion.bad()) AfxMessageBox("Error al salvar la etiqueta DCM_CodeValue en el archivo DICOM");

reultadoOperacion = anatomicRegionSequence->putAndInsertString(DCM_CodingSchemeDesignator, m_DCM_AnatomicRegionSequence_CodingSchemeDesignator); //SH
if(reultadoOperacion.bad()) AfxMessageBox("Error al salvar la etiqueta DCM_CodingSchemeDesignator en el archivo DICOM");

reultadoOperacion = anatomicRegionSequence->putAndInsertString(DCM_CodeMeaning, m_DCM_AnatomicRegionSequence_CodeMeaning); //LO
if(reultadoOperacion.bad()) AfxMessageBox("Error al salvar la etiqueta DCM_CodeMeaning en el archivo DICOM");
}
else
AfxMessageBox("Error al salvar la etiqueta DCM_AnatomicRegionSequence en el archivo DICOM");


The code tags are in Spanish but the general idea is still the same. Thanks again

Post Reply

Who is online

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