Saving Image for each trial block

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win10
PsychoPy version As of 2/2021
Standard Standalone? (y/n) ?
What are you trying to achieve?:

Hi,
I have an experiment that is text based (eg. each block is a static text block). Since so, rather than having the video of the whole thing, I’d like to save an image (jpg or so) for each trial block. I’d also like to do it in a way that the experiment will still run and be editable on the builder (+ Py code snippets on blocks).
What is the right way to do it?

Thanks!

You can save the window as an image like so:

outname = filename + "_" + str(```SOME VALUE WHICH CHANGES EACH ROUTINE```) + ".png"
frame = win.getMovieFrame()
frame.save(outname)

I would put this in the End Routine tab of a Code component :code:

Thank you so much. Just to make things clear - does win always exist and refer to the current window? or should I define it somewhere?

Yes, win is what PsychoPy calls the window, so it exists in every experiment :slight_smile: The only time it won’t exist is if you’re writing code in the Before Experiment tab of a Code component :code:, as the point of this tab is to add code before the window is created.

Thanks again. Easy…