Description of the problem:
I am trying to figure out how to get the monitor size of each participant that takes my study online and store it as a variable in my excel data files.
How do I do this?
Description of the problem:
I am trying to figure out how to get the monitor size of each participant that takes my study online and store it as a variable in my excel data files.
How do I do this?
@eszubsk, you should be able to get the size of the browser window using
psychoJS.window.size
I assume that psychoJS.window.size returns the resolution in pixels. Is that what you wanted? If not then you probably need to write a “resize a rectangle so it’s the same size as a credit card” technique described elsewhere:
This seems to be a solution but I am having trouble adding it as a code component to my experiment in Builder.
This is the error I keep getting:
expInfo[‘Window_size’] = psychoJS.window.size
NameError: name ‘psychoJS’ is not defined
Thank you in advance for your help. I am very new to PsychoPy and coding in general.
This is a really intriguing component that I would like to implement.
However I am very new to psychopy and coding in general.
Would it be possible to add this via the code component through psychopy builder?
@eszubsk, that looks like a Python error, so make sure you use this code in the JavaScript panels of the code component by setting the code type to ‘JS’ or ‘Both’. If using ‘Both’, the JS code is in the right hand panel.
I’ve written a Screen Scale PsychoPy that seems to work this evening – written in builder with code components.
I’ve set it to public so it can be viewed/copied.
Best wishes,
Wakefield
@wakecarter thank you so much for sharing Screen Scale!
V2020.1.3.
Windows 10
Chrome
I also want to run an online study that presents images as stimuli.
If all participants see these images at the same size regardless of their screen resolution and window size it would be really convenient for my experiment.
So, my question is is it possible to present all images at the same size across all window sizes and resolutions by using “resize credit card technique”?
Or is there a way such as creating a dialog box with a “resolution in pix” section that participants can manually enter their screen resolution such as [1920x1080] and according to the entered value images can be resized.
Many thanks,
Emre
I used to advocate pixels over norm units but height I feel is better for trials (and norm for instructions).
However, I should be able to edit Screen Scale so it detects the units being used and reports the appropriate scale. The main things that would need to change are the increments (it has two depending on whether you click the arrow keys within .5 seconds or not) and the text of the display. Actually it might be of particular use for norm units because it would allow images to be presented in the correct aspect ratios
Best wishes
Wakefield
@wakecarter Thank you for your fast reply!
As far as I know, using the norm unit can cause landscape or portrait presentation of the square picture according to window size. The shape of stimuli is pretty important for my experiment so I suppose I cannot use the norm unit. Detecting appropriate scale by Screen Scale would benefit in this case if I understood correctly?
However, as far as I understood there is no other way to stabilize image size in online studies (like cm).
Thanks a lot!
Emre
I’ve just improved Screen Scale such that it will work in height, norm and pix units. I’ve also added a second routine which displays a 10cm square – this will work with norm units because Screen Scale works out the horizontal and vertical scaling factors needed separately.
However, when I tried to sync to upload it to Pavlovia I got “This file doesn’t belong to any existing project” so I’m trying to troubleshoot that.
Try it now. I haven’t tested it online myself (because I’m only seeing the previous version) but I think it should work.
Thanks for this piece of code!! It works very well.
@wakecarter So sorry for the late reply. I wanted to try online before I send a message. I had a pilot token problem last days I could try the experiment online just now after I solved the problem!
Thank you so much for the updated Screen Scale. It works perfectly online as well!
Many thanks
Emre
@dvbridges when you call psychoJS.window.size
how is the information returned? Can I call something like psychoJS.window.height
and psychoJS.window.width
separately? What I need is to determine the width and height of the screen and then later be able to call the height and width separately as part of separate functions and I don’t know the best way to do this.
@Eslifkin, psychoJS.window.size
should return an array with the width and height e.g., [width, height]. You can unpack those values into separate variables e.g.,
[w, h] = psychoJS.window.size
// Use w and h for width and height, respectively
@dvbridges Thank you! When I add that code however, I get a reference error: w is not defined. Using that, how would I call just the width or height variables. Would it be $w
or psychoJS.window.size(w)
or something else?
Ah that is probably because PsychoPy is not finding and declared the new variables as they are nested in a list. Try the following instead:
w = psychoJS.window.size[0]
h = psychoJS.window.size[1]
Perfect, thank you so much!
Hi Wakefield and thank you for this work!
I had to update my Psychopy software and I’m now using Psychopy v2020.2.10. The credit card technique doesn’t seem to work anymore. Can you enlighten me, please?
Thank you and best regards,