DCMODIFY and DCMDUMP private tags

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
CStarkey
Posts: 2
Joined: Mon, 2020-05-11, 10:49

DCMODIFY and DCMDUMP private tags

#1 Post by CStarkey » Mon, 2020-05-11, 13:45

Good morning,

I've searched through the forums and haven't been able to isolate the source of my issue, I'm hoping someone here can help me out.

Goal: Insertion of custom private tags into DICOM images
Issue: If I add the creator identifier to the private dictionary definition then the DICOM tag name will display on a dump, but the tag value will not. If I do not include the identifier, then the value displays but the tag's name does not...
Environment: (Windows) MobaXterm Personal 20.2
DCMTK Version: 3.6.5

Example 'script':

BASEDIR='U:\Projects\DCM\DeIdent\'
DCMTK_EXE_LOC=$BASEDIR'dcmtk-3.6.5-win64-dynamic/bin/'
PATH=$PATH":$DCMTK_EXE_LOC"
cd $BASEDIR

# Confirming expected behavior, no private dictionary:
dcmodify --debug -i "(1337,0066)=HGRIC" -i "(1337,6600)=3.6.5" -i "(1337,6630)=A8675309" ./deidentified/study/DIRW0019
dcmdump --debug deidentified/study/DIRW0019 | grep 1337
# (1337,0066) LO [HGRIC] # 6, 1 PrivateCreator
# (1337,6600) UN 03\00 # 2, 1 Unknown Tag & Data
# (1337,6630) UN 03\00 # 2, 1 Unknown Tag & Data


# So we add in the following lines to the private.dic file
# # HGRIC addition:
# (1337,6600) ST DCMTKVersion 1 PrivateTag
# (1337,"HGRIC",6630) ST AnonJarSHA1 1 PrivateTag

# And enable it...
export DCMDICTPATH="$BASEDIR"'private.dic'

# Note, henceforth get "DcmDataDictionary: Loading file: (ourpath) " on dcmdump -d
dcmdump --debug +uc deidentified/study/DIRW0019 | grep 1337
# (1337,0066) LO [HGRIC] # 6, 1 PrivateCreator
# (1337,6600) ST [] # 2, 1 Unknown Tag & Data
# (1337,6630) ST [] # 2, 1 AnonJarSHA1


# Redo the modify command (on a new file), having DCMDICTPATH set...
dcmodify --debug -i "(1337,0066)=HGRIC" -i "(1337,6600)=3.6.5" -i "(1337,6630)=A8675309" ./deidentified/study/DIRW0020
dcmdump --debug +uc deidentified/study/DIRW0020 | grep 1337
# (1337,0066) LO [HGRIC] # 6, 1 PrivateCreator
# (1337,6600) ST [3.5.1] # 6, 1 Unknown Tag & Data
# (1337,6630) ST [] # 2, 1 AnonJarSHA1


# Values now correctly display for private.dic entries missing identifier value
# but are still missing their tag name...
#
# The entry that had the identifier value in the dictionary displays the tag
# name but the value isn't saved....

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

Re: DCMODIFY and DCMDUMP private tags

#2 Post by J. Riesmeier » Tue, 2020-05-12, 13:19

# So we add in the following lines to the private.dic file
# # HGRIC addition:
# (1337,6600) ST DCMTKVersion 1 PrivateTag
# (1337,"HGRIC",6630) ST AnonJarSHA1 1 PrivateTag
First of all, you should also add the Private Creator identifier "HGRIC" to the definition of your first private attribute (and remove the leading "#", of course).

Also, there are some known limitations for dcmodify when dealing with private tags (see documentation).

CStarkey
Posts: 2
Joined: Mon, 2020-05-11, 10:49

Re: DCMODIFY and DCMDUMP private tags

#3 Post by CStarkey » Tue, 2020-05-12, 14:32

Hello, thank you for the quick reply!

I apologize for the confusion this seems to have caused, but the literal 3 lines added to private.dic are:
"# HGRIC addition:
(1337,6600) ST DCMTKVersion 1 PrivateTag
(1337,"HGRIC",6630) ST AnonJarSHA1 1 PrivateTag"

The entries themselves do not have the comment delimiter.

I left both of those entries in there to be representative of the phenomenon I am experiencing: when I add the Private Creator identifier to the private.dic definition, the tag's value does not save correctly when inserted with DCMODIFY. If the identifier is missing from the private.dic definition, the tag's value appears to save properly, but the tag's name becomes Unknown.

I.E.
Scenario one) If my private dictionary ONLY contains: "(1337,6600) ST DCMTKVersion 1 PrivateTag"
==================================
$ dcmodify --debug -i "(1337,0066)=HGRIC" -i "(1337,6600)=3.6.5" ./deidentified/study/DIRW0008
I: Processing file: ./deidentified/study/DIRW0008
I: Loading file into dataset manager: ./deidentified/study/DIRW0008
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG Baseline"
I: Getting dataset from loaded file: ./deidentified/study/DIRW0008
I: Creating backup of input file: ./deidentified/study/DIRW0008.bak
I: Executing (option|path|value): i|(1337,0066)|HGRIC
I: Executing (option|path|value): i|(1337,6600)|3.6.5
D: DcmFileFormat::checkMetaHeaderValue() Version of MetaHeader is ok: 0x0001
D: DcmFileFormat::checkMetaHeaderValue() use new TransferSyntaxUID [JPEG Baseline] on writing following Dataset
D: DcmFileFormat::validateMetaInfo() found 7 Elements in DcmMetaInfo 'metinf'
I: Saving current dataset to file: ./deidentified/study/DIRW0008

$ dcmdump --debug deidentified/study/DIRW0008 | grep 1337
(1337,0066) LO [HGRIC] # 6, 1 PrivateCreator
(1337,6600) ST [3.6.5] # 6, 1 Unknown Tag & Data
==================================
As you can see, the tag value [3.6.5] is being displayed, but the tag name is showing up as "Unknown Tag & Data". The private dictionary entry appears to be recognized because the VR is being applied from the one specified in my dictionary entry, but the name is not.

Scenario two) if INSTEAD of the previous entry, my private dictionary only contains: "(1337,"HGRIC",6630) ST AnonJarSHA1 1 PrivateTag"
==================================
$ dcmodify --debug -i "(1337,0066)=HGRIC" -i "(1337,6630)=ABCD1234" ./deidentified/study/DIRW0010
I: Processing file: ./deidentified/study/DIRW0010
I: Loading file into dataset manager: ./deidentified/study/DIRW0010
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG Baseline"
I: Getting dataset from loaded file: ./deidentified/study/DIRW0010
I: Creating backup of input file: ./deidentified/study/DIRW0010.bak
I: Executing (option|path|value): i|(1337,0066)|HGRIC
I: Executing (option|path|value): i|(1337,6630)|ABCD1234
D: DcmFileFormat::checkMetaHeaderValue() Version of MetaHeader is ok: 0x0001
D: DcmFileFormat::checkMetaHeaderValue() use new TransferSyntaxUID [JPEG Baseline] on writing following Dataset
D: DcmFileFormat::validateMetaInfo() found 7 Elements in DcmMetaInfo 'metinf'
I: Saving current dataset to file: ./deidentified/study/DIRW0010

$ dcmdump --debug deidentified/study/DIRW0010 | grep 1337
(1337,0066) LO [HGRIC] # 6, 1 PrivateCreator
(1337,6630) UN 34\00 # 2, 1 AnonJarSHA1
==================================
In this scenario, the tag name is showing up as "AnonJarSHA1" but the VR is not being detected nor is the actual tag value.

As far as I can determine based on both your comment, https://support.dcmtk.org/docs/dcmodify ... ivate_tags, the example definitions in the provided private.dic file, reviewing https://support.dcmtk.org/docs/file_datadict.html, and google searching: scenario two is the correct method, I need to include the private identifier. However, when I do, the value does not appear to be stored when I go to export it with DCMDUMP.

If I attempt to use the +uc tag from DCMDUMP to force reading the tag in scenario two...
==================================
$ dcmdump -ml +uc --debug deidentified/study/DIRW0010 | grep 1337
(1337,0066) LO [HGRIC] # 6, 1 PrivateCreator
(1337,6630) ST [4] # 2, 1 AnonJarSHA1

==================================

Which is clearly not the desired result.

Can you see what I am missing that prevents the tag value and VR of a private tag from displaying when it is listed in the private dictionary with an identifier?

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

Re: DCMODIFY and DCMDUMP private tags

#4 Post by J. Riesmeier » Fri, 2020-05-15, 20:42

I can confirm that something is fishy about the private tag support in dcmodify. If I use -if instead of -i, reading the text string from a text file works. Using dcmdump with option +uc then shows the correct VR and attribute name.

I will ask the author of dcmodify to comment on this.

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

Re: DCMODIFY and DCMDUMP private tags

#5 Post by Michael Onken » Mon, 2020-05-25, 14:52

Hi,
I will ask the author of dcmodify to comment on this.
That would be me...

There is a bug with the reservation checking for private tags. I have fixed this in commit f7bd99. Do you have the chance to compile from source and try the new version?

Best regards,
Michael

Post Reply

Who is online

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