[Neuroimaging] Nibabel API change - always read as float

Matthew Brett matthew.brett at gmail.com
Mon Jul 6 23:54:28 CEST 2015


On Mon, Jul 6, 2015 at 10:33 PM, Brendan Moloney <moloney at ohsu.edu> wrote:
>> I think the dtype argument is OK, it may be better than `asfloat`. It
>> starts becoming a little complicated having to deal with all possible
>> output types - for example rounding float to ints is not as
>> straightforward as it may seem (for example you have to clip the
>> output so as not to overflow the ints).
>
> I think it is fine, maybe even preferable, to raise an exception is these
> situations. Even then I agree that it complicates things.

I suppose it is possible to argue that

data = img.get_data(asfloat=False).astype(np.float32)

or

data = np.array(img.dataobj).astype(np.float32)

is not too bad for the float32 case, given that it is a little specialized.

Matthew


More information about the Neuroimaging mailing list