Hu units, slope and intercept in nifti images


Im new here so sorry if im asking something stupid.

I have a database with lungs ct in nifti1 format and I want to use them to train a neural network. Some of them like lets say file1 have a datatype uint16 while others like file2 have a datatype int16.

The slope and intercept based on image.dataobj.slope and image.dataobj.inter are 1 and 0 respectively for both images.

This implies if I understand correctly that they are Hounsfield units but when I read the data the first file array data ranges from 0 to 4095 and the second file array data ranges from -2000 to 2481.
These data dont seem correct to me for Hounsfield units of a lung ct.

How can I convert them to appropriate Hounsfield unit ranges since I don’t know the slope and intercept?

Thanks in advance!

As you note, CT scans image intensity should be in calibrated Hounsfield units, which should be roughly -1000 for air, +1000 for bone, 0 for water and in the range of 20-40 for soft tissue (though brighter if the tissue is perfused with Gd).

  1. First of all, I would check that your NIfTI reading software is correctly reading the scale slope and intercept. From the command line use fslhd myFile.nii to see the values, for Philips data I would expect:
scl_slope	1.000000
scl_inter	-1024.000000
  1. If you have access to the DICOMs, you can use dcmdump myDICOM.dcm to determine the Rescale intercept, (0028,1052)rescale slope (0028,1053) which should be directly mapped to the NIfTI scl_inter and scl_slope.

  2. If you have access to the DICOMs, you may want to convert the images to NIfTI using dcm2niix. While any DICOM to NIfTI tool should preserve scale slope and intensity, to my knowledge dcm2niix is the only tool to handle CT specific information like gantry tilt. See here for examples.

  3. If all of this fails, you may want to consider using a simple algorithm to estimate the proper values. In theory, no voxels should be darker than -1000, though some manufacturers use -1024. You also need to be aware that the CT scanner generates a cylinder shaped volume, but the data is saved in a box-shaped volume. Some manufacturers make the upsampled voxels outside the scanning radius artificially dark. Finally, one could would expect the brightest voxels to be near the range +1000. However, this assumption is impacted by items like gold tooth fillings. I would guess the fsl robust range would provide a good threshold for rescaling.

1 Like

Thanks for your reply!

I found the original dataset and as you said it has a slope of 1 and intercept -1024.

thanks again!