[Neuroimaging] Nibabel API change - always read as float

Matthew Brett matthew.brett at gmail.com
Mon Jul 6 18:30:34 CEST 2015


Hi,

On Mon, Jul 6, 2015 at 5:24 PM, vanessa sochat <vsochat at stanford.edu> wrote:
> I don't like the modification, because there are plenty of images that
> should be returned as int16. b

There are certainly some images like that, but in my experience a
large majority of images stored on disk as int16 are stored that way
to conserve disk space.    For example, structural or functional
images are usually stored as int16, but we will nearly always want to
use floating point on them.

To help, can anyone come up with a realistic case where casting to
float64 will in fact case a bug, even for mask or label images?

> It's much more reasonable to have a workflow
> like:
>
> data = img.get_data()
>
> *look at, think about, your data*
> *make decisions* (cast as float, don't, etc)

I guess I'm repeating myself, but I don't want to force that need on
beginning users, as we do now.

> Possibly we can have an intermediate solution of leaving the default
> behavior and adding a to_float parameter, as Christopher suggested. But I'm
> not sure how that is any better or different than float(data).

Yes, there's no point in the parameter if it is not going to be the default.

Cheers,

Matthew


More information about the Neuroimaging mailing list