[Neuroimaging] Nibabel API change - always read as float

Matthew Brett matthew.brett at gmail.com
Tue Jul 7 07:54:57 CEST 2015


On Tue, Jul 7, 2015 at 2:23 AM, Brendan Moloney <moloney at ohsu.edu> wrote:
>
>> No: dtype=float by default will create other serious silent failures,
>> like the fact that round-trip save/load will change the data. This is
>> pretty bad behavior. Certainly not one that I would expect.
>
> I don't think this is true, provided you use the same Nifti header or
> create an appropriate new header. The situation is the same now if the
> scale factors are set.

Right - same argument as above.   Currently, anytime there are
not-default slope and offset, nibabel will load as float, and
recalculate slope, offset on save.   Again, whether this will happen
depends on the usually-arbitrary choice that the image author made of
dtype and slope and intercept.  So the change would have the benefit
of making this predictable rather than unpredictable.

>> This has implication on data processing: density estimation should be
>> done differently on a set of continuous values than on a set of integers
>> (histogram vs kernel smoothing).
>
> This goes both ways. If you wrote some code like this that assumes you
> have integer values it will fail mysteriously when the file has the scale
> factors set.

Right.  Of course there is a difference between the processing of ints
and floats, and that's exactly why we should not - by default - inject
that difference on the basis of settings in the header that are not
designed or (usually) used to make that distinction.  The distinction
should be make consciously by the user.   Explicit is better than
implicit, where the current algorithm (that I chose a long time ago
without much thought) is dangerously implicit.

Cheers,

Matthew


More information about the Neuroimaging mailing list