| Reference | Downloads | Github

Image output as a JPEG or PDF

Hi all. I’m currently using PsychoPy to create Gabor Patches for an experiment I am running in eprime. It currently displays the image in a separate window, but I have no way to copy the image other than to snip it or take a screen shot. I would much rather prefer to convert it to a JPEG or PDF so that I can call upon those objects while eprime is running. Here is the code I’m using to generate and display the gabor patch. If anyone could provide some code for doing this it would be greatly appreciated. Thanks!

 import psychopy.visual
> import psychopy.event

> win = psychopy.visual.Window(
>     size=[400, 400], 
>     units="pix",
>     fullscr=False, 
>     color=[.147, .147, .147] 
> )

> grating = psychopy.visual.GratingStim(
>     win=win,
>     units="pix",
>     size=[300, 300] 
> )

> grating.sf = 5.0 / 150.0

> grating.mask = "gauss" 

> contrasts = [0.8] 
> orientations = [-8] 

> for i_grating in range(1):
>     grating.ori = orientations[i_grating]
>     grating.contrast = contrasts[i_grating]

> grating.draw()

> win.flip()

> psychopy.event.waitKeys()

> win.close()

Yes you do: the .getMovieFrame() method of the Window class:

And you should probably avoid JPG compression if image fidelity is important to you. Use the lossless .png instead.

EEeek! Why? Try looking into the PsychoPy Builder view and see if it serves your purposes better? :wink:

1 Like