[Neuroimaging] Nibabel API change - always read as float
Brendan Moloney
moloney at ohsu.edu
Mon Jul 6 21:49:21 CEST 2015
> Sorry for being unclear, but Numpy would never force casting when
> loading data.
Numpy does "force" casting when the original data type is not completely
clear. For example point the 'loadtxt' function at a text file containing all
integers. Also, numpy does not have to deal with the weirdness of using
integers plus scale factors to represent floating point data.
> When you get some array, you need to be aware of what it is in order to
> work with it. A mask or label image is not meant to be something on
> which you perform algebraic manipulations. Sure, you can get it wrong if
> you don't know what you're doing, but either this user has to learn it
> or he/she should consider using higher level interfaces to work with images.
It really isn't as simple as knowing if your image is a mask or label image.
Most regular images will load as int16 unless the scale factors are used,
and it isn't always obvious. Even without scale factors the data in an
MRI isn't inherently integer data, it was just quantized that way for
efficiency.
In the obvious case of loading a mask or label image, it isn't too hard to
pass the correct 'dtype' to the load function. Just like you would do if your
mask was stored in a text file and you used numpy 'loadtxt' function.
-Brendan
More information about the Neuroimaging
mailing list