Private tag support

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Jingkun4dcmtk
Posts: 7
Joined: Wed, 2023-02-08, 18:18

Private tag support

#1 Post by Jingkun4dcmtk »

Dear Dev team,

I’m trying to extend dcmtk to support private tags via my own xyz.dic. I was able to generate or convert my xyz.dic to xyz.h, as shown below:

(0011,"Jhu-X",10) LO JhuGroup11 1 PrivateTag

(0011,"Jhu -X",01) CS PatientType 1 PrivateTag

(0011,"Jhu -X",02) CS PatientStatus 1 PrivateTag

(0011,"Jhu -X",03) LO PlanUuid 1 PrivateTag

(0011,"Jhu -X",04) LO TrackingMaskUuid 1 PrivateTag

(0011,"Jhu -X",05) LO PatientUuid 1 PrivateTag

(0011,"Jhu -X",06) LO PatientPictureUuid 1 PrivateTag

The generated tags are:
#define DCM_PatientUID DcmTagKey(0x0011, 0x0003)

#define DCM_PatientType DcmTagKey(0x0011, 0x0001)

#define DCM_PatientStatus DcmTagKey(0x0011, 0x0002)

#define DCM_PlanUuid DcmTagKey(0x0011, 0x0003)

#define DCM_TrackingMaskUuid DcmTagKey(0x0011, 0x0004)

#define DCM_PatientUuid DcmTagKey(0x0011, 0x0005)

#define DCM_PatientPictureUuid DcmTagKey(0x0011, 0x0006)

#define DCM_JhuGroup11 DcmTagKey(0x0011, 0x0010)

When adding tags to DICOM file in the following way:
dcmDS->putAndInsertString(DCM_JhuGroup11, "Jhu-X");

dcmDS->putAndInsertString(DCM_PatientType, "Phantom");

dcmDS->putAndInsertString(DCM_PatientStatus, "New");

Only DCM_JhuGroup11 is added successfully.

Can you help me get my other tags added? Basically I'd like to operate (read/write) private tags like public ones by extending the public dictionary.

Thanks,
Jack

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

Re: Private tag support

#2 Post by J. Riesmeier »

Apparently, the VR is missing for your private tags. By the way, there is a "Howto" on adding private data elements to a DICOM dataset: https://support.dcmtk.org/redmine/proje ... rivateData

Jingkun4dcmtk
Posts: 7
Joined: Wed, 2023-02-08, 18:18

Re: Private tag support

#3 Post by Jingkun4dcmtk »

Hi J. Riesmeier,

I'm able to add private tags via the instructions provided by "Howto" already. However, I don't want to use that approach of registering private tags at runtime. My understanding is that private tag support can also be achieved by extending the dicom.dic as described in https://support.dcmtk.org/docs/file_datadict.html so that private tags will be able to be used in the same way as public tags.

So I did the following:
1. create my own myprivate.dic by following your private.dic
2. generate private.h using myprivate-mkdeftag.h

What other steps do I need to do in order to use those private tags defined in myprivate.dic?

BTW, you pointed out that "VR missing"? I did have VR defined in my private tag definition, e.g., (0011,"Jhu-X",10) LO JhuGroup11 1 PrivateTag.

Thanks,
Jingkun

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

Re: Private tag support

#4 Post by J. Riesmeier »

My understanding is that private tag support can also be achieved by extending the dicom.dic as described in https://support.dcmtk.org/docs/file_datadict.html so that private tags will be able to be used in the same way as public tags.
That's correct.
generate private.h using myprivate-mkdeftag.h
This is not really necessary, and your DcmTagKey definitions also seem to be wrong [*], e.g. instead of

Code: Select all

#define DCM_PatientUID DcmTagKey(0x0011, 0x0003)
it should be

Code: Select all

#define DCM_PatientUID DcmTagKey(0x0011, 0x1003, "Jhu-X")
because otherwise the DCMTK would not be able to determine the VR. This would have been more obvious, I guess, if you would have checked the return value of the putAndInsertString() calls.

HTH

[*] The mkdeftag tool does not support DcmTagKey definitions for private tags, AFAICR. This is because creating DCM_xxx names from the private tags in the "private.dic" file that is shipped with the DCMTK is probably not possible.

Jingkun4dcmtk
Posts: 7
Joined: Wed, 2023-02-08, 18:18

Re: Private tag support

#5 Post by Jingkun4dcmtk »

Hi J. Reismeier,

In
#define DCM_PatientUID DcmTagKey(0x0011, 0x1003, "Jhu-X"), DcmTagKey can't take 3 parameters though. Did I miss any point?

Thanks,
Jingkun

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

Re: Private tag support

#6 Post by J. Riesmeier »

Sorry, I wanted to refer to DcmTag (not DcmTagKey), which has two constructors that allow for specifying the Private Creator identifier as an optional parameter (see documentation).

Jingkun4dcmtk
Posts: 7
Joined: Wed, 2023-02-08, 18:18

Re: Private tag support

#7 Post by Jingkun4dcmtk »

Hi J. Reismeier,

That does the trick!

I'm able to write and read my private tags as expected.

Your help is greatly appreciated!

Thanks,
Jingkun

Post Reply

Who is online

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