How to insert a Sequence with undefined length ?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
walibi33
Posts: 9
Joined: Tue, 2017-11-21, 17:47

How to insert a Sequence with undefined length ?

#1 Post by walibi33 »

Hi,

I have been struggling to insert a sequence, but with an undefined length, into a data set.
The insertion of the sequence, as well as the insertion of all direct and indirect childs, is done correctly though.

But when I load the DICOM filed generated with Sante DICOM Hexadecimal Viewer I get this:

http://www.hostingpics.net/viewer.php?i ... eSaved.png

We can see that the Data Size property value is different from FFFFFFFF (that corresponds to the undefined length value -1) and that it has been automatically calculated.

Here is the code I use:

Code: Select all

dcmSQ = new DcmSequenceOfItems(DcmTag(DcmTagKey(group, element), DcmVR(EVR_SQ)), 0xFFFFFFFF);
OFCondition ret = item->insert(dcmSQ);
if (!ret.good())
{
      delete dcmSQ;
      return;
}
How can I modifiy my code to get the Data Size property of my sequence to have its value equal to FFFFFFFF ?

Here the result I'm looking for:
http://www.hostingpics.net/viewer.php?i ... Before.png

Thanks in advance !

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

Re: How to insert a Sequence with undefined length ?

#2 Post by Michael Onken »

Hi,

you don't have to care about length or undefined length when adding a sequence or item.

Once you want to write the dataset to network or a file, you can use an option to specify whether you want to have sequences written with either
  • With explicit length (applied to all sequences/items, then)
  • With undefined length (applied to all sequences/items, then). This is the default.
See for example the saveFile() method from DcmFileformat. The encodingType value is the relevant one. Click on the datatype to see the possible values.

Is this sufficient for you or do you need to create a mixed dataset (i.e. some items/sequences with undefined length, some with explicit length) from scratch?

Best,
Michael

walibi33
Posts: 9
Joined: Tue, 2017-11-21, 17:47

Re: How to insert a Sequence with undefined length ?

#3 Post by walibi33 »

Thank you Good Sir,
That is exactly what I was looking for ! :D

Just out of curiosity, and in case of a possible further need, how do we do a such mixed data set ?

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

Re: How to insert a Sequence with undefined length ?

#4 Post by Michael Onken »

Hi,

it's not possible with DCMTK to write mixed files (to my knowledge :roll:), since we don't think this makes much sense (though it's valid DICOM). So we only allow to write out all sequences and items with either defined or undefined length, consistently.

Best regards,
Michael

Post Reply

Who is online

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