Issue for assessing the time between stimulus presentation and mouse movement to answer

Hello!

I’m a beginner for PsychoPy coding. I need help to code my experiment.

In this experiment, I would like to assess the initiation time, that corresponds to the time between the stimuli apparition (virtual ball, cross, and opening after clicking cross fixation) and the begining of the mouse movement. I tried several method while using core.clock(), reset(), and getTime(). I have tried to detect the begining of the mouse movement from the (0, 0) position or to add a fictive circle in the centre of the screen and detect when mouse leaves this circle. No options have worked, PsychoPy bug. You could see the code below and a video of the problem.

Thank for your help!

Best regards

KB

from psychopy import visual, event, core, monitors
import random
from numpy import linspace

win = visual.Window(size=(800, 600), color=‘black’, units=‘pix’)

ball = visual.Circle(win, radius=56.69, pos=(0, 0), fillColor=‘gray’, lineColor=None)
opening = visual.Circle(win, radius=30, pos=(0, 175), fillColor=‘white’, lineColor=None)
chemin_image = “cross.jpg”
cross = visual.ImageStim(win, image=chemin_image, pos=(0,-175))
chemin_image = “fixationcross.png”
false_circle = visual.Circle(win, radius=10, pos=(0, 0), fillColor=‘blue’, lineColor=None)
fixation_cross = visual.ImageStim(win, image=chemin_image, pos=(0,0))
fixation_ball = visual.Circle(win, radius=8, pos=(0, 0), fillColor=‘gray’, lineColor=None)

opening_sizes = linspace(5.67, 113.4, num=20)
random.shuffle(opening_sizes)

for block in range(5): # 5 blocs
for opening_size in opening_sizes:
fixation_cross.draw()
fixation_ball.draw()
win.flip()
mouse = event.Mouse()
response_clock = core.Clock()
response_clock.reset()
click_detected = False
while not click_detected and response_clock.getTime() < 10:
if mouse.getPressed()[0]:
if fixation_ball.contains(mouse):
click_detected = True

    opening.setRadius(opening_size)  
    ball.draw()
    opening.draw()
    cross.draw()
    win.flip()
    
    
    response_clock_initiation = core.Clock()
    response_clock_initiation.reset()
    initiation_time = None
    mouse_x, mouse_y = event.Mouse().getPos()
    timeout = 10
    while initiation_time is None and response_clock_initiation.getTime() < timeout:
        if mouse_y > 10 or mouse_x > 10: 
            initiation_time = response_clock_initiation.getTime()
        

    participant_response = None
    mouse = event.Mouse()
    response_clock = core.Clock()
    response_clock.reset()
    click_detected = False
    while not click_detected and response_clock.getTime() < 10:
        if mouse.getPressed()[0]:
            if opening.contains(mouse):
                participant_response = 'opening'
                click_detected = True
            elif cross.contains(mouse):
                participant_response = 'cross'
                click_detected = True
        
    if participant_response is None:
            participant_response = 'NR'

    print(f"Block: {block + 1}, Opening Size: {opening_size}, Response: {participant_response}, Initiation Time: {initiation_time}")

win.close()