Howdy, Stranger!

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

Supported by

defining a loop item within inline script

Hi!

I didn't find anything about this problem here, maybe I am missing something but here is the thing:

I have a pretty specific randomization requirement to follow with my stimulus set which is not doable with the options of the loop item, however I can easily create my randomized list of stimuli in inline python.

Is there any way to get a loop item to use my script-made table/list and run through that?

Of course I can write the whole experiment with inline script, and I could use my stimulus_list variable as an iterable if I used inline scripts with canvas, but it'd be so much more convenient if I could define the whole loop table with code.

Now I am using a list of lists format:

[["word","color"],

["red","green"],

["green","green"],

etc...]

but it's not necessary, if I can somehow get it into a loop element.

Thanks in advance

Comments

  • Hi @mibognar ,


    Is there any way to get a loop item to use my script-made table/list and run through that?

    Yes, this is certainly possible. The loop item is available in inline_script items as a DataMatrix object called "dm".


    Actually, OpenSesame generates two DataMatrix objects on the basis of the loop item:


    • The first (called "dm") contains the content of the loop item as you see it in the GUI
    • And the other one ("live_dm") contains the content of the loop item after it has been transformed by, for example, randomization


    You can find more information here, under "Accessing the loop table in Python inline script":



    Hope this helps you a bit further. Just let us know if you have any more questions!


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hi Lotje!

    Thanks, it works perfectly! Éooks like i missed that part in the documentation.

    Best,

    Miklos

Sign In or Register to comment.