GE Centricity Viewer DVDs of radiology images (PET / MRI) are saved in DICOM format and come with software for viewing the images. In order to use these images in other places, it may be necessary to convert them to a more standard format. I found one guide one sitepoint.com that covered the necessary steps, but I found that a number of details were missing in order to complete a successful installation on Mac OS X.
The following steps are what worked for me:
Install Xcode from App Store
This is a prerequisite for compiling programs.
Here’s a good guide:
Now install dicom support for ruby (in terminal):
$ gem install dicom
This is needed for the following two steps.
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The default install does not include jpeg 2000 support by default, which is needed to work with DICOM files, so you will need to specify the jp2 option when you install it:
$ brew install imagemagick --with-jp2
This is a prerequisite for the next step.
$ brew install pkg-config
Install Rmagick Gem
You may need to adjust the paths to match the current version numbers.
$ sudo C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.1-10/include/ImageMagick-6/ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.1-10/lib/pkgconfig/ gem install rmagick
Doing the conversion
Ruby conversion script
Create the following ruby program in a text editor and save it as dicom-convert.rb. This finds all matching files in the current directory and all subdirectories and converts each one to jpeg format. If the files have a .dcm file extension, use *.dcm, otherwise find a different wildcard (e.g. MRI*) that matches your files.1234567891011121314require 'dicom'include DICOMdcimfiles = File.join("**", “*.dcm")filenames = Dir.glob(dcimfiles)filenames.each do |filename|dcm = DObject.read(filename)dcm_image = dcm.imagedcm_image.normalize.write(filename + ".jpg")endexit
Or if you wish to use the script manually on individual files, you can use:123456789require 'dicom'include DICOMdcm = DObject.read("MRI000001.dcm")dcm_image = dcm.imagedcm_image.normalize.write("MRI000001.jpg")endexit
This is a useful resource if you need to customize the script further: ruby-doc.org
Running the script
Place the program in the root of your DICOM files directory, open terminal, change to that directory,and run the following command:
$ ruby dicom-convert.rb
This was based upon a guide written on Sitepoint.com; however, I found that additional steps were required to get it to work successfully. The sitepoint guide also includes instructions for Windows and Linux.