calculate accurate response time in while-loop
Hi,
I had created a Stop-Signal task recently using opensesame inline script. Everything goes well as expected for now.
But while looking at the result output, sometimes (not all always) some values in "response_time" would be illogically big values (e.g., 4455, 8757), or small values (like 1, or 0 (even a response was made)). The unusual results didn't appear every time, and the irrational values were not always at the same trials. (This situation occurred more often in Stop-trial, when subject could not hold the response as it supposed to do in stop-trial)
I'm wondering if there's any problem in the script... Or is there any reason could explain this
In stop-trial, the target would appear a period of time (stop-signal delay, SSD), and a stop-signal would appear. Three different scenarios might happen:
- if the response was made during SSD (before the stop-signal showed), the target would disappear once the response was made, and the given will be ceased and to the next trial;
- if the response is made after the stop-signal appeared, the trial would be ceased once it got a response;
- if the subject successfully held the response, the trial would be ended for "SSD + signal_duration (this would be the timeout period in stop trial)" period of time
I used while-loop to determine whether the stop-signal would be shown, and calculate the response time if a response is detected.
Here's the script for determining the response time during stop-trial:
start_time = self.time()
#clear pending input
if my_mouse.flush() == False:
click = None
elapsed_time = 0
while elapsed_time < self.get('stop_timeout'):
t0 = GO_canvas.show()
if elapsed_time < self.get('SSD'):
click, pos, t1 = my_mouse.get_click(timeout=self.get('SSD'))
if click != None:
var.response_time = t1 - t0
break
if elapsed_time > self.get('SSD'):
self.sleep(self.get('SSD'))
STOP_canvas.show()
if click == None:
click, pos, stop_time = my_mouse.get_click(timeout=self.get('stop_duration'))
break
if click != None:
click, pos, t1 = my_mouse.get_click(timeout=self.get('stop_duration'))
var.response_time = t1 - t0
break
elapsed_time = self.time() - start_time
Any suggestion or opinion will be very helpful
Thank you so much!!!
Best,
Samantha
Comments
Hi Samantha,
I have a hard time following the logic of your script. I'm not sure it's incorrect, but it's definitely not the most straightforward implementation of a stop-signal task that I've seen! So I cannot really say what causes the weird behavior.
My suggestion is to simply use the new coroutines plug-in. This was created especially for these situations, and the stop-signal task is actually given as an example experiment. If you're using OpenSesame 3.0, you have to install the coroutines plug-in separately:
But you can also use the 3.1 prerelease, which is already quite stable and comes with coroutines by default:
And then you can find the stop-signal task here:
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thank you for the suggestion!
I appreciate your time on this, and I'm sorry that my script is not that straightforward... (because the entire script is quiet complicated, so I just posted the part when the program started to collect the subject's response in stop trial)
I actually considered using the coroutines plug-in at the beginning, but in this customized Stop-Signal task, we want the SSD (stop signal delay) to be dynamic. We want to use the tracking SSD, which the current period of SSD will depend on whether previous stop trial is accurate. If the subject successfully holds the response in the stop trial, the SSD will be increased by, that's say, 50 ms (this is the variable "stop_duration" in my first post) for the next stop trial, but if the subject fails to hold the response in stop trial, the subsequent SSD will be decreased by 50 ms.
Does coroutines be able to do this?
Many thanks,
Samantha