[Neuroimaging] Nibabel API change - always read as float
moloney at ohsu.edu
Tue Jul 21 20:28:12 CEST 2015
> Yes, I guess you would have to either go through float64 or handle the
> scaling yourself. But isn't that just:
> data = data.astype(np.float32) * scale + inter?
If you just want your code to work with Nifti then I think the full code would be something like:
data = img.get_data(as_float=False)
slope = img.dataobj.slope
if np.isnan(slope) or slope == 0:
slope = 1.0
inter = img.dataobj.inter
inter = 0.0
data = data.astype(np.float32) * scale + inter
If you want your code to work with other image types besides Nifti I guess this gets slightly more complex.
More information about the Neuroimaging