Movie / video stimulus synchronization and restarting

Hi Chris,

We have a 3s movie clip. We’d like to loop it 10 times. However, on each repetition of the clip, we’d like to start that repetition at a specific time (just to make sure we stay synchronized to an external counter.) We want the last frame to stay on the screen until the next repetition start, so there is no flashing or frames of gray screen interposed.
The external counter ticks at a 30.02 Hz rate and our display frame rate is 29.995 Hz according to MWorks.
We want one counter tick per movie frame.
We are doing this with the image_directory_movie stimulus.

Probably we would be ok letting this run for 10 repetitions without resync each 3s rep.

But if we wanted to start the movie every 3s as I describe above, is there an action we need to execute to make sure the movie has restarted? Or does “play dynamic stimulus” start back at the beginning?

Thanks,
Mark

Hi Mark,

To manually restart at the beginning, you need to execute stop_dynamic_stimulus followed by play_dynamic_stimulus. The “stop” is what resets the stimulus.

Alternatively, you could configure the movie to repeat automatically (via the repeats parameter) and then pause and unpause it at the appropriate times to keep it in sync with the external counter. While the movie is paused, the currently-displayed frame remains on screen, so that might be preferable to stopping, which will make the movie stop drawing itself until you play it again.

A couple questions:

  1. Is the external timing signal available in the experiment? For example, does each tick result in a variable assignment?

  2. Will the rates of the external counter and the display refresh cycle always be about the same? If so, then a frame list stimulus might be a better choice than the image directory stimulus. In particular, its ending parameter would provide a convenient means for determining when to stop or pause the movie.

Cheers,
Chris

Hi Chris,

Thanks!

Is the external timing signal available in the experiment? For example, does each tick result in a variable assignment?

Yes. It comes in via a counter variable, via a Labjack device, at 30 or 60 Hz (and can go higher sometimes.)

Will the rates of the external counter and the display refresh cycle always be about the same? If so, then a frame list stimulus might be a better choice than the image directory stimulus. In particular, its ending parameter would provide a convenient means for determining when to stop or pause the movie.

Not always. Thanks for pointing that stimulus and variable out.

Any other suggestions for what to do here?

Our goal is for each MWorks video frame to start as close to a tick (or a tick mod N) of the counter as possible. For example, if the counter is going at 30 Hz, we’d like to start the next video frame as soon after each counter tick as possible. If counter at 60 Hz, next frame after every 2nd counter tick. Etc.

If a MWorks video frame is missed, we want it to be skipped so that later video frames start on the intended counter ticks - timing drift over time is the main thing we are worried about.

One option would be for us to just play a looped video, and in MWorks track frame timing at each counter tick to make sure no frames are missed. (Or do this offline via mwk2 file as I am not sure we have access to the current frame # in MWorks.) Given that the counter is running at a fixed frame timing which cannot be modified, and the MWorks monitor is also running at a fixed frame rate that cannot be modified, this may be the best we can do.

best,
Mark

Hi Mark,

As we discussed offline, MWorks’ movie and image directory movie stimuli will skip or repeat frames as needed to maintain the requested number of frames per second, so you should be all set.

Cheers,
Chris