[Neuroimaging] [nibabel] Loading data directly instead of using a memmap

Samuel St-Jean stjeansam at gmail.com
Thu Jan 14 06:24:40 EST 2016


Oh, a simple fix after all, thanks!

2016-01-14 12:14 GMT+01:00 Nathaniel Smith <njs at pobox.com>:

> On Thu, Jan 14, 2016 at 2:28 AM, Samuel St-Jean <stjeansam at gmail.com>
> wrote:
> > Hello,
> >
> > While processing some hcp data, we decided to use directly nifti files
> > instead of using gzipped file as they use quite a lot of ram (there are
> some
> > PRs fixing this under the work in nibabel apparently). So when you load a
> > regular nifti file, it gets a memmap instead of a proper numpy array,
> which
> > does not support the same feature and sometimes ends up producing really
> > weird bugs down the line (https://github.com/numpy/numpy/issues/6750).
> >
> > So, we just ended up casting the memmap to a regular numpy array with
> > something like
> >
> > data = np.array(data)
> >
> > While this works, is it memory usage friendly (hcp data is ~4go after
> all)
> > or does it keep a reference in the background? Is there a better way to
> > achieve similar results, like for example forcing nibabel to load a numpy
> > array directly instead of memmap?
>
> It costs a few hundred bytes of memory, and otherwise will act
> identically except that you lose access to the special mmap methods. I
> wouldn't worry about it :-).
>
> -n
>
> --
> Nathaniel J. Smith -- http://vorpus.org
> _______________________________________________
> 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/20160114/17804f7c/attachment.html>


More information about the Neuroimaging mailing list