Unexpected origin shift. What's the reason?

import numpy as np
import psychopy
from psychopy import visual, core, event, monitors, sound, clock

trials, moves, counter = 0, 0, 0 
key = []

# Window
window = visual.Window(
    size=(1024, 768), fullscr=True, screen=0, 
    winType='pyglet', allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True, 
    units='cm')

# Cross
cross = visual.ShapeStim(
    window, pos = (0, 0), size = 3, closeShape = True,
    vertices = [[2, 0], [-2, 0], [0, 0], [0, 2], [0, -2]],
    lineColor='white', lineColorSpace='rgb')

# Dot
dotFix = visual.DotStim(
    win = window, nDots = 1, fieldPos = (0,0), 
    dotSize = 20, color = (-1, -1, -1), dotLife = 0,
    coherence = 0, speed = 0, fieldSize = (0,0))

dotFix.draw()
cross.draw()
window.flip()
core.wait(5.0)

On running, the cross origin is slightly shifted wrt to the dot origin even though the position of both are set at (0,0). Is there a reason for this?

DotStims are designed to show a field of randomly distributed, moving small dots. You are just drawing a single dot from such a stimulus just once, so this behaviour won’t be apparent to you.

You should select a more appropriate static stimulus, like a polygon stimulus defined with many sides so it appears as a circle, where the centre of the stimulus will indeed be exactly (0, 0).

You need visual.Circle https://www.psychopy.org/api/visual/circle.html

Presuming full HD resolution, I recommend setting edges=128 given your desired diameter of 20 cm. Please note that for a visual.Circle you will have to set fillColor.

visual.Circle is good if you drawing in square window, i.e. width==height, otherwise you will get an oval instead of a circle.

If you want draw in rectangular window, as in you example size=(1024, 768), fullscr=True,, you can use something like visual.BaseShapeStim

1 Like

To get a true circle, you simply set the units of the window to be anything other than 'norm' (e.g. 'height', 'pix', etc). Only 'norm' stretches stimuli to match the aspect ratio of the screen.

1 Like