psychopy.org | Reference | Downloads | Github

Consistent image size across screens

URL of experiment: https://run.pavlovia.org/aelreym/concurrent_schedule_task/html

Description of the problem:
In the routine “cigarette length” I ask participants to estimate the real length of a cigarette by clicking on the appropriate image. So I have images of cigarettes with the real length of cigarettes and some deviations.
In my builder experiment I have set the units of my images to “cm” but this doesn’t work online. I have changed it to “from exp settings” and this does adapt the sizes to the screen and changes the dimensions of the cigarettes across screens. Is there a way to have consistent image sizes across screens?

2 Likes

Ah, that’s a tricky one. When you select a unit like “cm”, you need to have a defined monitor. That is, PsychoPy needs to know both the resolution of your screen and its physical dimensions. It is actually impossible to get this information for participants on Pavlovia, or really any other web-based system. You can get the resolution easily enough, but physical dimensions are not readable. So, unfortunately, you won’t be able to get consistent sizing across different screens unless each one has its monitor information entered into PsychoPy, and it’s simply not possible to do over Pavlovia at all.

Thanks for the explanations, I will try to replace this routine by something else.

It is actually possible to ask participants for the screen dimensions. The standard procedure is to ask them to resize a rectangle on the screen until it is the same size as an object we know the dimensions of (eg. credit card). jsPsych has a built-in plugin for this: https://www.jspsych.org/plugins/jspsych-resize/

Psychopy could implement a helper method that does the same

The trick would be to use the helper method to then feed into the units system, but that’s a good thought. That said, I don’t think @jon and the other developers have a huge amount of time to devote to new features right now, but worth putting in a feature request for in the issues queue on github.

Yeah, I created an issue on github. Thanks for the suggestion.

Yes, it’s worth having the to-do list ready. At some point we will be getting back to feature development! In fact, a new programmer will be starting on 1st June to work on PsychoJS full-time which will hopefully make a big difference to what we can achieve! :slight_smile:

1 Like

Hi, what is the trick to get the resolution ?

Javascript has very simple tools for this that are built-in and so can be incorporated into a PsychoPy code component (in principle). See here: https://www.tutorialrepublic.com/faq/how-to-detect-screen-resolution-with-javascript.php

Thanks for the info. How might this be implemented in PsychoPy though? More specifically, how can I use these Javascript screen.width and screen.height values in Python code/fields e.g., width and height of an image object?

The best solution would probably be to set the width and height to variable names rather than values, and then define those variables in a code component in either begin routine or begin experiment in terms of the screen width and height.

However, in general terms, if you want your stimulus displays to be relative to the screen size, you could use norm or height units, which should adjust for screen resolution automatically.

You can use my Screen Scale routine. It uses a credit card and then displays a square using height or norm units.

3 Likes

Hello! I was wondering if your screen scale routine will automatically change the scale depending on how the participant sizes the credit card, or if I need to do something else? I can’t get the code portions to open in the screen_scale routine.

Thank you for creating this wonderful resource!

You need to use the variables as scaling factors for future routines.

If you can’t open the code components then that probably need to upgrade to 2020.1.3 first.

Hello, I am late to the discussion here, but could you elaborate a little more? Would a workaround be possible with different units, say “height” or “normalized” units?

A workaround in what sense? Height and norm units are based on the display resolution alone, and will adjust their absolute size in pixels for the display resolution of any given participant, so they are a good option if you want everything to appear the same relative sizes regardless of an individual participant’s setup. However, you won’t know how that translates to cm without also knowing the physical dimensions of the screen, or degrees of visual angle without knowing both the physical dimensions or the viewing distance. Physical dimensions and viewing distance are simply not available for online participants for the time being.

1 Like

This is amazing! Do you know how can I use this to display an image instead of an object in order to have the same size across monitors?