Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

importing many pictures as canvas - python crashes - garbage collection?

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 the Canvas that you want to show, as you normally would in a trial-based experiment?

    Cheers!
    Sebastiaan

  • 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:

    #prepare the picture (more is not possible to store in the memory of OS)
    var.COR_TOTAL = 0
    import re
    for i in range(214): 
        #eventually have a break
        if (i+1)%20 == 0:
            break_GER.show()
            key, time = space.get_key()
        #load the stimulus
        strings = re.findall('\d+', present_list[i]) #make a list of all numbers in the name
        present = canvas()
        path = pool['Folie'+strings[0]+'.tif']
        if strings[1] == '1':       #rotate the image to have all 4 directions
            present.image(path,rotation=rotate[0])
        elif strings[1] == '2':
            present.image(path,rotation=rotate[1])          
        present.image(path2, y=400) #answer buttons in picture
    
    #present the fixation dot and the stimulus
        fixate.show()
        #clock.sleep#(995) #forum does not like clocksleep :)
        stim_time = present.show()
        #get response
        key, time = target.get_key()
        var.Stim = str(present_list[i])
        print var.Resp, var.Stim
        if   'COR' in present_list[i] and key=='x':
            var.Cor = 1
        elif 'COR' in present_list[i] and key=='m':
            var.Cor = 0 
        elif 'FAL' in present_list[i] and key=='m':
            var.Cor = 1
        elif 'FAL' in present_list[i] and key=='x':
            var.Cor = 0
        var.COR_TOTAL = var.COR_TOTAL + var.Cor
        var.COR_PERC = float(var.COR_TOTAL) / float(i+1) *float(100)
        var.RT = time - stim_time
        print var.COR_TOTAL, var.Resp, var.COR_PERC
        log.write_vars()
    
  • 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:

    • if you separate your loop in two loops same issues? Like for 0 to 110 then from 110 to the end?
    • if you use xrange instead of range same issue?

    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.

  • Right, I see now. By default, OpenSesame forces garbage collection after each sequence, to avoid unpredictable delays due to the garbage collection kicking in unexpectedly. However, in your case this is no good, because everything happens inside one big script. If you re-enable the automatic garbage collection in the general properties tab, does the issue go away?
  • Nice, this works.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games