Converting pixels to cm?

I added credit card scale to my online task, but I previously determined the line lengths in pixels. Now how do I convert them to centimeters?

If you have something you want to be 2.5 cm wide then give it a width of 2.5*x_scale

Okay, so in this case, I should delete elif and el statements, and is this how itā€™s supposed to look?

Those are for some sensible starting values before the credit card gets resized. Donā€™t pick cm as your online units. Personally I think itā€™s best to use height, but you could use pix. You could delete the bits you donā€™t need or leave them there for screen scale to check what units you are using.

I mean, we want everyone to see exact line lengths, not proportional values. So, in this case, I think centimeters would be right. Why did you think I should use height or pixels?

Are you running the study online?

If so, then you donā€™t know the size or the participantā€™s monitor. The cm units only work if you have told PsychoPy the size of monitor being used. Screen scale is designed to allow you to work out the participantā€™s screen size in pix or height units by resizing a credit card (common object of known size)

Yes, itā€™s going to be an online study. You mean adding a code that assumes the size of the monitor? Can we assume that the standard is 1080 x 1920? Can we do it like that?

I wouldnā€™t recommend assuming the size of the monitor in pixels. Have you tried the screen scale demo?

https://run.pavlovia.org/Wake/screenscale/

Here are some threads which might help.

Yes, I added that to my experiment, but this is just for making sure that everyone will receive the same length of stimuli, right? So after adding this, I should also make some adjustments to make sure that everyone receives the same length in cms, if Iā€™m understanding correctly. I mean Iā€™m not sure how to convert the measurements to centimeters at this point after adding the credit card reference.

hey, if Iā€™m missing something, can you please explain how to convert @wakecarter

Hi,
If you put units in pixels, credit card scale routine will make sure that all your participants have the same length/width in cm no matter their screen size/resolution. You donā€™t have to convert back to cm.

1 Like

Thank you, we converted the the predetermined pixels to cms considering our own computer (1080px), we calculated how many centimeters the pixels we previously determined correspond to. Now we have our distributions in cms. How to proceed from here? I mean adjusting the line lengths based on scaling factor derived from screen scale??

As you have calculated in cm the size of the stim that you want the online particpants to see, all you have to enter in the size of your stim component is: (the_size_in_cm_you_want * y_scale). y_scale is the scaling factor that the routine give to each participant (which is of course different for each screen size and resolution).
For example: if the y scaling factor of one participantā€™s screen is 55.6 pixels per cm and you want him to see a 3cms line, then the size in pixels is 355.6 (3 y scaling factor)

1 Like

Okay so considering line_rect_len is the name of the desired line lengths in cm in my spreadsheet, should I just write it like this:

line_length_px = thisTrial[ā€˜line_rect_lenā€™] * y_scale

Or:
line_length_px = line_rect_len * y_scale

And here:

Yes exactly, ā€œline_length_pxā€ in you code is the specific size in px that match the size of ā€œline_rect_lenā€ in cm for one particular screen !
Iā€™m not totally sure about how you built your experiment so I canā€™t tell if this line of code is at the right place (as long there are no bugs it should be fine)

1 Like