Howdy, Stranger!

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

Supported by

[open] Pictures to pool

edited December 2015 in OpenSesame

Greetings !

I'm conducting an experiment which includes about 400 pictures divided into two groups.
The pictures on the first group suppose to appear throughout the experiment randomly and without repetition (i.e. a pic that has been presented from this group will not be presented again), and the pictures from the 2nd group will be presented randomly and each one of them will be shown twice throughout the experiment. it would be best if I could place two folders each containing one group's pictures into the pool, but since it's impossible (cannot save the project while folders are in the pool) my questions are :

  1. Whether it's possible to program opensesame to approach a certain folder (inside or outside the pool) whenever it encounters a certain condition and each time pick a photo from there, without my having to drag 400 pics into the pool and give each a different name ?
  2. What instructions should I use to guide it to pick randomly without repetition from one group's folder, and randomly with 1 repetition per photo on the other group's folder ?

thanks in advance for supporting


  • edited December 2015

    Hi Marina,

    As long as the files are in the same folder as is the experiment, you don't have to drag them into the file pool. When calling exp.get_image(filename), you should be able to access the images. (e.g. like so: (my_canvas.image(exp.get_file('my_image.png'))).

    To pick the right images in a correct way, I recommend using an inline_script and prepare lists with the file names in beginning. That makes it easier to pick the right images later. Something along these lines should work;

    import random
    group1 = ['imagesg11.png','imagesg12.png',...,'last_image.png']
    group2 = ['imagesg21.png','imagesg22.png',...,'last_image.png']
    trials = []
    no_trials = 400
    for i in range(no_trials):

    So, the list trials will contain all the file names for your images. You just have to loop over the list a present every image.

    Does this make sense?


  • edited 1:49AM

    Hi Eduard,
    Thank you so much for your response,
    I will try and run it as you suggest and let you know if it is solved.

    Thank you ;;)

  • edited 1:49AM

    Hi Eduard,

    I've been trying to place my pictures in the same folder as the experiment,
    but within the opensesame folder on my computer there are no folders which contain my experiment. Trying to trace the source of the pool folder leads me to C:\Users\User\appdata\Local\Temp
    which is a location I cannot reach on my computer, and within it the program opens
    a temporary folder that disappears as I close the program and does not save any files I add to it, so I cannot use any pictures I place in it.
    Further, since I'm unable to reach the experiment's folders,
    how would I be able to move it to another computer on which I'm supposed to conduct my experiment once it's ready ?

    Sorry, some of this stuff is new to me so I'm a bit confused,
    once again thank you for your support


  • edited 1:49AM

    Hi Marina,

    In theory you should be able to save the experiment wherever you want. When you save it, just select the folder you want it to be saved in (Desktop, Documents, whatever). Once it is stored there, you can put the images in there. The default location to save the experiment, might be somewhere in C:\Users\appdata\,,,, but you once you save it to a more accessible location, you should be fine.

    Can you try and tell us whether this solved it?


  • edited December 2015

    Hi Eduard,

    so - I placed all the picture files at the correct folder and run them randomly,
    and after some adjustments it started running pretty much as it should.
    the main problem is that after about 50-60 trials the experiment stops
    and gives an 'error: Out of memory ' message is I run it on the quick run window,
    and, strangely, it keeps running much longer if I run it on a full screen mode, but still stops after couple hundred steps.
    following Sebastian's recommendations on former posts I made sure I'm using xpyriment back end (although my experiment is time sensitive), and that I run the experiment in a separate process, but the problem still occurs.
    My experiment contains of 2 target stimuli pictures (square & circle) and 2 frames pictures. on each trial one frame and one target stimuli appears simultaneously , for 600 trials. in addition, on 348 of the trials some other picture appears for a short while before the target stimuli + frame appears. I'm not using the pool and all my pictures are gathered on the same folder where the experiment is.
    Before my block loop I placed this initial_script on the prepare phase :

    import random

    Negative_group = []

    Neutral_group = []

    Negative_folder = "D:\GNG_SST_experiment\All_Negative_ordered\"

    Neutral_folder = "D:\GNG_SST_experiment\All_Neutral_ordered\"

    for i in range (1, 73):

    Negative_group.append("%d.jpg" % i)

    for i in range (73, 100):

    Negative_group.append("%d.bmp" % i)

    for i in range (100, 213):

    Neutral_group.append("%d.jpg" % i)

    for i in range (213, 230):

    Neutral_group.append("%d.bmp" % i)



    and after the trial sequence I placed a second inline_script also on prepare phase:

    print (var.Picture)

    if (var.Picture == "Negative"):

    var.Pic_path = Negative_folder + Negative_group.pop(0)

    if (var.Picture == "Neutral"):

    var.Pic_path = Neutral_folder + Neutral_group.pop(0)


    So I'll be grateful for any idea of the cause of failure.
    I added a pic of the experiment's so far (the practice phase is not yet set).
    Additionally, I'm not sure how should I make all the pictures to be presented on the same size without cropping them (some of them are of different sizes and I'd like them all to be presented uniformly)
    should I use PIL ?

    Sorry if some questions are weird, I'm not a pro on this as you can probably tell :]

    Thank you and a happy new year,



  • edited 1:49AM

    here's the error message ;

    The experiment did not finish normally for the following reason:

    Unexpected error

    item-stack: experiment[run].Experimantal_loop[run].Experimemtal_Block[run].Block_loop[run].Trial_sequance_1[prepare].Picture[prepare]
    exception message: Out of memory
    time: Sun Dec 27 20:58:56 2015
    exception type: error
    Traceback (also in debug window)

  • edited January 2016

    Hi Marina,

    Sorry for the late response.

    Just from your description, I can't see what the problem could be. Everything seems to be fine. Would you mind uploading the experiment (e.g. to file dropper). Maybe then we can find the problem.



Sign In or Register to comment.