mason
mason

Reputation: 47

DICOM File compression

My line of work requires the use of DICOM files. Each DICOM file constitutes many .dcm files in a single directory. I am required to send these files over the network, a process which is somewhat so due to the massive size of the files. I am also a programmer and I was wondering what is the ideal way to compress such files? I'm talking about a compression that will be made on the local computer and later decompressed on the destination computer (namely the compression is solely for speeding up the over-the-network transfer of the file). Is there a simple way to crop the DICOM files? (the files contain imaging of an entire head, whereas I'm only interested in a small part of the head).

Thanks!

Upvotes: 3

Views: 15545

Answers (5)

Floris
Floris

Reputation: 46435

I would recommend using rsync to send the files, using the -z option. This will automatically compress the files before transmission, and uncompress at the other end. The process is lossless and transparent.

I ran a little test on some dicom data that I have (a folder with about 6000 files in it - each one dicom slice).

When I do:

rsync -azvh --include='*.dcm' --exclude='*' --progress . temp1

I get:

sent 766.42M bytes  received 133.80K bytes  10.43M bytes/sec
total size is 1.97G  speedup is 2.57

While when I don't compress (no z flag)

rsync -avh --include='*.dcm' --exclude='*' --progress . temp2

the result is

sent 1.97G bytes  received 133.80K bytes  87.46M bytes/sec
total size is 1.97G  speedup is 1.00

As you can see, this is a quick and easy way to get a significant gain. If your computer is fast and your network slow, this is probably one of the easiest ways to speed things up.

(Note - this works on Mac and Linux systems; I am not sure if this works on Windows, or what the equivalent would be.)

Upvotes: 0

malat
malat

Reputation: 12510

Solution:

gdcmconv --jpeg uncompressed.dcm compressed.dcm

or for better compression ratio:

gdcmconv --jpegls uncompressed.dcm compressed.dcm

See: http://gdcm.sourceforge.net/html/gdcmconv.html

I would also recommend against lossy compression, you would need to be a DICOM wizard to do it properly (see derivation mechanism in the DICOM standard). I would also recommend against cropping the image (you would need to regenerate UIDs, get the Frame or Reference updated...)

HTH

Upvotes: 3

mostlydev
mostlydev

Reputation: 723

We have a compression router called "DICOM Shrinkinator" that can do this as it transmits the study to PACS:

http://fluxinc.ca/medical/dicom-shrinkinator/

Upvotes: 1

Ofek Shilon
Ofek Shilon

Reputation: 16207

In medical context, lossy compression is somewhere between not encouraged and forbidden. If you'd insist on cropping existing datasets the standard demands you to form at least new image & series UIDs. The standard does allow losless compression in the form of jpeg2000, but it is quite rare - if I had to bet I'd say your dataset is uncompressed altogether.

In my experience it is significantly better to compress a medical dataset as a solid archive - that is, unify all the images into a single stream. This makes a lot of sense, as there is typically a lot of similarity between nearby images and this is the way to take advantage of that similarity (a unified compression dictionary). This is available as a command line option both to rar and gzip compressors.

Upvotes: 5

Adam Shiemke
Adam Shiemke

Reputation: 3742

You could use something simple like lzma compression on one end to pack up the files and send them over. This is the easiest solution, since you can grab something like gzip and pack/unpack the files easily programmaticly. This may help considerably, because modern computers prefer transmitting/receiving one large file over many small files (a single 1GB file will transfer much faster than 10000 100KB files).

As for actually reducing the aggregate size, each .dcm file is probably a slice (if you're looking at something like MRI or CT data), and the viewer you are using reconstructs the slices into the 3d image. Cropping them isn't impossible, but parsing the DICOM format is a bit tricky. I'm not aware of any free programs that will help you parse the DICOM files, but I haven't looked for some time.

Since DICOM is a container format, the image data you are after is usually stored in a common format (such as JPEG), so if you are able to grab the relevant part of the file to extract the image data, you can use any of the loads of image processing tools available to crop the image to whatever dimensions you choose.

Upvotes: 1

Related Questions