Hi Mahdi,
Support for capturing stimulus display frames is now in the MWorks nightly build.
You can enable frame capture by including a Stimulus Display device in your experiment and setting its capture_format parameter to a supported value. For example:
var capture_enabled = false
stimulus_display (
capture_format = PNG
capture_height_pixels = 400 // Set to zero or omit for full display resolution
capture_enabled = capture_enabled
)
In general, PNG is probably the best format, as it uses lossless compression.
If the parameter capture_height_pixels is omitted or set to zero, frames are captured at the full resolution of the display. Otherwise, frames are scaled down to the specified height, with the width chosen to match the display’s aspect ratio.
By default, every display update will be captured. However, if you set the parameter capture_enabled to the name of a variable, then frames will be captured only when the variable’s value is true/1. This lets you capture only the frames you care about (e.g. while a trial is active).
Each captured frame is assigned to the system variable #stimDisplayCapture. The value of the variable is binary data (bytes in Python, uint8 array in MATLAB). The data is an image file in the chosen format (e.g. PNG). If you write the data to a file, you should be able to open it in Preview or any standard image viewer. It’s possible to preview the captured images while your experiment is running by using MWClient’s Image Viewer window with “Image data variable” set to #stimDisplayCapture
. (Note that the image viewer wasn’t designed to be updated every frame and can be quite laggy in this role. I will attempt to make it more performant in the future.)
Once you’ve run your experiment and have an event file full of captured frames, the next step is to extract and combine them into a video, with added eye traces and other desired adornments. I will work on an example of this and try to get it to you soon. You use MATLAB, right? If so, the VideoWriter class looks like a useful tool for this job, so I’ll probably try that first.
If you have any questions, please let me know!
Cheers,
Chris