3

This is the first time I am using this software to create an experiment.

For my experiment I am presenting two images side by side, ideally I would like to run this experiment in fullscreen but when I set the value to true, the images become stretched. How do i fix their aspect ratio so I can run the program in full screen without stretching the images?

I am using a MacBook Pro and the PsychoPy coder.

Here is my current code for the images:

scale=0.7
faceRGB = visual.ImageStim(win,image='male.jpg', 
mask=None,
pos=(0.0,0.0),
size=(scale,scale))


faceRGBINV = visual.ImageStim(win,image='maleInv.jpg', 
mask=None,
pos=(0.0,0.0),
size=(scale,scale)`

Furthermore, in my experiment one of the images will be slightly compressed or stretched as it is. The participants will then have to choose the fatter face. This is already set up and when run in a window the images appear normal, it is just in fullscreen mode when they become stretched to fit the monitor size.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Jack E Farr
  • 31
  • 1
  • 3

1 Answers1

1

By default, PsychoPy uses 'norm' as units, which is size normalized to the window dimensions. You may have a situation where you (1) change the size of the image and (2) the image just happens to have the correct dimensions when presented in the default 800 x 800 pixels Window but appears stretched when you go fullscreen because your monitor has another aspect ratio.

If you don't change the size of the image, PsychoPy maintains the correct aspect ratio. Scaling the image will preserve this aspect ratio, so that's an easy solution. E.g. add one line after initiating the ImageStim:

scale = 0.7

from psychopy import visual
win = visual.Window(fullscr=True)
faceRGB = visual.ImageStim(win, 'male.jpg')
faceRGB.size *= scale  # scale the image relative to initial size

If you want to control size directly and not just proportionally, see this discussion on the users list. I suggested the following solution. Say you want to set the image size so that scale is the maximum length along either the x- og y-axis and scale the other axis proportionally. Replace the last line above with this:

faceRGB.size *= scale / max(faceRGB.size)

Multiplying maintains aspect ratio as above and the righthand side is the multiplication factor to ensure scale. Change max to min if you want this to apply to the minimum length instead of the maximum length.

Note: you do not need to set pos=(0,0) and mask=None as that is the default value of these parameters.

Jonas Lindeløv
  • 5,442
  • 6
  • 31
  • 54
  • Hi, thank you so much for the reply. My current code for the images reads like this: scale=0.7 faceRGB = visual.ImageStim(win,image='male.jpg', stim.size *= 0.7 # 70 % original size mask=None, pos=(0.0,0.0), size=(scale,scale)) faceRGBINV = visual.ImageStim(win,image='maleInv.jpg', mask=None, pos=(0.0,0.0), size=(scale,scale)) Sorry if this seems rather basic, but where do i implement this new line of code? Thanks again for you time and help. – Jack E Farr Oct 20 '14 at 20:33
  • Always a good idea to provide the code in the question, so feel free to edit it and update with your concrete example. In this example, ``faceRGB`` is your stimulus object so ``faceRGB.size`` is the property you want to change. You can do this AFTER initialization, i.e. on a line below calling ``visual.ImageStim``. Notice that ``faceRGB.size`` is the same property as ``visual.ImageStim(size=4)`` but that you cannot do operations on it in the latter case. Do read up on some basic python syntax here - you cannot have a comment inline either. What I've called ``imageSize`` you've called ``scale`` – Jonas Lindeløv Oct 20 '14 at 21:08
  • I have updated my question with the extra details. I am currently reading up on python syntax but also trying to get my experiment running as soon as possible. I am struggling to understand how i implement what you have suggested. Is it just where I have (scale,scale) that needs changing? – Jack E Farr Oct 20 '14 at 21:29
  • 1
    I have updated the answer to match your variable names. It is not entirely clear from your last sentences whether you want psychopy to stretch an image or whether the face is already fatter/whiter in the original image. If you want psychopy to stretch it (e.g. wider), simply multiply the size on one dimension on a new line: ``faceRGB.size *= [1.3, 1]`` (30 percent wider but same height) – Jonas Lindeløv Oct 21 '14 at 05:21