Howdy, Stranger!

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

Supported by

Variable won't register negative values (difference between stimuli and response time)

edited July 2016 in OpenSesame

Hi!

I'm doing an experiment where a cue is presented, and then the subject should press a key (space) as soon as possible. A circle will flash before or after the key press, and the subject should determine whether the flash occurred before or after the key press. I use a script to count the mean response time of the key press, to be able to sometimes present the flash before the key press.

I have a variable that registers the response time for the key press, and a variable that registers the time delay before the circle is presented. I also want to know the time difference between these two events (circle_vs_response), but when I subtract the time delay before the circle (flash_delay) from the response time (trial_response_time), the variable circle_vs_response never shows any negative values, whether I press the key before the circle or not. The lowest value it shows is 24. When I look at the specific values in flash_delay and trial_response_time and count the difference the values in circle_vs_response are correct, but obviously there is something wrong with the code, because the difference should sometimes be negative. I guess the problem could be in registering response time or time delay of the circle?

Here is my overall design of the experiment (it continues after the practice block but I will use the same script later in the experiment):

image

Here is my prepare phase of the script:

image

Here is the run phase of the script:

image

Comments

  • edited 6:07AM

    Hi Charlotte, if the specific values for flash_delay and trial_response_time are correct, your desired variable should be flash_delay - trial_response_time. In your script it seems that you have switched these two around, is that right?

    Cheers

    Josh

  • edited 6:07AM

    Hi! Well, first I tried defining the variable just like that (flash_delay - trial_response_time), but then it was the other way around, the variable only gave me negative values, never positive ones. So while I thought the problem was in defining that variable, I start to think that it is the response time and/or the time delay of the circle that are not correct (even though the times look plausible when I print them).

    /Charlotte

  • edited 6:07AM

    Hi Charlotte, it should be easy to check if those individual values make sense or not, as you can calculate some time differences manually.

    Actually, I think the problem is that you're always collecting your keyboard response after the flash canvas in your run-phase. This is bound to always yield positive/negative values depending on which one comes first.

    A better setup may be to start timing with t0 = self.time(). Then you enter a while-loop, where you continuously collect a keyboard response with timeout = 1. You break from the while-loop when a response is given (response != None) or when a general timeout is reached. Before entering the loop, you determine at which point your flash should appear. You can display the flash during the loop by means of:

         current_time = self.time() - t0
         if current_time >= flash_time:
              flash_canvas.show()
    

    Does this make sense?

    Cheers

    Josh

  • edited 6:07AM

    Thank you for your help! It all seems to work fine now, and circle_vs_response registers both positive and negative values.

    /Charlotte

Sign In or Register to comment.