Handling of DICOM data is a mandataory but  tricky task in medical image processing. This is especially true when it comes to volumetric 3-D data. The most common and supported format for storing 3-D data using DICOM is to partition the volume into slices and to save each slice as a simple DICOM image. The slices can be distinguished either by a number coding (e.g. slice.001, slice.002,…) in the file name or by specific DICOM tags.

However, this format easily becomes a pain as it requires to store hundreds of single files. The goal of this article is to provide a solution for that problem but still to remain a large compatibility with existing software. The solution: just zip it up! I agree, this sounds simple but provides all the required functionality. It is a single file, zip-files are highly portable and are available on almost all platforms, plus we get a nice compression for free.

Of course we won’t zip our data by hand! In this article I will provide a Matlab routine which allows to store and read volume data using the above technique.  In an upcoming article I will provide C/C++ code, too.  Here we go: The two functions are called dicomreadvolume() and dicomwritevolume(). They require you to have the Matlab image processing toolbox installed. An example session for storing and reading the 3-D Shepp-Logan phantom with an anisotropic voxel size of [0.25mm 0.25mm 0.5mm] could look like this:

  1. % create phantom data
  2. V = phantom3d(128);
  3. V = uint8(255.*V); % convert to uint8
  4.  
  5. % save the dicom volume
  6. dicomwritevolume(shepplogan.zip‘, V, [0.25 0.25 0.5]);
  7.  
  8. % read in the dicom volume again
  9. [V2 VS] = dicomreadvolume(shepplogan.zip);
  10.  
  11. % V2 contains the volume
  12. % VS contains the voxel size

 
I hope this code helps some of you out. It comes in handy for me in an every day usage :-). In an upcoming article I will provide you with some equivalent C++ code. So look out for more!

An up-to-date download is available at MATLAB Central.