Onset times and custom timers

Windows 10, PsychoPy 3.0.7

I’d like to store stimulus onset times, although an important question with that is what those times are referenced to. i.e. the beginning of the experiment execution or the beginning of the phase loop (in a multi-phase study).

  1. How do I get the current time since the experiment started so that I can log this in the log file for each stimulus presented?

  2. How do I begin a timer, starting for example with a mouse click, then get the time of stimulus onset within a loop with reference to that timer, and then end the timer when a specific loop has completed?

The reason is because I plan to create an fMRI study and require onset times for data analysis, and I am also unsure of how many times I will stop/start scanning (I assume that acquisition will be in two runs).

Hi @fffrost, as of PsychoPy 3.1.0 , each Builder Component is now outputting its start/stop times in the data file by default ( and can be turned off). If you want to create your own clocks, see the clock API.

1 Like

Is there a way to save timings of the builder components relative to a custom clock? Asking for an fMRI experiment where ideally everything would be saved relative to the trigger.

you have a try :
import time
or
timer = core.Clock()
timer.add(5)
while timer.getTime()<0:
do something

thanks. I’m thinking of whether the “builtin” component times (Save onset/offset time feature) can be tied to a custom clock - such as timer = core.Clock() - somehow?

If so, please share the correct answer here