[Neuroimaging] Nibabel API change - always read as float

Alexis Roche alexis.roche at gmail.com
Mon Jul 20 22:14:34 CEST 2015


Exactly - but I think that what makes the situation ambiguous is to
consider the "intent" of whoever created the nifti file. It may not be
relevant because the nifti norm does not allow to make such intent explicit
anyway...

Having said that, I would be totally happy if the load function would take
a dtype keyword argument, which could default to float (fair enough), but
would leave me the possibility to load my data as unsingned int16 if I want
to (of course, without loading a float array first) and would issue a
warning if that entails information loss (e.g. because of a non-integer
slope). Even better, have the option to pass in `dtype='native'` or
something like that, and get the array in the same format as on disk if
slope and offset permit, an error otherwise.

I guess this whole discussion would then boil down to whether the default
dtype should be float or 'native'. But what really matters is the intent of
the user.

Alexis
 Le 20 juil. 2015 13:34, "Matthew Brett" <matthew.brett at gmail.com> a écrit :

> On Mon, Jul 20, 2015 at 11:46 AM, Alexis Roche <alexis.roche at gmail.com>
> wrote:
> > Hi Matthew,
> >
> > I think that, if the data is int on disk with scale factors are (0,1),
> then
> > the intended dtype is more likely to be int than float - in the sense
> that
> > there is no obvious reason for casting the data to float, but it's more
> > efficient to keep it as int.
>
> Put another way - I can see there is a argument that int is the
> best-guess at the intended dtype here - although I don't think that
> argument is correct.
>
> However, to me it seems clear that this is a guess in the face of
> ambiguity and:
>
> "In the face of ambiguity, refuse the temptation to guess."
>
> Matthew
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20150720/f5fc01b8/attachment.html>


More information about the Neuroimaging mailing list