Reading second instance of a duplicated Tag

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
jdinca
Posts: 13
Joined: Thu, 2012-10-25, 07:18

Reading second instance of a duplicated Tag

#1 Post by jdinca »

Hi,

I've found that certain data sets have two instances of the same tag, meaning that, when findAndGetOFStringArray is used for the read, the second tag is ignored.
OFCondition findAndGetOFStringArray(const DcmTagKey &tagKey,
OFString &value,
const OFBool searchIntoSub = OFFalse);

Is there any solution to this? Or, do more recent versions of DCMTK facilitate multiple reads of duplicate tags?

According to this:
https://forum.dcmtk.org/viewtopic.php?t=509

DCMTK, by default, throws out the second value of any duplicated tag.

I am using 3.6.0 and realize this is now an old version and this previous posting is also quite old. This could be a reason to update!

Thank you in advance for any help.

Jonathan.

jdinca
Posts: 13
Joined: Thu, 2012-10-25, 07:18

Re: Reading second instance of a duplicated Tag

#2 Post by jdinca »

Just to follow up, we realized that findAndGetElements returns _all_ elements with the same name, so one simply need loop over the returned values to get them all.

DCMTK is great!

Jonathan.

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

Re: Reading second instance of a duplicated Tag

#3 Post by J. Riesmeier »

Thank you for posting the solution to your problem.

So, there are no duplicates but the data elements with the same attribute tag are stored on different nesting levels or in different sequences / items.

jdinca
Posts: 13
Joined: Thu, 2012-10-25, 07:18

Re: Reading second instance of a duplicated Tag

#4 Post by jdinca »

Yes, no problems. Happy to help as this forum has been really useful to us and invariably DCMTK has an excellent solution! So to be quite explicit for other readers, the approach we use is via the DcmStack, in which we can populate all results:

DcmStack resultStack;
fileformat.getDataset()->findAndGetElements(DCM_CodeMeaning, resultStack);
while (!resultStack.empty())
{
DcmStackNode tmp = resultStack.pop();
DcmObject* val = tmp.value();
}

And indeed, they are not duplicates as you point out. Just nested items.

Thanks,

Jonathan.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest