nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats

Home Page:http://nipy.org/nibabel/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is support for memory maps discontinued?

Garyfallidis opened this issue · comments

Hi all,

In the past we could use memory maps with ease directly from Nibabel. My understanding is that this is not any more supported.
Is there an alternative approach?

I assume we're discussing spatial images? Here's the breakdown:

  • img.dataobj.get_unscaled() will return a memmap if the data are uncompressed, and will not apply scaling
  • np.asanyarray(img.dataobj) will return a memmap if the data are uncompressed and there are no scale-factors
    • img.dataobj[:] would also work, but is less explicit
  • np.asanyarray(img.dataobj, target_dtype) will return a memmap if the data are uncompressed, with no scaling, in that dtype
  • img.get_fdata(dtype=target_dtype) will return a memmap if the data are uncompressed, with no scaling, in that dtype
    • This will also store a cache of the array on the img object.
  • img.get_fdata() will return a memmap if the data are uncompressed, float64, with no scale factors

Yes. Spatial images. Thank you for the quick response @effigies.