running inline scripts in parallel
Hi,
I am using a Cedrus box.
I managed to write inline script which reads the correct buttin number + RT for that
This is the code:
if dev.is_response_device():
dev.reset_base_timer()
dev.reset_rt_timer()
while True:
dev.poll_for_response()
if dev.response_queue_size() > 0:
response = dev.get_next_response()
# do something with the response
keyPressed = response['key']
isPressed = response['pressed']
rt = response['time']
dev.clear_response_queue()
if isPressed:
#print('isPressed')
var.thisResponse = keyPressed
var.thisTime = rt
break
But I want to be able to run a loop where I show image and the user may or may not press on the button.
Something like the stop-signal-task in http://osdoc.cogsci.nl/3.1/manual/structure/coroutines/
but not with keyboard response, but my Cedrus response box.
I wanted to replace the kb_response with my getResponse inline script and got error that "inline_script" does not support coroutines.
I generated inline_script just like in the "Writing a custom coroutine" section (copied the 2nd example there) but again got the same error.
How can I have my inline_script run in parallel to the stimulus ?
Thanks!
Noa
Comments
Hi Noa,
You can use an
inline_script
in combination with coroutines, but it works a little differently. You have to define a so-called generator coroutine function in aninline_script
, and then indicate the name of this function in thecoroutines
item. The script itself is then not placed in thecoroutines
item.A generator coroutine is simply a function that has a
yield
in it, instead of areturn
statement.This is explained in more detail here:
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!