[visionegg] Re: pre-loading a large number of stimuli

Another suggestion would be to extract the image data from the PIL file yourself (making Numeric/numarray arrays of the data). This way, you would control the file opening/closing, and only the image data would be in RAM.

As an aside, which is probably not important since I think you load the images before the experiments begin: Right now, I think this process would involve a copy of the RAM involved [using Numeric.fromstring(image.tostring())], but eventaully the "array interface" being specified by Travis Oliphant and others in the Numeric world should make its way to PIL, allowing the raw memory to be shared between different views, such as PIL, numarray, and Numeric.

Cheers!
Andrew

Nick Knouf wrote:
Hi everybody,

(note: this will probably be the beginning of a large barrage of questions as I try and implement a standard blocked design fMRI experiment in VisionEgg)

I'm trying to pre-load a large number of stimuli for an experiment; say, on the order of up to 400 or so. My loop to load the stimuli is the following (taken out of context):

stimuli = []
for condition in filelist:
texture_list = [Texture(filename) for filename in condition]
stimuli.append([TextureStimulus(anchor = 'center', position = (round(position[0]), round(position[1])), texture = texture, size = texture.size, texture_min_filter = gl.GL_LINEAR) for texture in texture_list])


(filelist is a list of images to load, indexed first by condition, next by image; in this case, it's a list of dimensions 4 by 80)

It seems to bomb out at around 200 images, however, giving the following error:

2005-08-15 20:13:16,390 (7856) CRITICAL: Traceback (most recent call last):
File "test_rsvp.py", line 65, in ?
File "/Users/nknouf/Development/VisionEgg_work/nklab/experiments/ common.py", line 67, in createTexturesFromFilelist
File "/Users/Shared/Library/Python/2.3/lib/python2.3/site-packages/ VisionEgg/Textures.py", line 171, in __init__
File "/Users/Shared/Library/Python/2.3/lib/python2.3/site-packages/ PIL/Image.py", line 1717, in open
IOError: [Errno 24] Too many open files: '2 objects/gun 25.tif'


Looking at the source for PIL.Image, it appears to be running into the per-user open-file limit (since it runs the standard-library "open") command. I know that PILs open command only creates a file- handle, and actual reading of the data is deferred until later.

Is there a way to force PIL, through VisionEgg, to read the file when creating a Texture() object, such that I don't exceed the open file limit? I know I could simply increase the limit, but I'd rather not do that.

Thanks,

nick knouf
lab manager, kanwisher lab

PS BTW, is there a reason why all of the demos use " texture_min_filter = gl.GL_LINEAR" as a keyword argument to TextureStimulus, especially since the help information says that texture_min_filter already defaults to gl.GL_LINEAR?
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html


--
Andrew D. Straw  Post-doctoral scholar
,-.              Dickinson Lab
\_/              California Institute of Technology
8||}             Mailcode 138-78
/ \              Pasadena CA 91125, USA
`-^
                 email:  astraw@xxxxxxxxxxx
                 office: +1 626 395 4396

======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: