no SOPInstanceUID, but a ReferencedSOPInstanceUID

I have a handful of studies which contain images that have no SOPInstanceUID, but instead have a “ReferencedSOPInstanceUID” (0008,1155). (See attached.)

OsiriX doesn’t seem to have a problem with this, but Orthanc won’t accept the upload, giving “Bad file format: missing StudyInstanceUID, SerieInstanceUID or SOPInstanceUID”.

Is there anything I can do about this?

Daniel

IM-0001-0022.dcm (86.5 KB)

Hi Daniel,

Indeed, the SOPInstanceUID is really required by Orthanc (Useless to say that it is also required by the DICOM standard).

This is checked very early in Orthanc so you can not even sanitize the instance in OnStoredInstance(). So, I would advise you to sanitize it before pushing it to Orthanc or better reconfigure the modality/algorithm that generates those files to make them more valid.

Best regards,

Alain

Unfortunately, these are historic dicoms - generated as much as 25 years ago - that I am trying to import from our old (OsiriX) system into our new Orthanc-based system.

I’m not really allowed to modify existing files, but if I were going to (shhhh) … what do you mean by “sanitize”? What would you suggest I do?

Thanks

Hi Daniel,

By “Sanitizing”, I mean making the DICOM file more compliant.

In your case, that would probably mean:

  • retrieving the files from Osirix
  • adding a SOPInstanceUID with e.g. DCMTK or pydicom
  • import the files into Orthanc.

Best regards,

Alain

Dear Daniel,

As indicated by Alain, the “SOP Instance UID” (0008,0018) is a mandatory tag that cannot be empty (aka. “Type 1” tag) according to the DICOM standard:
http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.12.html

This can notably be seen by applying the “dciodvfy” command-line tool from the dicom3tools suite by David Clunie onto your sample file:

$ dciodvfy /tmp/IM-0001-0022.dcm
[…]
Error - Empty attribute (no value) Type 1 Required Element= Module=

You’ll find attached to this file, a sample Python plugin that can be used to automatically sanitize your DICOM files (which consists in introducing a random SOP Instance UID if absent, as explained by Alain):
https://book.orthanc-server.com/plugins/python.html

Here is the corresponding call to upload and sanitize your sample DICOM file:

$ curl -H ‘Expect:’ http://localhost:8042/fix --data-binary @IM-0001-0022.dcm

Two remarks about this script:

  • I have only tested it using Python 2.7, some adaptations might be needed for Python 3.x.
  • If you upload twice the same instance, two instances will be created: You could improve this sample plugin by keeping a map “MD5 of the DICOM file” to the “generated SOP Instance UID tag” in a separate database handled by Python in order to have a reproducible generation of the UID.

HTH,
Sébastien-

Oops, I forgot the attachment. Here it is.

drucker.py (1.04 KB)

This is fantastic, thank you!