calculate accurate response time in while-loop
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!!!