How to ensure objects are of desired size

Let’s say I want my measurements to be in CM, so I created a Window where the units is in “cm”, for example:

visual.Window(..., units="cm")

If I need a Rectangle of size 1cm by 1cm, I assume that creating a Rect where width and height are 1.0 will give me that desired Rectangle, for example:

visual.Rect(..., width=1.0, height=1.0)

But the Rectangle I got on the screen during runtime isn’t 1 by 1 cm.

Likewise for Circles, if I need a Circle where the radius is 1cm, I do this:

visual.Circle(..., radius=1.0)

But, similar to the Rectangle, I didn’t manage to a perfect 1cm radius (2cm in diameter).

What I am missing here?

Likewise, I would like to know how to ensure that the positions is where I want the object to be located, for example if I want a Rectangle to be placed at 1cm on the X and 2cm on the Y, from the point of origin, I do this:

rect = visual.Rect(...)
rect.pos = (1.0,2.0)

Is that right? Which part of the Rectangle is right at the [1,2] point? The center?

Hi there, if you use the units drop down box in the component you can select “cm”.

The default is “from exp settings” which is usually height (this is proportion of screen height so is good to ensure task runs a across several devices with differing screen size)

Note that the same applies for the positioning of stimuli. Select the desired units in the component :blush:

Thanks for your response @Becca. I am coding it on Python, what do you mean by “drop down box”, is that on the builder? I suppose by selecting “cm” (as you mentioned), it is equivalent to initialise visual.Window with units="cm" in Python. But strangely, I didn’t get a perfect 1x1cm box on the screen when I create a Rectangle with visual.Rect(..., width=1.0, height=1.0).

You should probably describe exactly what you did get. But I would guess that the issue here is that you haven’t correctly specified the physical and pixel dimensions of your monitor. PsychoPy can’t display stimuli in physical units like cm unless it is told the physical geometry of your display. It can tell how many pixels are on your screen, but has no idea how large those pixels are until you tell it.

I got a box that is smaller than 1x1cm, around 6mm.

Thanks for you input, it’s valuable. You mention that haven’t correctly specified the physical and pixel dimensions of your monitor. Where should this settlings be configured? I’m currently developing this on Macbook pro with a resolution of 2880x1800 Retina.

In the toolbar in PsychoPy, click on the “Monitor settings” icon and create a new named definition for your monitor (i.e. you should see a default entry called something like testMonitor: create a new one that is specific to the particular display you are using). Then use that name in the call to:

win = visual.Window(monitor = 'your_monitor_definition_name')

I did not install the full package, instead only pip install. As such unable configure my monitor as suggested by @Michael:

toolbar in PsychoPy, click on the “Monitor settings” icon and create a new named definition

But, thanks to @Michael, found the location where the configuration are stored, based on documentation:

This will write a json file to the monitors subfolder of your PsychoPy configuration folder (typically ~/.psychopy3/monitors on Linux and macOS, and %APPDATA%psychopy3monitors on Windows).

On the Terminal, I went to cd ~/.psychopy3/monitors, and clone the existing testMonitor.json. Tune it to the size of my monitor and test by creating 1x1 Rect and Circle with radius 1.0.

I changed 2 things, width and sizePix. This is my JSON file, for 2018 Macbook Pro:

{
  "2020_06_30 15:39": {
    "calibDate": 1593502740.0,
    "gamma": 1.0,
    "width": 50,
    "distance": 57,
    "notes": "default (not very useful) monitor",
    "psychopyVersion": "2020.1.2",
    "usebits": false,
    "gammaGrid": {
      "__ndarray__": [
        [
          0.0,
          1.0,
          1.0
        ],
        [
          0.0,
          1.0,
          1.0
        ],
        [
          0.0,
          1.0,
          1.0
        ],
        [
          0.0,
          1.0,
          1.0
        ]
      ],
      "dtype": "float64",
      "shape": [
        4,
        3
      ],
      "Corder": true
    },
    "linearizeMethod": 1,
    "sizePix": [
      2880,
      1800
    ]
  }
}

Hope this helps for anyone who need to calibrate their monitor without Monitor Center.

Assuming you installed all the required dependencies correctly, you can still run the PsychoPy app GUI, you just have to do it from the command line instead of double-clicking a convenient icon.