help > Range (i.e. Darkest and Brightest values) are not correct when loading a .nii file
Showing 1-4 of 4 posts
Display:
Results per page:
Oct 6, 2020  11:10 AM | makis
Range (i.e. Darkest and Brightest values) are not correct when loading a .nii file
I am using MRIcroGL to visualize some .nii files and I came across a potential bug.

When I load a .nii file the automatically detected "Darkest" and "Brightest" values are not correct. In other words, the range of the values of the nii file is not detected correctly and I have to manually correct them.


Any fix for this?
Oct 7, 2020  12:10 PM | Chris Rorden
RE: Range (i.e. Darkest and Brightest values) are not correct when loading a .nii file
This is a feature. MRIcroGL will clip values below the "Darkest" value and above the "Brightest" value, and linearly scale the intensity between these two values. This like adjusting the contrast and brightness of an image, or in radiological terms the "Window Center" and "Window Width". Setting the minimum for the darkest value in the image and the maximum to the brightest value in the image is typically a bad choice, as it it wildly impacted by outliers. The initial values are set to the "robust intensity range", which minimizes the impact of outliers. This provides much better contrast, brightness for typical images. If you want to override this behavior to use any arbitrary value, simply set the cal_min and cal_max values of your NIfTI header to the values you prefer.

As an aside, on Linux and MacOS if you launch MRIcroGL from the command line, it will report both the full image intensity range and the robust image intensity range to the terminal. For example, with the spmMotor image that comes with the software, the full range is -6.86..+12.1, but the robust range is -1.58..2.976:

int16 range -6.8623576164245605...12.15650463104248
int16 window -1.5804531574249268...2.9761490821838379
Oct 7, 2020  01:10 PM | makis
RE: Range (i.e. Darkest and Brightest values) are not correct when loading a .nii file
Originally posted by Chris Rorden:
This is a feature. MRIcroGL will clip values below the "Darkest" value and above the "Brightest" value, and linearly scale the intensity between these two values. This like adjusting the contrast and brightness of an image, or in radiological terms the "Window Center" and "Window Width". Setting the minimum for the darkest value in the image and the maximum to the brightest value in the image is typically a bad choice, as it it wildly impacted by outliers. The initial values are set to the "robust intensity range", which minimizes the impact of outliers. This provides much better contrast, brightness for typical images. If you want to override this behavior to use any arbitrary value, simply set the cal_min and cal_max values of your NIfTI header to the values you prefer.

As an aside, on Linux and MacOS if you launch MRIcroGL from the command line, it will report both the full image intensity range and the robust image intensity range to the terminal. For example, with the spmMotor image that comes with the software, the full range is -6.86..+12.1, but the robust range is -1.58..2.976:

int16 range -6.8623576164245605...12.15650463104248
int16 window -1.5804531574249268...2.9761490821838379

Thanks for the reply. I just updated my version by installing the pre-release (july 2020) and this issue/feature is not present any more i.e. the min max values correspond to the real ones.
Oct 7, 2020  01:10 PM | Chris Rorden
RE: Range (i.e. Darkest and Brightest values) are not correct when loading a .nii file
The pre-release changes the robust image intensity algorithm to better deal with thresholded images. However, be aware that there are always situations that can disrupt automated contrast/brightness detection. You should not assume the initial displayed intensity range always corresponds to the full range of your data. The software tries to be clever, to show a nice looking image.