[pymvpa] MemoryError

Yaroslav Halchenko debian at onerussian.com
Sun Jun 27 03:32:17 UTC 2010


On Sat, 26 Jun 2010, McKell Carter wrote:

> Yes, 32K after masking. The full image size is 48X58X49.
cool -- I guess you've hit the bug in libnifti... damn you ;-)

here is my silly snippet to reproduce:

from nifti import NiftiImage
import numpy as np

def check(s, ni):
    print "%s saving/loading" % s
    fn1s = np.where(ni.data[:, 1,1,1] != 1)[0]
    if len(fn1s):
        fn1 = fn1s[0]
        print [(i, ni.data[i, 1,1,1]) for i in (fn1-1, fn1)]
    else:
        print "everything 1s"

size=(48, 59,49, 15000)
print "Size ", size
ni = NiftiImage(np.ones(size[::-1]))
ni.save('/tmp/ones.nii.gz')
check('before', ni)

del ni
ni = NiftiImage('/tmp/ones.nii.gz')
check('after', ni)

nidr = ni.data.ravel()
# silly way but what a heck ;)
print "first non-1 ", np.where(nidr!=1)[0][0]


it outputs:

Size  (48, 59, 49, 15000)
before saving/loading
everything 1s
after saving/loading
[(3393, 1.0), (3394, 0.0)]
first non-1 470907264

more fun came when I changed first dimension size to 25:

In [1]: ## working on region in file /home/yoh/.tmp/python-10698W9c.py...
Size  (25, 59, 49, 15000)
** ERROR: NWAD: wrote only 83065408 of 83065408 bytes to file
before saving/loading
everything 1s
after saving/loading
++ WARNING: nifti_read_buffer(/tmp/ones.nii.gz):
   data bytes needed = 83065408
   data bytes input  = 83065408
   number missing    = 0 (set to 0)
[(143, 1.0), (144, 0.0)]
first non-1  10383176


as to me it makes somewhat little sense ;)

in any case -- we will look into it.  From a quick look I don't see where
we could be possibly hitting the limit here:

http://nifti.nimh.nih.gov/board/read.php?f=1&i=2357&t=2356

-- 
                                  .-.
=------------------------------   /v\  ----------------------------=
Keep in touch                    // \\     (yoh@|www.)onerussian.com
Yaroslav Halchenko              /(   )\               ICQ#: 60653192
                   Linux User    ^^-^^    [175555]





More information about the Pkg-ExpPsy-PyMVPA mailing list