[Neuroimaging] Nibabel API change - always read as float
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.
On Tue, Jul 21, 2015 at 1:22 AM, Matthew Brett <matthew.brett at gmail.com>
> On Mon, Jul 20, 2015 at 11:42 PM, Alexis Roche <alexis.roche at gmail.com>
> >> 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
> > 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?
> Neuroimaging mailing list
> Neuroimaging at python.org
Lead Clinical Research
Advanced Clinical Imaging Technology
1015 Lausanne, Switzerland
Phone: +41 21 545 9972
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Neuroimaging