[Neuroimaging] Nibabel API change - always read as float

Alexandre ABRAHAM abraham.alexandre at gmail.com
Mon Jul 6 22:13:30 CEST 2015


> 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.


Well, unless I am mistaken, there is no ambiguity in the datatype of a
binary file. Plus,  numpy does not enforce anything, it is just a default
value. Using np.genfromtxt(dtype=None), and you get a more logical behavior.
Whatever you do, if you load a npy file using np.load, it will always be of
the type saved in the first place.

Also, numpy does not have to deal with the weirdness of using
> integers plus scale factors to represent floating point data.
>

Well, in that case, why not adding a dtype value in the header ?

Even without scale factors the data in an
> MRI isn't inherently integer data, it was just quantized that way for
> efficiency.
>

Except that Nifti can store other things than MRI data (such as masks,
labels, or any voxel-related value).

Alex.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20150706/2b2c3959/attachment.html>


More information about the Neuroimaging mailing list