[Insight-developers] NIfTI char images with slope/intercept value rescale not being read in correctly -- my proposed fix

kent williams norman-k-williams at uiowa.edu
Thu Sep 13 10:25:44 EDT 2007


Richard Beare posted to the Developer's List that he was getting all-black
probability images with the ImageViewer app.

He sent me a NIfTI file that illustrates the problem is this: The pixel type
is char, but the slope is 0.003922. In other words the pixels on disk are in
the range 0..255 but the pixel values should be in the range 0.0..1.0.

The only fix I can see is this:

1. In ReadImageInformation, record the actual on-disk pixel type, but report
FLOAT in m_ComponentType.  This will force ImageFileReader to allocate it's
pixel buffer as float, not char.

2. After reading the char data from disk, upcast each pixel to float and
copy to the float buffer.  Then the pixel value Rescale function will work
in floating point.

There really isn't any alternative to this that I can see. Obviously at
least one person is seeing these char + rescale to 0.0..1.0 files in the
wild, and reading them in as all zeros isn't very helpful.

This is perhaps too late for 3.4, but if the gatekeepers think this change
is important enough to slip in, I can send the changes and add a regression
test.  Unfortunately I'll have to write out a test file with niftilib and
not ITK, since ITK would have no way to write out such a file.



More information about the Insight-developers mailing list