add a private tag

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
AlreadyGoogled
Posts: 17
Joined: Wed, 2005-01-26, 16:43

add a private tag

#1 Post by AlreadyGoogled »

Hi,

I've been reading the FAQ and another post here about private tags, but still am uncertain of how to procede.

First I compiled the project which can create a built in dictionary from private.dic (makedictbi.cxx). I added my private tag to private.dic and had it rebuilt. My first question is, what should I direct the output to? Currently it is printing to screen, but should I overwrite dcdictzz.cxx (storing my new private dict) that is currently located at \dcmdata\libsrc?

Once that is done, do I recompile the dcmdata project?

Once that is done, how would I add the private tag in practice - similar to adding a normal entry?

Code: Select all

getDataset()->putAndInsertString(?? My_New_Private_Tag ??, "hello");
Thanks!

edit:
I am on windows.
________
Aromed vaporizer
Last edited by AlreadyGoogled on Sun, 2011-02-13, 00:31, edited 1 time in total.

AlreadyGoogled
Posts: 17
Joined: Wed, 2005-01-26, 16:43

#2 Post by AlreadyGoogled »

Ok I got it to work. I will post the steps here, if someone can verify this was the correct way that would be great, also perhaps people can refer to this post later on for help as well:

1) Go to dcmdata\libsrc and make a backup of dcdictzz.cxx. This is the file that will eventually include your private tags.

2) I think you can use the makefile Makefile.in in that directory to create a small app which will create a new dcdictzz.cxx for you. I just did it manually by creating a new win32 console project, and adding mkdictbi.cxx as the only source file.

3) In the source of mkdictbi.cxx, direct the output to a file called "dcdictzz.cxx" instead of output to screen.

3) Find and edit private.dic. You can add the private tags you want to use at the bottom there by following exactly the instructions at the top of the file.

4) Run the app you built in step 2 like:
> theprogram.exe [path to dicom.dic] [path to private.dic]

5) A newly created dcdictzz.cxx should await you. It had the private tags I added in there, along with the rest of the normal data dictionary. Replace the original dcdictzz.cxx at dcmdata\libsrc with the new one. Rebuild dcmtk. (Not sure if rebuilding all of dcmtk is necessary, but I did it as a precaution).

6) Now you can add the private tags you listed at runtime.

This method worked, if it is wrong or there is an easier way, please let me know, thanks!
________
Daihatsu yrv specifications
Last edited by AlreadyGoogled on Sun, 2011-02-13, 00:31, edited 1 time in total.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1446
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#3 Post by Marco Eichelberg »

Your description is correct. We usually generate the dictionary files on Unix (Linux), where the DCMTK makefile in dcmdata/libsrc already has a make target for this purpose: "make dcdictzz.cc" will generate a new built-in dictionary from dicom.dic and private.dic.
In a similar manner, "make gendeftag" can be used to re-generate the dcdeftag.h header file, which does not include the private tags however.

AlreadyGoogled
Posts: 17
Joined: Wed, 2005-01-26, 16:43

#4 Post by AlreadyGoogled »

Hello Marco, thanks for your reply. I have been adding private tags without problems so long as their VR is LO. This works fine. I tried adding some more private tags defined in private.dic like so:

Code: Select all

(3333, "My_priv_tag", 13)   US   1
Compiled with the new tags etc. Now whenever I try adding this tag at runtime using:

Code: Select all

putAndInsertUint16(DcmTagKey(0x3333, 0x0013), 45);
I always get a runtime warning of:

Code: Select all

Illegal Call, perhaps wrong parameters.
It works fine if I add the tag using:

Code: Select all

putAndInsertString(DcmTagKey(0x3333, 0x0013), "45");
Any ideas why I can't use InsertUint16 with this private tag? It's not a huge deal, I'd just rather not have to format my numerics into buffers before adding them to the image.

Thanks.
________
Dodge Charger (1999 Concept) History
Last edited by AlreadyGoogled on Sun, 2011-02-13, 00:31, edited 1 time in total.

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

#5 Post by Jörg Riesmeier »

You should read section 7.8 (Private Data Elements) in part 5 of the DICOM standard. (3333,0013) is a Private Creator element which always has a VR of "LO".

Zbigniew
Posts: 2
Joined: Tue, 2005-02-15, 09:58
Location: Bonn

#6 Post by Zbigniew »

Hi,

What would be the way to read / define private tags "on runtime" (without changing the private.dic file and without recompilation of DCMTK) ? Is it possible? If so, which interfaces / methods should I use ?

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1446
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#7 Post by Marco Eichelberg »

See the definition of DcmDataDictionary::addEntry() in dcmdata/include/dcdict.h.

Code: Select all

DcmDataDictionary& dict = dcmDataDict.wrlock();
dict.addEntry(new DcmDictEntry(0x0009, 0x1000, EVR_SQ, "MyPrivateSQ", 1, 1, "private", OFFalse, "MY_PRIVATE_CREATOR"));
dcmDataDict.unlock();

Beacon
Posts: 2
Joined: Mon, 2006-03-20, 18:50

#8 Post by Beacon »

I'm trying the Data Dictionary way of adding an entry, but even after adding in the lines Marco posted (slighly modified for the entry I needed to add), I'm still getting the following error when I call findAndGetString with the new TagKey:
Illegal Call, perhaps wrong parameters
Is there something I might be forgetting to do?
Thanks in advance.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1446
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#9 Post by Marco Eichelberg »

Make sure the reservation element (3333,00xx) with VR=LO and value "My_priv_tag" (or whatever you have decided to call it) is present in the dataset, so that the data dictionary can look up the VR of your attribute based on the reservation element.

Beacon
Posts: 2
Joined: Mon, 2006-03-20, 18:50

#10 Post by Beacon »

Sorry, I guess I'm a bit confused. What is this reservation element? Are you saying that any private tags need to be 3333, 00xx? If that's true, then I'm REALLY confused, since the tags I need to add all start with 200D.

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

#11 Post by Jörg Riesmeier »

You should read section 7.8.1 of part 5 of the DICOM standard.

Veena
Posts: 3
Joined: Mon, 2009-05-11, 08:16
Location: Bangalore

Adding private tags

#12 Post by Veena »

Hi ,

I had followed the same steps as posted above, still no success.. Anyways this is what I did - please find my queries too..

1. Added private tag
(3333,"my_company_creator",11) DS TestTagInfo

In above, I need 3333,2511 to point to "TestTagInfo" which means,
3333,0025 refers to the private creator "my_company_creator" . Am I correct?
do I need to add my private creators too in the DICOM dic file?

2. I built mkdictbi with the same dicom dic as arguments. Built fine and I got the dcdictzz.cxx file created with this following entry -

#ifdef WITH_PRIVATE_TAGS
, { 0x3333, 0x0011, 0x3333, 0x0011,
EVR_DS, "TestTagInfo", 1, 1, "DICOM",
DcmDictRange_Unspecified, DcmDictRange_Unspecified,
"my_company_creator" }

I tried building the mkdeftag.
I would like to define this tag as
#define DCM_TEST_TAGINFO DcmTagKey(0x3333, 0x2511)

How do I make this reflect to my application and to the dcdictzz.cxx?

Anyways, i tried temporarily to add this tag by defining the same to my application, but, when i did a dcm2xml create i could see the tag as Unknown.
Please help .

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

#13 Post by Jörg Riesmeier »

In above, I need 3333,2511 to point to "TestTagInfo" which means,
3333,0025 refers to the private creator "my_company_creator" . Am I correct?
Yes.
do I need to add my private creators too in the DICOM dic file?
No.
I tried building the mkdeftag.
I would like to define this tag as
#define DCM_TEST_TAGINFO DcmTagKey(0x3333, 0x2511)
For private tags, no defines are created because the tag name is (usually) not unique.
Anyways, i tried temporarily to add this tag by defining the same to my application, but, when i did a dcm2xml create i could see the tag as Unknown.
If you are using the built-in dictionary, make sure that dcdictzz.cxx is used and not the dcdictbi.cxx (see documentation). If you are using the private.dic file (or any other external dictionary file), please make sure that this file is loaded by your application, e.g. by setting the DCMDICTPATH environment variable accordingly.

Post Reply

Who is online

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