Possibility of converting inline_script (Python) in OpenSesame interface
in OpenSesame
Hello!
I would like to know if there is a chance to use this script in OpenSesame without Python (to be able to run the experiment in OSWeb and Jatos).
My structure is that I have in block loop set of pictures as Pic1 and Pic2 and also two positions - Pos1 and Pos2. Positions are shaffled, so I can not suggest that press 'w' will always be the right answer and etc.
And also I have a timeout for a participant response.
my_keyboard = Keyboard(keylist=[u'w', u'p'], timeout=2000)
start_time = clock.time()
key, end_time = my_keyboard.get_key()
var.response = key
var.response_time = end_time - start_time
var.response_timeout = int(var.response is None)
if var.pos1 == "centerleft":
correct_answer = "w"
else:
correct_answer = "p"
if correct_answer == var.response:
var.total_correct += 1
Thank you all in advance!
Comments
Hi @Daria ,
Based on this code, it doesn't seem to me that you need any script at all. You can simply use a
keyboard_responseto replace the first part of the code, which collects a key press and does some basic bookkeeping. And then, in the block_loop (or whereverpos1is defined) also create a column for the variablecorrect_responseand set it to 'w' wheneverpos1is 'centerleft', and to 'p' ifpos1has a different value.Hope this helps!
-- Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you, @sebastiaan . Still can not understand completely.
Right now my block_loop looks like this.
I am shuffling pos1 and pos2 randomly.
You suggesting creating just pos instead of pos1 and pos2? and it will be centertight and centerleft and so on? and create correct_response with 'w' and 'p'?
pic1 is always the correct answer in my experiment.
Thank you!
Hi @Daria ,
I am shuffling pos1 and pos2 randomly.
If you mean that you're shuffling these columns independently, with a
shuffleoperation in the script of theloopitem, then my suggestion indeed won't work because the shuffling will break the correspondence between the columns. (Or, to put it differently, values from the same row won't be kept together.)In that case, you can use a simple
inline_javascriptitem the start of the trial sequence with the following code in the prepare phase:if (vars.pos1 === "centerleft") { vars.correct_response = "w" } else { vars.scorrect_response = "p" }This will set the
correct_responsevariable based onpos1with the same logic as your previous script.-- Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
@sebastiaan
Yes, but that would mean that I won't be able to run my experiment online :(
Thank you
Yes, but that would mean that I won't be able to run my experiment online :(
No you would be able to do that! You can include JavaScript in an OSWeb experiment as described on this page:
Check out SigmundAI.eu for our OpenSesame AI assistant!