[Neuroimaging] Nibabel API change - always read as float

Bertrand Thirion bertrand.thirion at inria.fr
Mon Jul 6 18:32:10 CEST 2015


+1 we (and more importantly, our students) should rely as much as possible on the standard behavior of numpy arrays and make adequate decisions, rather than having to figure out the details of the API of neuroimaging libraries. So the defaut should be unchanged. 

Bertrand 

----- Mail original -----

> De: "vanessa sochat" <vsochat at stanford.edu>
> À: "Neuroimaging analysis in Python" <neuroimaging at python.org>
> Envoyé: Lundi 6 Juillet 2015 18:24:46
> Objet: Re: [Neuroimaging] Nibabel API change - always read as float

> 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 like:

> 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 >
> wrote:

> > Hi,
> 

> > 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 numpy,
> 
> > > and more ready/capable to debug their error.
> 

> > Basically any numpy operation on the returned array can give you weird
> > errors.
> 

> > 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
> > > support
> 
> > > 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'.
> 

> > Cheers,
> 

> > Matthew
> 
> > _______________________________________________
> 
> > Neuroimaging mailing list
> 
> > Neuroimaging at python.org
> 
> > https://mail.python.org/mailman/listinfo/neuroimaging
> 

> --
> Vanessa Villamia Sochat
> Stanford University
> (603) 321-0676

> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20150706/b0b494d3/attachment.html>


More information about the Neuroimaging mailing list