Howdy, Stranger!

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

Supported by

Collecting a mouse response during a for loop -in OpenSesame

edited May 2022 in OpenSesame

Dear Community,

I'm facing a problem in Opensesame. I am programming a visual search task. 12 Stimuli are presented on screen, but they appear one by one, with a delay of 80ms between each stimulus.

I want the participants to respond with a mouse click, when they see the target. Hence, the response should be possible, even when not all stimuli are already shown on screen.

Im am presenting the stimuli using a for-loop.

Now, when I add ad mouse.get_click() command after the for loop, the participants will not be able to respond until all stimuli are on screen.

If I add this command before the loop, the stimuli will not occur before the mouse click.


Moreover, I would like the loop to stop, when a response was given.


Can you please give me some advice in how to approach this?

Thanks a lot!

Comments

  • Hi @Tali ,

    The trick is to replace the clock.sleep(80) by my_mouse.get_click() while having a timeout of 80 ms. This way you can check during the waiting period whether a button was clicked, and break the loop as soon as this is the case. Something like this should probably do the trick:

    my_mouse = Mouse(timeout=80)
    for i in range(0, len(middle), 4):
        button, position, timestamp = my_mouse.get_click()
        if button is not None:
            break
        draw_list.append(middle[i])
        # … the rest of the loop
    

    Good luck!

    — Sebastiaan

Sign In or Register to comment.