[Neuroimaging] Nibabel API change - always read as float
abraham.alexandre at gmail.com
Mon Jul 6 18:38:27 CEST 2015
For all the reasons mentioned above, I also think that it's a bad idea. As
a regular user of nibabel for big data, this would be a burden for me
espacially because, when we cast to float, we chose float32 to save as
memory as possible (most of the time, float64 precision is not needed and
it costs a lot).
Speaking of beginners, I think that it is better to warn them, rather to
set up guards everywhere. This problem is not nibabel specific: it is numpy
(and even python) specific. I think that teaching them to _always_ cast
their data to float unless they know what they're doing is a good idea.
Better, np.seterr() is here to help you set overflow as errors.
On Mon, Jul 6, 2015 at 6: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. It's much more reasonable to have a workflow
> data = img.get_data()
> *look at, think about, your data*
> *make decisions* (cast as float, don't, etc)
> 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).
> On Mon, Jul 6, 2015 at 9:13 AM, Matthew Brett <matthew.brett at gmail.com>
>> On Mon, Jul 6, 2015 at 5:03 PM, Ben Cipollini <bcipolli at ucsd.edu> wrote:
>> > I agree with Gael.
>> > I would also add, it also seems to be solving a problem that doesn't
>> seem to
>> > exist in the wild. There's never a report of hitting this issue, right?
>> > Users using sum() or other raw operations are likely familiar with
>> > and more ready/capable to debug their error.
>> Basically any numpy operation on the returned array can give you weird
>> I did precisely run into this when teaching the students. I was
>> teaching them to run diagnostics, and the script I wrote used the sum.
>> This worked fine on one set of functional images, but gave a
>> completely wrong answer on another set of images, and it took me a
>> little while to work out what had gone wrong. Part of the problem is
>> that nifti images are often int16, so it's easy to run into silent
>> horrors just by adding or subtracting. My feeling is that dealing
>> with any operations on int16 arrays is for advanced users. Advanced
>> users will know to do `to_float=False`.
>> > Adding complexity can potentially introduce confusion for all users,
>> > including relatively numpy-naive ones. Then we potentially have to
>> > new questions, and I'm not sure there's any practical benefit.
>> I think this is reducing complexity for basic use (you don't have to
>> think about your data types, until you want to think about your data
>> types). At the moment, when you see this:
>> data = img.get_data()
>> you have to think 'oh wait, at the moment I can't easily predict what
>> data type this is. If I want to do stuff with this array, I will
>> probably have to cast to float for safety'.
>> Neuroimaging mailing list
>> Neuroimaging at python.org
> Vanessa Villamia Sochat
> Stanford University
> (603) 321-0676
> Neuroimaging mailing list
> Neuroimaging at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Neuroimaging