[Neuroimaging] Nibabel API change - always read as float

Alexis Roche alexis.roche at gmail.com
Tue Jul 21 19:41:39 CEST 2015


OK, that will do the trick with a fairly light syntax.

Looks like a reasonable change overall.

Alexis

On Tue, Jul 21, 2015 at 1:22 AM, Matthew Brett <matthew.brett at gmail.com>
wrote:

> Hi,
>
> On Mon, Jul 20, 2015 at 11:42 PM, Alexis Roche <alexis.roche at gmail.com>
> wrote:
> >
> >> Can you think of a common use of an arbitrary dtype here?  I mean
> >> dtype not equal to the on-disk dtype or the scaled dtype?   It seems
> >> as if that use might be rather specialized - could it be done in the
> >> user code that starts with the code above?
> >
> >
> > Right. I can think of the following cases:
> > * a mask image encoded in int16 on disk, but you want an array of
> booleans
> > in memory (nifti does not support boolean format)
>
> I guess you can assume no scalefactors?  Then:
>
> data = img.get_data(as_float=False).astype(np.bool)
>
> That is as memory-efficient as you can do that, I think.
>
> > * an image of positive-valued MR parameters encoded in int, but you want
> > unsigned int in memory
>
> > Of course, that could be done via the 'dataobj' attribute, which requires
> > advanced knowledge of nibabel I think. I don't think this is very
> > specialized usage.
>
> Same idea if no scalefactors.  If you do have scalefactors, and you
> don't want them applied, yes, you'll have to use
> `img.dataobj.get_unscaled()` for that, but it does seem pretty
> specialized to throw away scalefactors in that situation.
>
> Or did you mean that `get_data` also has to take care only to load
> small parts of the image at a time, and apply scalefactors, and then
> cast that part of the array?
>
> Cheers,
>
> Matthew
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>



-- 
Lead Clinical Research
Advanced Clinical Imaging Technology
Siemens/CHUV/EPFL
1015 Lausanne, Switzerland
Phone: +41 21 545 9972
https://sites.google.com/site/alexisroche
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20150721/22868c39/attachment.html>


More information about the Neuroimaging mailing list