Howdy, Stranger!

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

Supported by

Response time logging with mouse

Dear Forum,

In my experiment, I am recording responses with the class mouse: button, position, time = my_mouse.get_click()

After every response, I am logging the answer and response time:

var.buttonpress = button

var.time_buttonpress = time

I now looked at the data file from a pilot data collection and have a couple of general questions regarding how response times are logged:

  • Is the format of the log file in milliseconds? Because the first recorded time is quite large - is it possible that the time until the experiment has been started is measured here?
  • Am I correct in the assumption that the time recording starts when the function is called and stops when the participant answers (= clicks with the mouse)?
  • Since I am calling the functions more than 200 times during the experiment, I was wondering whether the response times are summed up? Because the data indicates that the response time is getting larger with every answer, which points to some kind of accumulation. If this is the case, would I have to use the mouse.flush() function every time an answer has been recorded?

I am looking forward to hearing back from you - thank you very much in advance :)

Best,

Sarah

Comments

  • Hi @sarah_alexandra,

    I think the confusion comes from the fact that your sample the time variable instead of the response time associated with the mouse click object. As far as I know, the time variable simply refers to the internal clock time. It'll always go increasing as the task runs and does not reflect the interval between the onset of the mouse object and the time a click is registered.

    If you'd like to calculate that interval manually through code, you'd have to use a variable to store the time when you want to start measuring, and then right after a click is detected, calculate the difference between the current time and the stored time.

    Otherwise, simply use the response_time variable (var.response_time or [response_time] depending on the context), or the response time variable for the specific mouse object (let's imagine my mouse event is called 'mymouse', var.response_time_mymouse or [response_time_mymouse] depending on the context).

    See this example:

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • edited February 2023

    Hi Fabrice,

    Thanks a lot for your fast answer!

    That means when calling the mouse function such as "button, position, time = my_mouse.get_click()", I am not recording the response time, but simply the current timestamp since the experiment has started?

    Since I have programmed my experiment mainly with inline code and am using a while loop as part of a staircase mechanism, I have to calculate the time interval manually through code. Do you have an example how that could look like? Would the variable used to store the time when I want to start measuring be right after or before calling the mouse function?

    Thanks a lot in advance!

    Best,

    Sarah

  • FabFab
    edited February 2023

    Hi @sarah_alexandra,

    Ok, now it's clearer to me where you get your time variable from. You get it from the definition of a get_click() event. You might want to call the time element timestamp or something, just to avoid potential problems as "time" is also a python reserved word. Might generate problems, but just to be on the safe side, I'd call it something else.

    I'm not accustomed to program this type of event directly from python code, but I looked it up for you and it looks as if, as I thought, your time variable (from "button, position, time = my_mouse.get_click()) is a measure of the current time with reference to the computer's internal clock (probably starting when the task begins). So, to calculate the the interval between a certain event and the mouse click, what you want to do is to define a timestamp for the first event:

    start_time = self.time()
    

    And then calculate the difference between time and start_time.

    I had a quick go at it in this example.

    Hopefully that'll help

    Fabrice.

    Buy Me A Coffee

  • Hi Fabrice,

    That indeed helps a lot, thank you very much for your fast answer! I'll give that a try :)

    Best,

    Sarah

  • Ok, @sarah_alexandra 👍️

    Incidentally, when replying in this forum, you can direct a message to a specific person by using their handle. For example, if you type @Fab, you'll see a pulldown menu appear where you can select my handle. If you use it, then I get a notification when I open the forum (otherwise, when there are many requests at once, I don't always see that a message is addressed to me.

    Buy Me A Coffee

  • Perfect, thanks for the recommendation @Fab ! I just tried it out and it works perfectly 👍️ Thank you!!

  • Hi @sarah_alexandra,

    Glad I could help!

    Good luck with your experiment!

    Fabrice.

    Buy Me A Coffee

  • Thank you! 😊

Sign In or Register to comment.