Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

abort the trial after responding and jump to the next trial without continuing the current trial

edited May 2016 in OpenSesame

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

  1. 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()

  1. get the response

click, pos, t1 = my_mouse.get_click()

  1. 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)
  1. 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

  • edited 11:47PM

    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:

    if var.stop_presence == 1:
    
       while True:
    
          # Set the timestamp for GO canvas
          t0 = GO_canvas.show()
          # Sleep the specified SSD duration
          self.sleep(SSD)
          # Check if a response has been given before the STOP-signal
          click, pos, timestamp = my_mouse.get_click(20)
          # Break the loop if response has been found
          if click != None:
             var.correct = 0
             break
          # If no response has been given display the STOP-signal and continue trial
          STOP_canvas.show()
    
          self.sleep(345)
    
          GO_canvas.show()
    

    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

  • edited May 2016

    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

    click, pos, timestamp = my_mouse.get_click(20)

    In this line, what does the "20" mean? Should the value here be the duration of SSD?

    I actually used

    click, pos, t1 = my_mouse.get_click(self.get('SSD'))

    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

  • edited May 2016

    Hi Samantha,

    In this line, what does the "20" mean? Should the value here be the duration of SSD?

    The 20 (which is in ms) sets the timeout duration to collect a mouseclick. I used this arbitrary number because the documentation uses it.

    click, pos, t1 = my_mouse.get_click(self.get('SSD'))

    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.

    but an error message was showed: get_click() takes exactly 1 argument (2 given)

    Maybe if you assign the SSD duration to the timeout argument beforehand it takes the correct time.

    Would I be able to collect the response time for this response?

    Yes, the t1 collects the timestamp of the mouseclick, you can derive the response time like you did in the original post:

    if var.stop_presence == 1:
    
       # Assign the timeout duration to SSD
       timeout = var.SSD
    
       while True:
    
          # Set the timestamp for GO canvas
          t0 = GO_canvas.show()
          # Sleep the specified SSD duration
          self.sleep(SSD)
          # Check if a response has been given for the duration of SSD
          click, pos, t1= my_mouse.get_click(timeout=timeout)
          # Break the loop if response has been found
          if click != None:
             var.response_time = t1 - t0
             var.correct = 0
             break
          # If no response has been given display the STOP-signal and continue trial
          STOP_canvas.show()
    
          self.sleep(345)
    
          GO_canvas.show()
    

    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 another break after it. But like i said, i'm no expert either and haven't tested it.

    Good luck!

    Laurent

  • edited 11:47PM

    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

Sign In or Register to comment.