Howdy, Stranger!

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

Supported by

[open] Prevent a picture to be shown twice

edited July 2013 in OpenSesame

Dear community,

it's me again. Hope that I'm not spaming with all my questions ;-)
I have a follow up question to my microexpression experiment. The experiment exists of 7 loops and every loop is called 7 times (see picture below for more details). In every loop there's a random picture shown (the variable 'emotion').
Here's my question: how can I prevent that one picture is shown two or more times? I need to get sure that every picture is shown only one time.


Best wishes


  • edited 4:47AM

    Hi Daniël,

    Is it possible for you to provide us with the code of your experiment?

    • Open the "General properties" tab, click "Script editor" and copy the whole script,
    • go to or, upload your script there (simply paste and submit)
    • and provide us with the resulting link in your forum post.

    I think I understand the question, but just to be sure I think it would help if I could see the experiment myself.



    Lotje van der Linden -

  • edited 4:47AM

    Hi Lotje,

    here's the link to my experiment. Thanks for your help :-)


  • edited 4:47AM

    Hi Daniël,

    Thanks for the link.

    If I understand correctly, you don't want stimuli from within a given loop (e.g. 'fearful_loop') to be repeated, right?
    One way to achieve this is as follows:

    Firstly, append an inline_script item to the beginning of all your 'sub' sequences:


    Secondly, put the following code in the inline_script item (see comments for more information):

    # Get the loop item from the items dictionary:
    loop_item = exp.items['%s_loop' % self.get("Emotion2")]
    # And remove the current cycle, such that the stimulus presented
    # on the current trial will never be shown again.
    # In other words, if your fearful_loop is run again, it will not contain
    # the previously-shown 'Emotion's' anymore, and therefore they cannot
    # be shown multiple times by coincidence.
    for cycle in loop_item.matrix:
        if loop_item.matrix[cycle]['Neutral'] == self.get('Neutral'):
    del loop_item.matrix[cycle]

    Note that this quick way to achieve your goal involves changing the internals of OpenSesame, since we're manually adapting the content of the in-the-GUI-defined loop items.
    For another thread on this issue, see:

    There are other, more transparent ways to prevent stimuli from being presented twice as well, but those involve more inline_script items and would require a bigger change in the outline of your experiment. That's why I'd suggest the above, somewhat complex method first (but I'm happy to explain the other one as well, if you want).

    An example experiment can be found here:

    Best wishes,


    Lotje van der Linden -

Sign In or Register to comment.