Getting Exception on opening file: "Unhandled VR in DICOM parser observer: SQ"

432 views
Skip to first unread message

Jeremy Dowling

unread,
Jul 18, 2014, 5:32:25 PM7/18/14
to fo-d...@googlegroups.com
I'm trying to troubleshoot the exception noted in in the Question Title, and need some assistance.

My code, with respect to this issue, is straighforward:

Dicom.Imaging.DicomImage img = new Dicom.Imaging.DicomImage(f.FullName);
img.RenderImage().Save(destDir.FullName + @"\" + f.Name + @".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

I have several Dicom image files that work just fine, and several others that do not.

Have attempted, randomly, as I'm still a Oak DICOM newbie, several other attempts at opening the files that throw the exception.  In each case the below code throws the same exception:
  1. Dicom.Media.DicomDirectory d = Dicom.Media.DicomDirectory.Open(f.FullName);
  2. Dicom.DicomFile ffff = Dicom.DicomFile.Open(f.FullName)
The inner exception / stack trace is as follows:
InnerException: Dicom.DicomDataException
       HResult=-2146233088
       Message=Unhandled VR in DICOM parser observer: SQ
       Source=Dicom
       StackTrace:
            at Dicom.IO.Reader.DicomFileReader.EndRead(IAsyncResult result) in Z:\Development\fo-dicom\DICOM\IO\Reader\DicomFileReader.cs:line 59
            at Dicom.IO.Reader.DicomFileReader.Read(IByteSource source, IDicomReaderObserver fileMetaInfo, IDicomReaderObserver dataset) in Z:\Development\fo-dicom\DICOM\IO\Reader\DicomFileReader.cs:line 42
            at Dicom.DicomFile.Open(String fileName) in Z:\Development\fo-dicom\DICOM\DicomFile.cs:line 143

I have compared, in RadiAnt Dicom image viewer, the VR tags in files that work, as compared to those that do not.  There is a single level SQ in ones that successfully open.  In the ones that do not, the following nested sequence is present:

Other minor differences existed in the VR tags, however, they were not related to an SQ code.

Is it possible that the nested SQ is causing this issue?  Has anyone else observed this problem?  Is there a way to read the files I have and tell the files to drop SQ areas, as I simply need to open the image portion and export the image as a jpg?

David Murray

unread,
Jul 28, 2014, 6:11:00 PM7/28/14
to fo-d...@googlegroups.com
Hi Jeremy,

With 1.0.38 we are seeing this same failure on DICOM instances that have empty SQ elements. Although this is not great DICOM that such things exist, we need to tolerate this because some de-identification tools that our customers use seem to remove all the elements of some sequences but leave the sequence header in (as a NULL).

For now we have had to roll back to a previous version of fo-dicom.

Hope this helps.

Dave

Colby Dillion

unread,
Jul 28, 2014, 7:57:08 PM7/28/14
to fo-d...@googlegroups.com
I have not had time to look into this regression. I am certainly open to any fixes however.

Chris Horn

unread,
Aug 1, 2014, 1:24:54 AM8/1/14
to fo-d...@googlegroups.com
Are you able to post a an example image of an image that does not work?

David Murray

unread,
Aug 2, 2014, 6:45:14 PM8/2/14
to fo-d...@googlegroups.com
I'm pretty sure your June 26 commit (zero-length SQ) will fix our issue Colby. By Jeremy's issue might be different, for sure.

Jeremy Dowling

unread,
Aug 6, 2014, 11:29:36 AM8/6/14
to fo-d...@googlegroups.com
Thanks for all the feedback.  I happen to be at a customer site this week (thus the long lag time in getting back to everyone) - I will ask them for a non-confidential file that I can provide to the group.

Jeremy Dowling

unread,
Aug 6, 2014, 10:21:09 PM8/6/14
to fo-d...@googlegroups.com
Here is an example of a file that did not work with the above code.  It is zipped.

Once again, thanks for the help.
SYN00001.zip

Aerik Sylvan

unread,
Aug 27, 2014, 7:02:42 PM8/27/14
to fo-d...@googlegroups.com
I had a similar problem when the library tries to be smart about DicomVR.UN - the problem I saw was that the library changed the VR to the default dictionary VR for that tag, but *after* setting the length.  I moved that block of code to before the length was determined, and that fixed my issues.  I can also successfully parse your file.

Here's my DicomReader (attached).
DicomReader.cs

Chris Horn

unread,
Aug 27, 2014, 11:26:14 PM8/27/14
to fo-d...@googlegroups.com
As David has already mentioned the code was fixed by the June 26 check in..

however currently you will need to download the source code compile and use, as 1.0.38 has not been re-compiled for nuget
based on past release's these will not be in nuget until Colby  versions up 1.0.39. (unless he does a patch)

if you can't wait for that you should grab the source code or fork it on gitb hub.

At the end of the day to use Aerik's fix or Colby's you need to compile it,
Reply all
Reply to author
Forward
0 new messages