Howdy, Stranger!

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

Supported by

pseudorandomization with just one cycle

Hi,
I have an experimental setup in which I show 5 images.Two of them are fillers and need to always appear in position 2 and position 5 (however it is random which of the two appears in position 2 and which in 5). The other 3 images have to appear in random order in positions 1, 3 and 4.

Is there a way to do this? I read about the constraint option but I do not think it applies in this case as I only have one cycle.

Thanks!

Comments

  • Hi Loes,

    There are many solutions to this problem, and the details of what you want to do are not exactly clear to me. (Try to provide a bit more detail in the future!). But something like the following should work.

    In an inline_script, assign five variables (image1, image2, ... image5) that correspond to the five images that you want to show, in the order that you want to show them. This script should come just before your loop.

    import random
    
    # Define a list of images that should be shown at random positions,
    # shuffle this list, and assign it to variables that we'll use in 
    # the loop
    random_images = ['random_a.png', 'random_b.png', 'random_c.png']
    random.shuffle(random_images)
    var.image1, var.image3, var.image4 = random_images
    # Two other images are fixed
    var.image2 = 'fixed_2.png'
    var.image5 = 'fixed_5.png'
    

    Then, in the loop, define a variable image based on these variables. To preserve the order, make sure that it's set to 'sequential'.

    Cheers!
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Dear Sebastiaan,
    Thank you. This works perfectly for what I need.

Sign In or Register to comment.