SeiictyUsui / pydicom

Automatically exported from code.google.com/p/pydicom
0 stars 0 forks source link

Incorrectly populates with Null Procedure Code Sequence #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. I'm working with mammography data from GE Senographe Essential burned 
from the Review Workstation.  There is a null sequence (0008, 1032) 
ProcedureCodeSequence.  pydicom seems to place all tags past that sequence 
inside of it such that PatientsName, PatientsID, etc.. are considered part 
of the sequence instead of in the document root as they should be.

I loaded the file in other dicom apps (Jdicom, ClearCanvas, Matlab), and 
all apps parse these files correctly.  Perhaps there is a bug handling null 
sequences?

Using pydicom 0.9.1, WinXP 32-bit Python 2.5.2

Original issue reported on code.google.com by brandon....@gmail.com on 24 Nov 2008 at 7:40

GoogleCodeExporter commented 9 years ago
Thanks for this detailed issue entry. In dicom.ReadSequence, the logic seems 
right
for either a zero length sequence or for a delimited sequence with nothing in 
it. Can
you direct me to an example file or a hex dump of the region of the sequence?

Original comment by darcymason@gmail.com on 25 Nov 2008 at 4:46

GoogleCodeExporter commented 9 years ago
assuming you are using gmail.. sent you a file.

Original comment by brandon....@gmail.com on 9 Dec 2008 at 8:06

GoogleCodeExporter commented 9 years ago
The sequence has a single item in it, but that item is empty (zero length). The 
code
didn't expect a zero-length dataset so a comparison to bytes-read < 0 never
triggered, and thus everything after was attached to the sequence.

I'm not quite sure of the best way to parse this, whether to consider the 
sequence
empty or to have a single (empty) item in it. I picked the latter for now and 
there
is a simple fix for this which will be in the next commit (but other code needs 
to be
fixed up first):

In dataset.py, function ReadDataset(),
  After
    ds = Dataset()
  Insert the following two lines
    if bytelength == 0:
        return ds
Then in ReadSequence():
  Change
        if not dataset:  # None is returned if get to Sequence Delimiter
  to
        if dataset is None:  # None is returned if get to Sequence Delimiter
Without the change in ReadSequence it will still work but will report the 
sequence as
having zero items.

Original comment by darcymason@gmail.com on 10 Dec 2008 at 4:24

GoogleCodeExporter commented 9 years ago
Unit test code added in r75.

Original comment by darcymason@gmail.com on 12 Jan 2009 at 4:40