psychopy.org | Reference | Downloads | Github

Is it possible to record UNIX time with millisecond precision?

In order to work out the absolute delay between when triggers are received in the programme I am using to record EEG, and the time that stimuli are first presented in psychopy, I am trying to use the core.getAbsTime() in psychopy so I can compare with UNIX timestamps recorded in the EEG software.

This works, but I can only get UNIX timestamps in Psychopy to the nearest second. Is there are way to record these timestamps with millisecond precision?

Thanks

Hi @nrh31, have you thought about using Pythons time package? See docs.

You could save time at specific events using:

# Begin Experiment
import time

# Each Frame
if event == true:
    thisExp.addData("utcTime", time.time())

Note, the time docs do say that not all systems provide time with better precision that 1 second.

This works really well! A perfect solution to my problem.

Many thanks

This does not work if it gets pushed to Pavlovia. It just get stuck at “initializing experiment…”

Any ideas as of how to fix this?

Hi @CbjOpto yes this was a Python solution, but you can easily do something similar in JS:

unixTime = new Date().getTime()
psychoJS.experiment.addData("unixTime", unixTime)