importing many pictures as canvas - python crashes - garbage collection?
in OpenSesame
When reading in 100 pictures and building up 400 canvas for an experiment, i get many python crashes. Sometimes i get error messages like 'out of memory' without changing the code. I found the garbage_collection discussion. However, i am not familiar with this function and i do not know where i need to set the gc.enable() into my code.
Any suggestions?
Here is the code:
#import gc
#gc.enable()
tar = canvas()
path2 = pool['targets.tif']
#tar.image(path2)
rotate = [0,90,180,270]
COR_list = []
for i in range(38): #number of correct stim
for j in range(4): #4 types of rotations
COR_list.append('COR_'+str(i+1)+'_'+str(j+1))
COR_list[i+j] = canvas()
path = pool['Folie'+str(i+1)+'.tif']
#rotate the image to have all 4 directions
COR_list[i+j].image(path,rotation=rotate[j])
COR_list[i+j].image(path2, y=400)
FAL_list = []
for i in range(69): #number of false stim
for j in range(4): #4 types of rotations
FAL_list.append('FAL_'+str(i+1)+'_'+str(j+1))
FAL_list[i+j] = canvas()
path = pool['Folie'+str(i+40)+'.tif']
#rotate the image to have all 4 directions
FAL_list[i+j].image(path,rotation=rotate[j])
FAL_list[i+j].image(path2, y=400)
I know i need to reduce the number of stimuli. But i would like to select the most suited by using human data.
Comments
Hi,
The problem here is that you're preloading all
Canvas
objects. But I suspect that this isn't necessary. What exactly is the paradigm? Is it not possible to selectively prepare theCanvas
that you want to show, as you normally would in a trial-based experiment?Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
I now created a list of names. And based on this list i kind of overwrite the same canvas object 214 times (I have 214 images). However, it always get's stuck at i=115. Any idea why?
Here is part of the code:
Stuck means: Nothing goes. I need to open the task manager to shut down OpenSesame.
Not even Escape button works.
Hello,
I will not probably be able to help but I am curious:
Sylvain
Unfortunately, it did not help.
With xrange it stopped after i=58
With two seperate loops range(107) and range(107,214) it stopped after i=111
I tested the original range(214) twice and it stopped after i=115
For the new runs i closed OpenSesame and opened the experiment again.
Check out SigmundAI.eu for our OpenSesame AI assistant!
Nice, this works.