Thursday 13 March 2014

Converting CT Data to Hounsfield Units

According to Wikipedia, the Hounsfield scale was invented in 1972 by Godfrey Newbold Hounsfield. His scale is a quantitative measure of radiodensity and is used to evaluate CAT scans. Pixels in an image obtained by CT scanning are displayed in terms of relative radiodensity. 

The pixel value is displayed according to the mean attenuation of the tissue that it corresponds to on a scale from -1024 to +3071 on the Hounsfield scale. Water has an attenuation of 0 Hounsfield units (HU) while air is -1000 HU, bone is typically +400 HU or greater and metallic implants are usually +1000 HU. 

To convert from the normal units found in CT data (a typical data set ranges from 0 to 4000 or so) you have to apply a linear transformation of the data. The equation is:
   hu = pixel_value * slope + intercept
 
The real question is where do you find the slope and intercept used in the conversion?
Normally, these values are stored in the DICOM file itself. The tags are generally called the Rescale Slope and Rescale Intercept, and typically have values of 1 and -1024, respectively.

To show you how to obtain these values, I downloaded a sample CT data set, named CT-MONO2-16-ankle.dcm. This file was created on a GE Medical Systems scanner. After unpacking the compressed file, and adding a dcm file extension to the name (a convenience), I opened the file and dumped the elements to the display.
   IDL> dicomObj = Obj_New('IDLffDICOM', 'CT-MONO2-16-ankle.dcm')
   IDL> dicomObj -> DumpElements
      0 : (0002,0000) : UL : META Group Length : 4 : 188 
      1 : (0002,0001) : OB : META File Meta Information Version : 2 : 0 1 
      2 : (0002,0002) : UI : META Media Stored SOP Class UID : 26 : 1.2.840.10008.5.1.4.1.1.7
     ...
     ...
     50 : (0028,1052) : DS : IMG Rescale Intercept : 6 : -1024 
     51 : (0028,1053) : DS : IMG Rescale Slope : 2 : 1 
     52 : (0028,1054) : LO : IMG Rescale Type : 2 : US
     53 : (7FE0,0000) : UL : PXL Group Length : 4 : 524296 
     54 : (7FE0,0010) : OW : PXL Pixel Data : 524288 : 4080 4080 4080 4080 4080 ...
I found the Rescale Slope and Rescale Intercept as elements 51 and 50. As expected, they had values of 1 and -1024.
Next, I read the data from the DICOM file, and applied the transformation.
 
   IDL> imagePtr = (dicomObj -> GetValue('7FE0'x, '0010'x))[0]
   IDL> MinMax, *imagePtr 
        32   4080
   IDL> image_hu = *imagePtr * 1 + (-1024)
   IDL> MinMax, image_hu
        -992   3056
This image will appear upside down on my display, so I want to reverse the Y direction.
   IDL> image_hu = Reverse(image_hu, 2)
If I just want to see the bone structure (probably a good idea with this ankle image), I can display it like this.
   TV, BytScl(image_hu, Min=600, Max=3000)
The CT image displayed in Hounsfield units.
The bone structure of the CT angle image, displayed in Hounsfield units.
 
Be sure to clean up your pointers and objects.
   IDL> Ptr_Free, imagePtr
   IDL> Obj_Destroy, dicomObj

No comments: