[Neuroimaging] Nibabel API change - always read as float

Matthew Brett matthew.brett at gmail.com
Mon Jul 6 17:53:03 CEST 2015


Hi,

On Mon, Jul 6, 2015 at 4:46 PM, Blaise Frederick
<blaise.frederick at gmail.com> wrote:
> That seems reasonable.  It might also add clarity to define:
>
> img.get_native_data()
>
> which was just an alias of
>
> img.get_data(to_float=False)
>
> That would have the advantage of making it immediately obvious what the code was doing (not that the other way doesn’t).

The problem there is that the user might expect `get_native_data()` to
always return the raw data on disk, but in fact it will only return
the raw data on disk if the scalefactors are also default values (1,
0).   You can currently get the raw data on disk with:

data = img.dataobj.get_unscaled()

- but only if `dataobj` is a data object, rather than an array (it is
a data object if you load an image from disk).

Cheers,

Matthew


More information about the Neuroimaging mailing list