Download DICOM images from Orthanc

I have an Orthanc setup having MySQL DB as its backend and orthanc is registered with the PACS. I have a requirement to download the DICOM images from this orthanc server using spark. As per orthanc documentation only ways to download DICOM images is via the orthanc UI or via the API, the images that I have on PACS could go over 1 GB which makes API bit unreliable.

The other method I tried is to retrieve from the table in MySQL server,“StorageArea” is the name of the table, which has a content column which holds the entire DICOM image in the HEX format.I tired querying this table via spark and convert the column into string but all I got was garbage value.The HEX value should ideally decode to a DICOM image.

Need help to get the DICOM image using spark.

Thanks in advance.

Hello,

Why would the REST API be unreliable?

Have you considered downloading ZIP archives (which will by default create a stream since Orthanc 1.9.4), hereby mitigating possible memory issues), or using WebDAV?

https://book.orthanc-server.com/users/webdav.html

Directly accessing the storage area containing the DICOM files while Orthanc is running is discouraged.

Sébastien-

Hello Sébastien,

Thanks for the reply, this seems to be a good implementable solution but my requirement is to automate this solution(no human interventions) for that I have few questions.

  1. Will WebDAV store data in the DICOM format.
  2. Is WebDAV just an abstraction layer over RDBMS or does it make a new copy of the DICOM images.

Thanks

Hello,

1- Yes, WebDAV gives access to the raw DICOM files.
2- Yes, this is a virtual filesystem that purely operates in memory, so no copy is involved.

Regards,

Sébastien-

Hello,

That is amazing!
On another note, if I were to query the MySQL (StorageArea->content column), how can I convert this to “.dcm” format?
Right now I see it in blob/binary format.

Regards
Rushabh

Hello,

This question is more about MySQL than about Orthanc. Anyway, you’ll easily find an answer to it on Internet, for instance:
https://stackoverflow.com/questions/4646533/exporting-blob-from-mysql-database-to-file-with-only-sql

Sébastien-

Hello Sébastien,

Thanks for the link but what I want is, how have you encoded the DICOM image and stored it in MySQL,I was able to get the encoded image data from MySQL but not able to decode it to DICOM format.

Hello,

The MySQL plugin will by default store the raw DICOM instance.

This probably means that you have activated the “StorageCompression” configuration option of Orthanc.

https://book.orthanc-server.com/faq/features.html#compression

Have a look at the “OrthancRecoverCompressedFile” command-line tool (there are posts on this forum about it).

HTH,

Sébastien-

Hello,

Those are off,I cross checked with the AttachedFile table, my compressed and uncompressed size are same.As one more level on validation, uploaded size was same as compressed size.
Data is stored in a blob, which will be an array.I need help to convert this array to DICOM without the help of API.

Regards
Rushabh

Data is stored in a blob, which will be an array.I need help to convert this array to DICOM without the help of API.

Again, check out the link I sent you above in this thread:

https://stackoverflow.com/a/4647011

What is the issue with this answer?

Sébastien-

Hello,

Thanks for prompt replies !!

So if I understand correctly

Content column contains the image information only, not the tags,it is located in another table.
Using the store procedure I can get the image from content column.
My requirement was to get the DICOM as a whole, that is why I asked you again.

Also while I was reading you previous conversations, I wanted to ask few more questions:-
1.If I do not use any databases, .json files are stored in OrthancStorage but where are the images stored?
2.If using RDBMS, MySQL do I get the option to toggle enableStorage to false?

Regards
Rushabh