Problems with element length

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
tcdewit
Posts: 8
Joined: Fri, 2012-06-01, 08:30

Problems with element length

#1 Post by tcdewit »

I'm having some weird problems when editing elements under sequence "ViewCodeSequence". The original dicom file has:

Code: Select all

    (0054,0220) SQ (Sequence with explicit length #=1)      #  72, 1 ViewCodeSequence
      (fffe,e000) na (Item with explicit length #=3)          #  64, 1 Item
        (0008,0100) SH [Anterior 3hr P.I]                       #  16, 1 CodeValue
        (0008,0102) SH [99NMG]                                  #   6, 1 CodingSchemeDesignator
        (0008,0104) LO [Anterior 3hr P.I.]                      #  18, 1 CodeMeaning
      (fffe,e00d) na (ItemDelimitationItem for re-encoding)   #   0, 0 ItemDelimitationItem
    (fffe,e0dd) na (SequenceDelimitationItem for re-encod.) #   0, 0 SequenceDelimitationItem
After editing the CodeValue element (just appending a dot) i get:

Code: Select all

    (0054,0220) SQ (Sequence with explicit length #=1)      #  74, 1 ViewCodeSequence
      (fffe,e000) na (Item with explicit length #=3)          #  66, 1 Item
        (0008,0100) SH [Posterior 3hr P.I.]                     #  18, 1 CodeValue
        (0008,0102) SH [99SDM]                                  #   6, 1 CodingSchemeDesignator
        (0008,0104) LO [Posterior 3hr P.I.]                     #  18, 1 CodeMeaning
      (fffe,e00d) na (ItemDelimitationItem for re-encoding)   #   0, 0 ItemDelimitationItem
    (fffe,e0dd) na (SequenceDelimitationItem for re-encod.) #   0, 0 SequenceDelimitationItem
The file is saved properly, but the ViewCodeSequence is not being read (no error msg though) by my 3rd party application (the original file does). Furthermore, when executing "cout << viewcodesequenceitem->verify().text() << endl;" after editing the element it returns "Corrupted data".

Any idea what i'm doing wrong?

tcdewit
Posts: 8
Joined: Fri, 2012-06-01, 08:30

Re: Problems with element length

#2 Post by tcdewit »

Btw... i'm using saveFile(File,EXS_Unknown,EET_ExplicitLength) for saving the modified dicom file.

braggpeaks
Posts: 15
Joined: Tue, 2012-04-17, 08:02

Re: Problems with element length

#3 Post by braggpeaks »

What tool are you using? Have you tried ImplicitLength? What if you don't modify anything, but save the file again; can you read the file then?

tcdewit
Posts: 8
Joined: Fri, 2012-06-01, 08:30

Re: Problems with element length

#4 Post by tcdewit »

I'm using a program of myself, created with dcmtk to modify and save the dicom file.
My program can read in the modified file and process the ViewCodeSequence even though it says its corrupted.
As long as i modify the CodeValue to a string with smaller length than the original everything is ok.

Do you know how can i specify ImplicitLength? EET_ImplicitLength doesn't exist apparently... I did try EET_UndefinedLength but that doesn't work either.

Just found out that using verify(true) fixes the problem. However, i'd like to understand whats going on and prevent instead of fix it.

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

Re: Problems with element length

#5 Post by Michael Onken »

Hi,

you just append a dot and "Anterior 3hr P.I" changes to "Posterior 3hr P.I."?

Is dcmdump able to dump the file before and after modification without prolems?

To find out what's wrong, try to write a minimal program that re-produces the error with the sequence in that file.

Best,
Michael

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

Re: Problems with element length

#6 Post by J. Riesmeier »

To the OP: Why are you calling verify() at all?

tcdewit
Posts: 8
Joined: Fri, 2012-06-01, 08:30

Re: Problems with element length

#7 Post by tcdewit »

Initially for debugging purposes only... I found out it doesn't really fix the problem though; it truncates the field to the original element-length (16 instead of 18 in above example).

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

Re: Problems with element length

#8 Post by J. Riesmeier »

Usually, there is no need to call verify() directly. This methods is mainly used internally as part of other DCMTK functions.

Post Reply

Who is online

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