psychopy.org | Reference | Downloads | Github

Mouse position "incorrect"?

mouse

#1

If this template helps then use it. If not then just delete and start from scratch.

OS: Mac OSX High Sierra (10.13.5) running on a Macbook Pro of some sort
PsychoPy version (e.g. 1.84.x): 1.90.3
Standard Standalone? (y/n) If not then what?: Y
What are you trying to achieve?:

I have been developing the visual search task given in Chapter 9 of the Building Experiments in PsychoPy book. If you’re not familiar, it’s a case of finding a target hexagon among a variable number of distractor pentagons. The hex may or may not be the same color as the distractors.

I found that everything worked, but the mouse click didn’t end the trial, as it should have done.

What did you try to make it work?:

After some hacked attempts at coding (I’m not a Python coder) I discovered that clicks are being registered, it’s just that the position of the mouse (my trackpad) doesn’t match. Note that the target position can be between -400 and +400 pix, in steps of 100, on both the x and y axis.

if mouse.status == STARTED:  # only update if started and not stopped!
            buttons = mouse.getPressed()
            if buttons != prevButtonState:  # button state changed?
                prevButtonState = buttons
                if sum(buttons) > 0:  # state changed to a new click
                    #DEBUG
                    print("mouse:")
                    print("{}".format(mouse.getPos()))
                    print("target:")
                    print("{}".format(target.pos))
                    
                    # check if the mouse was inside our 'clickable' objects
                    for obj in [target]:
                        if obj.contains(mouse):
                            #DEBUG
                            print("valid click found")
                            gotValidClick = True
mouse.clicked_name.append(obj.name)
                            mouse.clicked_pos.append(obj.pos)
                    if gotValidClick:  # abort routine on response
                        #DEBUG
                        print("Stop Routine")
                        continueRoutine = False

In the image you can see that the (x,y) coordinates for the mouse appear to be double the (x,y) coordinates of the target.

I made sure the measurement units of the mouse, the experiment, and even the PsychoPy preferences were all set to “pix” (although I believe the lower level setting should have been enough).

I could just do the division manually in the code, but is there something I’m doing wrong? I suspect I need to give more info, but I’m not sure on what info would be helpful

edit: my screen coords as registered by PsychoPy are [1440, 900], which my Macbook settings agree with


#2

That sounds like this bug re retina screens:

but that shouldn’t be affecting you if you are using v 1.90.3?


#3

Hi Michael,

Thanks for the quick response. I didn’t catch that topic, sorry for the duplication. I can confirm that I’m running 1.90.3 standalone.

edit I previously had another version installed on here which I never used. Then I installed this new version. Maybe the install didn’t overwrite the old package (can you tell that I’m not an assembly line coder?..)

C