Storing non-DICOM (eg JPG)

Hi, I have a question regarding storing non-DICOM files e.g. JPEGs/PNGs in Orthanc. What’s the current best approach for that in your experience? I would like to upload JPGs via Orthanc’s API. Is creating DICOM from scratch (e.g. via PyDicom) the way to go? If yes, do you have a reference to what kind of metatags/structure is required for Orthanc to accept the file?

Appreciate your help
-Jan

Hi Jan,

Yes, pydicom is an option. Note that you may also use the tools/create-dicomroute. There are some examples in the orthanc-tests: https://bitbucket.org/sjodogne/orthanc-tests/src/b8cdb0aef4b9970ee9c95a96ac09db86974e8f24/Tests/Tests.py#lines-1471
just use image/jpeg and make sure to encode the jpeg in base64.

For the file to be accepted by Orthanc, you’ll need to have at least all 4 Dicom Ids set (https://book.orthanc-server.com/faq/orthanc-ids.html) but it’s recommended to include as many tags as possible (like Study/Series Description, PatientName, Modality, pixelSpacings, …)

Jan -

Pydicom does work for this - I don’t see a good example for making secondary capture images on the web. But once you’ve created your *.dcm file you should try validating it using Dave Clunie’s dciovfy tool (http://www.dclunie.com/dicom3tools/dciodvfy.html). In the last few weeks I’ve had two different unexpected glitches with missing fields in the DICOM headers

  • OHIF wouldn’t display on its study list a study which was missing StudyDate - the image had been mangled by an anonymization tool
  • The dcmqi tool for generating DICOM seg wouldn’t work when StudyId (not the StudyInstanceUID - a different field) was missing. It’s a type 2 field (it can be empty - but it must be present).
    If the image loads into Osirix you can look at the output of the validation button on the metadata page - this might be more convenient than invoking dciovfy directly.

Sean

Sean, Alain,

Thank you guys for help. I was able to create minimalistic DICOM with Pydicom and store it in Orthanc. Thanks Sean for the suggestion regarding OHIF: right now I’m working with base cornerstone, but I will keep that in mind. I did not know about dciovfy – will look into this as well.

Because I don’t think there is a working example of making DICOM from scratch in Python (that would be store-able in Orthanc) on the web so far, let me leave the code snippet for future reference. Maybe someone will find it useful.

`
ds = Dataset() # pydicom.dataset.Dataset()
ds.file_meta = Dataset()
ds.file_meta.TransferSyntaxUID = pydicom.uid.ExplicitVRLittleEndian
ds.file_meta.MediaStorageSOPClassUID = ‘1.2.840.10008.5.1.4.1.1.1.1’
ds.file_meta.MediaStorageSOPInstanceUID = “1.2.3”
ds.file_meta.ImplementationClassUID = “1.2.3.4”
ds.PatientName = ‘Created’
ds.Rows = img.height
ds.Columns = img.width
ds.PhotometricInterpretation = “YBR_FULL_422”
if np_frame.shape[1] == 3:
ds.SamplesPerPixel = 3
else:
ds.SamplesPerPixel = 1
ds.BitsStored = 8
ds.BitsAllocated = 8
ds.HighBit = 7
ds.PixelRepresentation = 0
ds.PlanarConfiguration = 0
ds.NumberOfFrames = 1
ds.SOPClassUID = generate_uid() # pydicom.uid.generate_uid
ds.SOPInstanceUID = generate_uid()
ds.StudyInstanceUID = generate_uid()
ds.SeriesInstanceUID = generate_uid()
ds.PixelData = np_frame # Numpy frame of loaded image (e.g. via PIL)
ds.is_little_endian = True
ds.is_implicit_VR = False

`

W dniu piątek, 7 lutego 2020 06:06:01 UTC-5 użytkownik Sean Doyle napisał: