Importing Images already compressed by Orthanc

I have a set of images that have been compressed by orthanc already.
When I try to use ImportDicomFiles.py to import the images into a different server, I get this error:

From script:

Importing OrthancStorage.original/3e/c4/3ec4505b-bb42-4f8b-aef8-fc5097cb8c45 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/b1/3eb1d5ca-82f9-4536-a4f4-34e0147dbee1 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/b1/3eb10a9a-da54-4bff-a2cc-7f2f251928d9 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/c1/3ec175f9-fc47-46e0-8746-c6ce93c42dcb => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/c1/3ec126be-5f74-43df-a6ca-2c303cc0e254 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/3c/3e3c0f20-fd9c-4112-995b-699b5a7520b5 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/3c/3e3c46ef-86be-459b-ae2c-bb3d0b099faf => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/3f/3e3f6a1e-057b-41e1-98e5-5834764138c6 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/f7/3ef78a89-f236-48c0-805c-b64132804879 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/fa/3efac67c-3114-4ec9-b45b-bfd96de1baf4 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/fa/3efa698c-50c7-4535-ac88-392554f0212c => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/fa/3efa9164-e12b-4662-9c41-7fa592635043 => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/fe/3efe183b-8eec-4cbe-b5b1-9945adc5fe7a => failure (Is it a DICOM file?)
Importing OrthancStorage.original/3e/00/3e005028-4e6e-423c-8b56-3989a392cd31 => failure (Is it a DICOM file?)

From Server:

E0310 23:33:58.686676 20211 MongooseServer.cpp:689] Exception in the HTTP handler: Bad file format
E0310 23:33:58.702746 20212 MongooseServer.cpp:689] Exception in the HTTP handler: Bad file format
E0310 23:33:58.755324 20213 MongooseServer.cpp:689] Exception in the HTTP handler: Bad file format
E0310 23:33:58.767066 20214 MongooseServer.cpp:689] Exception in the HTTP handler: Bad file format
E0310 23:33:58.835363 20215 MongooseServer.cpp:689] Exception in the HTTP handler: Bad file format
E0310 23:33:58.848182 20216 MongooseServer.cpp:689] Exception in the HTTP handler: Bad file format
E0310 23:33:58.910857 20217 MongooseServer.cpp:689] Exception in the HTTP handler: Bad file format
E0310 23:33:58.979068 20218 MongooseServer.cpp:689] Exception in the HTTP handler: Bad file format

I have also tried to decompress the images using these methods: http://unix.stackexchange.com/questions/22834/how-to-uncompress-zlib-data-in-unix

Is there any way to import already compressed images into orthanc?

Hi,

You will first have to decompress each file to get the original DICOM files before re-importing them.

The source distribution contains a maintenance tool for this purpose:
https://code.google.com/p/orthanc/source/browse/Resources/Samples/Tools/RecoverCompressedFile.cpp

HTH,
Sébastien-

Hi Sebastien,

Thank you for your quick reply!
I am not very acquainted with compiling source like this, perhaps I am doing something wrong. Here is my error:

`

[user@centos6 Orthanc-0.8.5]$ pwd

/opt/src/Orthanc-0.8.5

[user@centos6 Orthanc-0.8.5]$ find . -name “RecoverCompressedFile.cpp”

./Resources/Samples/Tools/RecoverCompressedFile.cpp

[user@centos6 Orthanc-0.8.5]$ g++ Resources/Samples/Tools/RecoverCompressedFile.cpp -o RecoverCompressedFile

In file included from Resources/Samples/Tools/…/…/…/Core/Toolbox.h:35,

from Resources/Samples/Tools/RecoverCompressedFile.cpp:22:

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:35:23: error: laaw/laaw.h: No such file or directory

In file included from Resources/Samples/Tools/RecoverCompressedFile.cpp:22:

Resources/Samples/Tools/…/…/…/Core/Toolbox.h:40:23: error: json/json.h: No such file or directory

In file included from Resources/Samples/Tools/…/…/…/Core/Toolbox.h:35,

from Resources/Samples/Tools/RecoverCompressedFile.cpp:22:

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:83: error: use of enum ‘LAAW_API’ without previous declaration

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:84: error: invalid type in declaration before ‘{’ token

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:84: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:90: error: ‘PixelFormat_RGB24’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:97: error: ‘PixelFormat_RGBA32’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:103: error: ‘PixelFormat_Grayscale8’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:109: error: ‘PixelFormat_Grayscale16’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:115: error: ‘PixelFormat_SignedGrayscale16’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:116: error: scalar object ‘Orthanc::PixelFormat’ requires one element in initializer

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:122: error: use of enum ‘LAAW_API’ without previous declaration

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:123: error: invalid type in declaration before ‘{’ token

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:123: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:128: error: ‘ImageExtractionMode_Preview’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:133: error: ‘ImageExtractionMode_UInt8’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:138: error: ‘ImageExtractionMode_UInt16’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:143: error: ‘ImageExtractionMode_Int16’ was not declared in this scope

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:144: error: scalar object ‘Orthanc::ImageExtractionMode’ requires one element in initializer

Resources/Samples/Tools/…/…/…/Core/Enumerations.h:329: error: expected ‘)’ before ‘format’

[user@centos6 Orthanc-0.8.5]$ find . -iname ‘laaw.h’

./OrthancCppClient/SharedLibrary/Laaw/laaw/laaw.h

[user@centos6 Orthanc-0.8.5]$ find . -iname ‘json.h’

./jsoncpp-src-0.6.0-rc2/include/json/json.h

[user@centos6 Orthanc-0.8.5]$ g++ Resources/Samples/Tools/RecoverCompressedFile.cpp -o RecoverCompressedFile -I OrthancCppClient/SharedLibrary/Laaw -I jsoncpp-src-0.6.0-rc2/include

/tmp/cczMxjod.o: In function `main’:

RecoverCompressedFile.cpp:(.text+0xf6): undefined reference to `Orthanc::toolbox::ReadFile(std::basic_string<char, std::char_traits, std::allocator >&, std::basic_string<char, std::char_traits, std::allocator > const&)’

RecoverCompressedFile.cpp:(.text+0x1a3): undefined reference to `Orthanc::BufferCompressor::Uncompress(std::basic_string<char, std::char_traits, std::allocator >&, std::basic_string<char, std::char_traits, std::allocator > const&)’

RecoverCompressedFile.cpp:(.text+0x217): undefined reference to `Orthanc::toolbox::WriteFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const&)’

RecoverCompressedFile.cpp:(.text+0x370): undefined reference to `Orthanc::OrthancException::What() const’

/tmp/cczMxjod.o: In function `Orthanc::BufferCompressor::~BufferCompressor()':

RecoverCompressedFile.cpp:(.text._ZN7Orthanc16BufferCompressorD2Ev[_ZN7Orthanc16BufferCompressorD5Ev]+0x13): undefined reference to `vtable for Orthanc::BufferCompressor’

/tmp/cczMxjod.o: In function `Orthanc::BufferCompressor::BufferCompressor()':

RecoverCompressedFile.cpp:(.text._ZN7Orthanc16BufferCompressorC2Ev[_ZN7Orthanc16BufferCompressorC5Ev]+0xf): undefined reference to `vtable for Orthanc::BufferCompressor’

/tmp/cczMxjod.o: In function `Orthanc::ZlibCompressor::ZlibCompressor()':

RecoverCompressedFile.cpp:(.text._ZN7Orthanc14ZlibCompressorC2Ev[_ZN7Orthanc14ZlibCompressorC5Ev]+0x1f): undefined reference to `vtable for Orthanc::ZlibCompressor’

/tmp/cczMxjod.o: In function `Orthanc::ZlibCompressor::~ZlibCompressor()':

RecoverCompressedFile.cpp:(.text._ZN7Orthanc14ZlibCompressorD2Ev[_ZN7Orthanc14ZlibCompressorD5Ev]+0x13): undefined reference to `vtable for Orthanc::ZlibCompressor’

collect2: ld returned 1 exit status

[user@centos6 Orthanc-0.8.5]$

`

Hi,

I have just pushed some fixes in the mainline to build this project (there were some path problems that prevented its build).

Here is a complete build session that works at least on Ubuntu 12.10:

cd /tmp

hg clone https://s.jodogne@code.google.com/p/orthanc/

cd /tmp/orthanc/Resources/Samples/Tools/

mkdir Build

cd Build

cmake …

make

./RecoverCompressedFile

Maintenance tool to recover a DICOM file that was compressed by Orthanc.

Usage: ./RecoverCompressedFile [output]
If “output” is not given, the data will be output to stdout

HTH,
Sébastien-

This works perfectly, Thanks!
Your instructions are awesome.

I can confirm that it builds also on CentOS 6 (using cmake28 instead of cmake).

Hi Orthanc Community,

I’m encountering some issues while using the OrthancRecoverCompressedFile tool to decode compressed DICOM images. Whenever I attempt to recover any compressed image, I receive the following errors:

pacs@test:~/00/42$ OrthancRecoverCompressedFile 0042142a-36ab-4d25-a5cc-ea76bee7fa53
Reading the file into memory...
Decompressing the content of the file...
Error: The server hosting Orthanc is running out of memory

pacs@test:~/00/42$ OrthancRecoverCompressedFile 00425b1b-3a74-44d8-a48c-96509aab4b5e
Reading the file into memory...
Decompressing the content of the file...
Error: Corrupted file (e.g. inconsistent MD5 hash)

Here are the details of my system setup:

  • Server Specs: 32 GB of RAM, 32-core CPU.
  • Orthanc Version: 1.12.2
  • Operating System: Ubuntu 24.4 LTS

Error Analysis:

  1. First Error (Out of Memory): Despite having 32 GB of RAM and a powerful CPU, I am getting the error:
    Error: The server hosting Orthanc is running out of memory when trying to decode the file.
    This seems to suggest an issue with memory allocation, but my server should be capable of handling this workload without issue.
  2. Second Error (Corrupted File): When trying a different file, I receive the error:
    Error: Corrupted file (e.g. inconsistent MD5 hash).
    This suggests there might be a problem with the file integrity, but I’ve checked the MD5 hash and it appears to be valid.

My Questions:

  • What might be causing the “out of memory” error even though my server has ample resources? Could there be a configuration issue or a problem with the way the decompression process is handling memory?
  • How can I resolve the “corrupted file” error? Is this a sign that the DICOM file itself is damaged, or could there be an issue with how the tool is reading the file?
  • Are there any additional logs or debug steps I should take to help identify the root cause of these issues?

Additional Info:

  • I have verified that my server has sufficient free RAM and CPU resources when running the command.
  • I’ve also tried decoding multiple files with similar results.

I would greatly appreciate any advice or suggestions on how to resolve these issues. Thank you in advance for your help!

Best regards,
Chetan Giri.

Hi,

First question: are your files actually compressed ?
the Error: Corrupted file (e.g. inconsistent MD5 hash) error would appear if the file is not compressed.

Second question: what is the size of the file that generates the out of memory error ?

Best,

Alain