[Neuroimaging] Nibabel API change - always read as float

Gael Varoquaux gael.varoquaux at normalesup.org
Tue Jul 7 01:40:27 CEST 2015


On Mon, Jul 06, 2015 at 04:24:33PM -0700, Michael Waskom wrote:
> I don't think the people in favor of Matthew's proposal are saying this. I
> think they are saying that the negatives of `dtype=None` (serious, silent
> failures) outweigh the negatives of `dtype=float` (people who want to do
> something specific have to pass an explicit parameter in their code).

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.

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

Nibabel is a low-level I/O library. It has no notion of how the data is
going to be used, and should therefore do as little as possible to the
data. There are other libraries to do the rest. People using nibabel and
get_data should be aware of these things. Just like they should be aware
of floating point errors:

    In [1]: .1 + 1 - 1
    Out[1]: 0.10000000000000009

    In [2]: 1 - 1 + .1
    Out[2]: 0.1

Trying to find rules to mitigate problems of arithmetics on computers is
bound to fail: the problems are not solvable, unless with know something
about of the numbers are going to be used.

Gaël


More information about the Neuroimaging mailing list