retrieving private tag values

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
i.sch
Posts: 3
Joined: Fri, 2010-05-28, 07:52

retrieving private tag values

#1 Post by i.sch »

Hi, i am new to the dcmtk, so maybe this question will sound trivial to some board members.
I have several dicom files, and some of them contain private tags.
It looks like following:

Code: Select all

0009, 0000 Group Length, UL, 1, somenumber
0009, 0010 Private Creator, Lo, 1, sometext
0009, 0011 Private Creator, Lo, 1, whatiwant
0009, 0012 Private Creator, Lo, 1, sometext
What i'm trying to do is, to determin if the current dicom file, contains the whatiwant string, which btw. appears somewhere in the block and not always on the 0011 position. I tried searching the DcmDataDictionary for "PrivateCreator" or "Private Creator". Which looked something like that:

Code: Select all

DcmTagKey tag = *dict.findEntry("Private Creator");
myDcmDataset->findAndGetOFString(tag, value);
But this seems to be the wrong way to do it, since it doesn't work. So maybe someone here can describe how to solve this problem or push me in the right direction.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

I'm not quite sure what you are looking for, but if you want to know if a certain tag is a private creator, you could use the following method: DcmTagKey::isPrivateReservation()
What i'm trying to do is, to determin if the current dicom file, contains the whatiwant string, which btw. appears somewhere in the block and not always on the 0011 position.
So, you want to know whether a particular private creator string is used in the DICOM dataset - in any of the private groups?

i.sch
Posts: 3
Joined: Fri, 2010-05-28, 07:52

#3 Post by i.sch »

Jörg Riesmeier wrote: [...]
So, you want to know whether a particular private creator string is used in the DICOM dataset - in any of the private groups?
exactly

[edit]
Thanks for the tip. Now the only problem seems to be, to determine how many entries a group has. In the Tag "Group Length" there is just a number which probably somehow represents bits or bytes, but not the number of entries in a group. Or is there maybe another way to iterate through a group?
[/edit]

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#4 Post by Jörg Riesmeier »

The following example shows how to iterate over the data elements of a dataset.

i.sch
Posts: 3
Joined: Fri, 2010-05-28, 07:52

#5 Post by i.sch »

Thanks it worked. I modified the example a little bit and used the nextInContainer function instead, since i am not deleting elements. Here is a simplified code snipplet to make this topic complete.

Code: Select all

DcmObject *dobj = NULL;
DcmTagKey tag;

while((dobj = pDcmDataset->nextInContainer(dobj)) != NULL){
   tag = dobj->getTag();
   if (tag.isPrivate()){
    	OFString ostring;
    	OFCondition res = pDcmDataset->findAndGetOFString(tag, ostring);
    	std::cerr << "res: " << ostring.c_str() <<std::endl;
   }
}

Post Reply

Who is online

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