Howdy, Stranger!

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

Supported by

[solved] Collecting response time when using image button with inline script

edited May 2014 in OpenSesame

hello guys,

I am establishing a psychological experiment with a task in which one can click on a image (in a form) to choose the answer and proceed to next round of loop.

Everything runs ok except the inline script (custom form) fails to collect the response time of my mouse click on the image button (the default variable "time_inline_script turns out to be "NA").

So I tried to find other solutions,

from openexp.mouse import mouse
my_mouse = mouse(exp)
start_time = self.time()
resp, position, timestamp = my_mouse.get_click()
self.experiment.set('response_time', timestamp-start_time)

the code above succeeded to calculate and record the response time, while another problem comes that I have to do one additional click to continue (which is unacceptable in such experiment). I guess this is because the function of image button demands one click and that of mouse click demands another.

I am stuck in this for two days and deeply hope that somebody could help me to get a solution.

Thanks in advance.

Antonie

Comments

  • edited 4:59PM

    Hi Antonie,

    the code above succeeded to calculate and record the response time, while another problem comes that I have to do one additional click to continue (which is unacceptable in such experiment). I guess this is because the function of image button demands one click and that of mouse click demands another.

    That's correct, yes. Since the form will not give you any response times, you'll have to use an inline_script to catch the mouse response (like you did), or simply use the mouse_response item (which actually seems easier in your case). To avoid having to click twice, you make the form non-interactive (i.e. it's shown but doesn't wait for input), by adding the following line to the form's script:

    set only_render "yes"
    

    See also:

    Hope this helps!
    Sebastiaan

  • edited 4:59PM

    hi Sebastiaan,

    thank you for your answer! Now I understand that the codes I wrote do exactly the same thing as the item "mouse response". Sadly I still cannot solve my problem with your advice.

    May I introduce briefly the procedure of my experiment?

    1. Fixation point lasting 1000ms (with item "sketchpad")

    2. An interface including the task of "click a button to choose the answer" (with item "inline script", written by python codes)

    3. item "logger"

    And of course the 3 times are included in a sequence and loop.

    I am quite a newbie of programming, but I guess it was not a good idea to make the item 2 "non-interactive" since the "interaction" is the very purpose of the step.

    Please tell me if I misunderstood your idea and thanks again for your help.

    Antonie

  • edited 4:59PM

    Hi Antonie,

    Ah, right, so you have implemented the form in an inline_script as well? (I assumed that you used the form_base plug-in, and my suggestion was based on that assumption.) In that case, you could simply get the timestamps of before and after the form has been executed, and use these to determine the response time. For example like so:

    # (... create your form here ...)
    start_time = self.time()
    button_clicked = form._exec()
    timestamp = self.time()
    self.experiment.set('response_time', timestamp-start_time)
    

    Does that make sense?

    Cheers,
    Sebastiaan

  • edited 4:59PM

    Bravo! It works with your advice. Thanks a lot!

    Well the solution is so simple that I'm now confused why it didn't occur to me. I just could ignore the mouse click function and the lines of time calculation will do the work. I wish I could have more time to learn some basics of programming...

    And it feels great that we have both such useful software and considerate instructions of you and your colleagues.

    Antonie

Sign In or Register to comment.