Creating image from gabor generated with psychopy

Hi, I’m planning to do an experiment where the first part is conducted in psychopy and the other part with another software. I would like to present some Gabor patches with some parameters (e.g. contrast) and then use the same stimuli with another software.
Which is the best method in order to save high-quality images for this purpose?
Thank you

There’s really only one method, and it’s using window.getMovieFrame() and window.saveMovieFrame(), which will capture the entire screen in whatever format you need (probably TIFF is the best for this, since it’s uncompressed).

They’re very simple to use, you just set up something like this in your usual draw loop:

grating.draw()
win.flip()
win.getMovieFrame()

and then when you’re ready to save all of the frames you’ve collected:

win.saveMovieFrames('filename.tif')

(It will name them filename001.tif, filename002.tif, etc.)

You can read more here: Window — PsychoPy v2021.1
Window — PsychoPy v2021.1

Thank you! do you think that the quality is good enough? I’m worried about using this image instead of an internally generated image as in psychopy.

It should be. PsychoPy saves each frame as a complete set of all of its individual pixels, and .tif is an uncompressed format, meaning that every pixel that would be displayed on the screen by PsychoPy will be included in the image file. There’s still some amount of encoding involved so there is a small risk of slight changes in image quality, but in my experience if you save the output as a .tif file it looks exactly like it does when rendered by PsychoPy itself, especially if it’s greyscale.

Thank you! maybe selecting a subset of the entire screen as screenshot area could enhance image quality?

The main difference isn’t going to be in image quality but in file size. The image will be no lower or higher quality if there were some way to capture only a portion of the screen with this system (and I don’t believe there is), but the file size will be larger because it is capturing the whole screen.

The way PsychoPy is doing this is that it takes the information it sends to the rendering system on your computer to actually present the frame on your screen (the frame buffer) and saves it, then when you tell it to save it just outputs that information to an image file instead of your computer’s graphics system. It can’t capture just part of the screen or individual objects within the screen as far as I know, it just records what every pixel in your PsychoPy window is supposed to be based on the objects you’ve drawn and saves that.