abort the trial after responding and jump to the next trial without continuing the current trial
Hello,
I'm trying to use the inline script to create a customized Stop-Signal task with visual stop signal modality adapted for tablet. (participant needs to hold his/her response if a stop signal is present after the target showed, and the period during the target stimulus and stop signal is called "stop signal delay (SSD)")
So far, the script is going on the track that I want it to.
However, in the STOP condition, if a response was made BEFORE the stop signal, which means the reaction time is shorter than SSD, the script would be interrupt shortly somehow...
Although the task will continue, the subsequent 2-3 trials would be not presented normally (the stimulus presentations in the subsequent trials would bounce).
Here is the general (simplified) structure of the script:
1. fixation
- target and stop-signal (STOP condition) present
if var.stop_presence == 1:
t0 = GO_canvas.show()
self.sleep(SSD)
STOP_canvas.show()
self.sleep(345)
GO_canvas.show()
elif var.stop_presence == 0:
t0 = GO_canvas.show()
- get the response
click, pos, t1 = my_mouse.get_click()
- define correct response
if var.stop_presence == 1:
if click != None:
var.response_time = t1 - t0 var.correct = 0 . . (I skipped the detailed script for demonstration purpose) . elif click == None: var.response_time = 0 var.correct = 1
elif var.stop_presence == 0:
if click != None: var.response_time = t1 - t0 . . (define correct (1)/incorrect (0) response) . else: var.response_time = 0 var.correct = 2 (missing response in GO condition)
- output to log file
I tried to use "if var.response_time <= SSD:" (Here's another question, how do I express "equal or less" in opensesame inline script. Cause the "<=" in python seems not work here...), but I'm not sure where to put this condition...
Is there function (like "break" or "continue") in opensesame inline that I can use to break the current trial under the condition when responding before the stop-signal in STOP trial and continue the task? (In that case, after a response is made, the stop-signal will not be presented, and this will be categorized as the incorrect STOP. But the given response time still needs to be recorded)
I appreciate any suggestion and help.
Thank you so much!
Best,
Samantha
Comments
Hi Samantha,
It is difficult to say what causes the problem in your script due to the formatting but one of the options could be to place (parts of) the script within a
while-loop
. These loops run until a certain condition has been met, then you can choose to abort (break
) the trial if a response has been given.For example:
This would be the general idea, but i have not tested it in any way nor am i very experienced with python, so proceed accordingly
The 'equal or less' operator <= should work, are you sure the values are correct? Alternatively you can just use the 'less' operator (<) since the chance of the response time being exactly equal to the SSD in ms is very small.
Best,
Laurent
Hello Laurent,
Thank you so much for the quick reply!
Yes, the idea is very like to be working.
But I have some questions regarding the "mouse.get_click" function in the while-loop.
As you suggested, I have to check if a click response is made before the STOP-signal.
To do this, you use
In this line, what does the "20" mean? Should the value here be the duration of SSD?
I actually used
The SSD will change according to participant's response in the previous performance
but an error message was showed: get_click() takes exactly 1 argument (2 given)
Would I be able to collect the response time for this response? (Cause even this will be an incorrect STOP response, but I still have to record how this response is made, including the response as well as the response time)
I'm basically a new hand in programming, any suggestion would be very helpfully.
Thank you so much!!
Best wishes,
Samantha
Hi Samantha,
The 20 (which is in ms) sets the timeout duration to collect a mouseclick. I used this arbitrary number because the documentation uses it.
That's a good idea but make sure to check how it behaves with the
self.sleep(SSD)
line, i don't think that you can simultaneously sleep and collect responses. But someone else please correct me if i'm wrong.Maybe if you assign the SSD duration to the timeout argument beforehand it takes the correct time.
Yes, the
t1
collects the timestamp of the mouseclick, you can derive the response time like you did in the original post:I'm not sure how this loop behaves when no response has been made during the SSD. In other words: if the while-loop doesn't end automatically after
GO_canvas.show()
you might want to inlcude anotherbreak
after it. But like i said, i'm no expert either and haven't tested it.Good luck!
Laurent
Hi Laurent,
Thank you so much for the information.
For this customized task, I put the "while-loop" at the beginning of the entire trial_script, and separated the "STOP" and "GO" conditions in the loop to make it easier to write the script. So far so good^^
Thanks again.
Cheers,
Samantha