Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

log shuffled list

Hello!
I am looking for a way to log the shuffled sequence of a list. I am using an inline script for presenting a series of pictures randomly in one display.

x_a1 = exp.get_file('x_a.png')
x_b1 = exp.get_file('x_b.png')
x_c1 = exp.get_file('x_c.png')
x_d1 = exp.get_file('x_d.png')

l = [x_a1, x_b1, x_c1, x_d1]

toBeShuffled = l
shuffle(toBeShuffled)
print (toBeShuffled)

left_pic = toBeShuffled[0]
right_pic = toBeShuffled[1]
center_pic = toBeShuffled[2]
center2_pic = toBeShuffled[3]
print(left_pic)
print(center_pic)
print(center2_pic)
print(right_pic)

So I want to know what picture is "assigned" each time in variable left_pic, right_pic, center_pic, center2_pic. Should I use a scripted logger? Or should I add something to my inline script in order to have such a choice on the logger? Thanks in advance for any ideas!

Best regards,

Vicky

Comments

  • eduardeduard Posts: 977

    Hi Vicky,

    if you prepend your variables with a var, they will be added to the logfile (of course, only if you have a logger item placed after that.

    e.g.

    x_a1 = exp.get_file('x_a.png')
    x_b1 = exp.get_file('x_b.png')
    x_c1 = exp.get_file('x_c.png')
    x_d1 = exp.get_file('x_d.png')
    
    l = [x_a1, x_b1, x_c1, x_d1]
    
    toBeShuffled = l
    shuffle(toBeShuffled)
    print (toBeShuffled)
    
    var.left_pic = toBeShuffled[0]
    var.right_pic = toBeShuffled[1]
    var.center_pic = toBeShuffled[2]
    var.center2_pic = toBeShuffled[3]
    print(var.left_pic)
    print(var.center_pic)
    print(var.center2_pic)
    print(var.right_pic)
    

    Goo dluck,

    Eduard

    Thanked by 1Vicky
  • VickyVicky Posts: 3

    Hi and thanks for the idea!

    I tried it but the var. function does not work in my script. Maybe there is something with my version, it gives me an error message now,:

    exception message: name 'var' is not defined
    exception type: NameError

    So I really don't know if that would work!

    This is the full script

  • eduardeduard Posts: 977

    Which version of Opensesame do you have? If it's an older one <3.0, you can try to replace the var with exp.

    Eduard

    Thanked by 1Vicky
  • VickyVicky Posts: 3

    It's working just fine!
    Thank you
    -V.

Sign In or Register to comment.