[#9982] Intensity boundary is not calculated for cal_min=cal_max=0

Please log in

State: more information
Open
Date:
2021-10-28 11:07
Priority: more information
3
Submitted By:
spenhouet (spenhouet)
Assigned To: more information
Nobody (None)
Hardware: 
None
Product: 
None
Operating System: 
other
Component: 
None
Version: 
None
Severity: 
normal
Resolution: 
None
Summary: more information
Intensity boundary is not calculated for cal_min=cal_max=0

Detailed description

In the file hippo.nii.gz the cal_min and cal_max are set to 0.
When loading the orig.nii.gz and hippo.nii.gz, then the "Darkest" value is wrong (-128).

Reproduction:
  • Open orig.nii.gz in MRIcroGL
  • Overlay hippo.nii.gz

Expected behavior:

The hippo.nii.gz file should load with "Darkets" set to 0 and "Brightest" set to 5.

Response

Message

Date: 2021-10-28 15:09
Sender: Chris Rorden

Hello
This will be fixed in the next release, alternatively recompile the latest commit on Github:
 https://github.com/rordenlab/MRIcroGL/commit/c755d83a23fd431641807a5769255c7880a0a6f1

The core issue is that your image is saved as INT8. While legal, this is an exceptionally rare data type (indeed, it did not exist in NIfTI's predecessor the Analyze format). This may cause unusual behavior in many tools. I would suggest saving images like this as UINT8 data. Here is a Python script to convert INT8 data types to UINT8:

import nibabel as nib
import numpy as np
fnm = 'hippo.nii.gz'
nii = nib.load(fnm)
img = nii.get_fdata()
nii.set_data_dtype(np.ubyte)
nii = nib.Nifti1Image(img, nii.affine, nii.header)
nii.header['scl_slope'] = 1.0
nii.header['scl_inter'] = 0.0
outnm = 'hippo8.nii.gz'
nib.save(nii, outnm)

Attached Files:

Name Download
orig.nii.gz Download
hippo.nii.gz Download

Changes:

Field Old Value Date By
New Message2021-10-28 15:09crlab
File Added1166: hippo.nii.gz2021-10-28 11:07spenhouet
File Added1165: orig.nii.gz2021-10-28 11:07spenhouet