dcmodify and private sequence attributes

Questions regarding other OFFIS DICOM tools

Moderator: Moderator Team

Post Reply
Message
Author
jsgillen1
Posts: 3
Joined: Tue, 2020-02-04, 09:09

dcmodify and private sequence attributes

#1 Post by jsgillen1 » Mon, 2020-02-10, 15:49

I'm working on a DICOM anonymizer for our Philips MRI data using dcmodify and seeing problems with private tags. Private sequences are not recognized with the usual entries in the private dictionary. On my Mac and Linux system I'm using a DCMTK 3.6.5 that I built from source so I loaded the pre-built binary for Windows to try in my VMware VM. It has the same issue. Private sequence attributes aren't recognized in dcmdump or dcmodify. I have been able to get my script working by entering the SQ attributes into the dictionary without the reservation. This is fine as long as Philips doesn't change the reservation numbers. Here is an example that illustrates the problem. It's not clear from the documentation whether all of this should actually be working - does dcmodify recognize the private reservations?

C:\Data>dcmodify -m 5200,9229[0].2005,140e[0].0018,9011=YES 06_MPRAGE_SAG_Sense.dcm
E: modifying tag in file 06_MPRAGE_SAG_Sense.dcm: Invalid Path: Non-sequence tag found with rest path following
E: There was 1 error

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

Re: dcmodify and private sequence attributes

#2 Post by Michael Onken » Wed, 2020-02-12, 09:29

Hi,

under some cirumstances it is into possible for a DICOM parser to recognize and parse unknown private sequence data. Is the file encoded in Little Endian Implicit? It could also be a problem with the lookup method dcmodify uses to recognize the tag on the commandline, so I am not 100% sure that it is related to this. Anyway:

You should enter your private attributes into the dictionary, but *with* reservation, otherwise DCMTK will not recognize your tag as a valid private tag in a file. There is a specific syntax for that. Look into the file private.dic coming with DCMTK to see how this works (instructions in comments in the beginning of the file and examples below).

You can edit the private.dic file and compile it into DCMTK by enabling "DCMTK_ENABLE_PRIVATE_TAGS" in cmake configuration, but you can also add it afterwards:

You can include any additional dictionary file (including private.dic file) on top of the standard dictionary before running DCMTK binaries using the DCMDICTPATH environment variable, e.g. under linux you usually have to do this:

Code: Select all

export DCMDICTPATH=$DCMDICTPATH:/your/path/to/private.dic
...and then run dcmodify.

Let me know whether this works for you, otherwise you could maybe provide a little sample file (e.g. anonymized or only dataset with only the related tags, if you can).

Best regards,
Michael

jsgillen1
Posts: 3
Joined: Tue, 2020-02-04, 09:09

Re: dcmodify and private sequence attributes

#3 Post by jsgillen1 » Fri, 2020-02-14, 14:47

Here are my dictionary entries for an example of the problem. This example is done on a Windows system using the pre-built binaries from DCMTK. I get the same results using my Mac and CentOS versions built from source code:

C:\Data>echo %DCMDICTPATH%
C:\dcmtk-3.6.5-win64-dynamic\share\dcmtk\private.dic;C:\dcmtk-3.6.5-win64-dynamic\share\dcmtk\dicom.dic;

C:\Data>grep PrivateSharedSq C:\dcmtk-3.6.5-win64-dynamic\share\dcmtk\private.dic
(2005,"Philips MR Imaging DD 005",0e) SQ PrivateSharedSq 1
(2005,"PHILIPS MR IMAGING DD 005",0e) SQ PrivateSharedSq 1

If I try to dcmdump a Private sequence by name it fails, but without a warning about an unrecognized tag name

C:\Data>dcmdump +p +P PrivateSharedSq 06_MPRAGE_SAG_Sense.dcm

C:\Data>

Using the group,element it displays - with the private element labelled

C:\Data>dcmdump +p +P 2005,140e 06_MPRAGE_SAG_Sense.dcm
(5200,9229).(2005,140e) SQ (Sequence with explicit length #=1) # 336, 1 PrivateSharedSq
(fffe,e000) na (Item with explicit length #=23) # 328, 1 Item
(0008,0014) UI [1.3.46.670589.11.89.5] # 22, 1 InstanceCreatorUID
(0008,0016) UI =MRImageStorage # 26, 1 SOPClassUID
(0018,0089) IS [272] # 4, 1 NumberOfPhaseEncodingSteps
.
.
.
(0018,9183) CS (no value available) # 0, 0 FlowCompensationDirection
(0018,9218) FD 0 # 8, 1 TagSpacingSecondDimension
(fffe,e00d) na (ItemDelimitationItem for re-encoding) # 0, 0 ItemDelimitationItem
(fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem

For dcmodify referencing any private sequence using labels or group,element fails - it doesn't recognize that the attribute is VR = SQ

C:\Data> C:\Data> C:\Data>dcmodify -m 5200,9229[0].2005,140e[0].0018,9011=YES 06_MPRAGE_SAG_Sense.dcm
E: modifying tag in file 06_MPRAGE_SAG_Sense.dcm: Invalid Path: Non-sequence tag found with rest path following
E: There was 1 error

C:\Data>dcmodify -m 5200,9229[0].PrivateSharedSq[0].0018,9011=YES 06_MPRAGE_SAG_Sense.dcm
E: modifying tag in file 06_MPRAGE_SAG_Sense.dcm: Tag not found
E: There was 1 error

If I add the private sequence into the dictionary with the reservation, it works - even though this isn't legal

C:\Data>grep PrivateSharedSq C:\dcmtk-3.6.5-win64-dynamic\share\dcmtk\private.dic
(2005,"Philips MR Imaging DD 005",0e) SQ PrivateSharedSq 1
(2005,140e) SQ PrivateSharedSq 1
(2005,"PHILIPS MR IMAGING DD 005",0e) SQ PrivateSharedSq 1

C:\Data>dcmodify -m 5200,9229[0].2005,140e[0].0018,9011=YES 06_MPRAGE_SAG_Sense.dcm

C:\Data>

Checking with dcmdump, the value is modified

jsgillen1
Posts: 3
Joined: Tue, 2020-02-04, 09:09

Re: dcmodify and private sequence attributes

#4 Post by jsgillen1 » Sat, 2020-02-15, 16:08

Here's a minimal dump that can be used to test the problem. You should be able to convert it into a DICOM file using dump2dcm. I don't seem to have attachment permission. Here are the commands:

cat << EOF > test.txt
(0002,0000) UL 208
(0002,0001) OB 00\01
(0002,0002) UI =MRImageStorage
(0002,0003) UI [1.3.46.670589.11.24058.5.0.3400.2020021312112932630]
(0002,0010) UI =LittleEndianExplicit
(0002,0012) UI [1.2.276.0.7230010.3.0.3.6.5]
(0002,0013) SH [OFFIS_DCMTK_365]
(0008,0005) CS [ISO_IR 100]
(0040,0260) SQ (Sequence)
(fffe,e000) na (Item)
(0008,010b) CS [N]
(fffe,e00d) na (ItemDelimitationItem)
(fffe,e0dd) na (SequenceDelimitationItem)
(2001,0010) LO [Philips Imaging DD 001]
(2001,105f) SQ (Sequence)
(fffe,e000) na (Item)
(2001,0010) LO [Philips Imaging DD 001]
(2001,102d) SS 48
(fffe,e00d) na (ItemDelimitationItem)
(fffe,e0dd) na (SequenceDelimitationItem)
EOF
dump2dcm test.txt test.dcm
dcmodify -m '0040,260[0].0008,010b=Y' test.dcm
dcmodify -m '2001,105f[0].2001,102d=10' test.dcm

The first dcmodify will work. The second to a private sequence does not. Message is:
E: modifying tag in file s11.dcm: Invalid Path: Non-sequence tag found with rest path following
E: There was 1 error

The dictionary path:
kirby/jgillen/TEST_200213> echo $DCMDICTPATH
/usr/local/share/dcmtk/dicom.dic:/usr/local/share/dcmtk/private.dic
The private dictionary:
kirby/jgillen/TEST_200213> egrep '2001,.*5f' /usr/local/share/dcmtk/private.dic
(2001,"Philips Imaging DD 001",5f) SQ Stack 1
(2001,"PHILIPS IMAGING DD 001",5f) SQ Stack 1

If you add this to the private dictionary, it will work - even though not correct thing to do
(2001,105f) SQ Stack 1

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

Re: dcmodify and private sequence attributes

#5 Post by Michael Onken » Fri, 2020-02-21, 14:10

Sorry, I did not have the time to look into this in depth, I will check within the next days.

Best,
Michael

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest