Hi Psychtoolbox community,
I am having some issues getting the timing offset between psychtoolbox stimulus timestamps and my daq. I am using a Windows 10 machine running MatLab 2022a and Psychtoolbox 3 (3.0.18 - Flavor: beta - Corresponds to SVN Revision 12968).
For my experiment, I am using a ni-daq to trigger psychtoolbox screen flips while acquiring videos and other signals. I am using the screen(“flip”) function in psychtoolbox to flip my patterns and saving the VBL timestand (and stimulus onsettime). From my understanding, this time is the seconds since the system’s last bootup time. However, adding the timestamps to the system’s last bootup time gives me a large time difference (~10+seconds) from the daq timestamp when the screen flip should have happened. From acquired experimental data, the neuron response/behavioral lag from when the ni-daq triggered the flip is on the order of ~100 ms, not 10+ seconds. The 10s time difference is not consistent and will depend on how long the computer has been running for.
As a sanity check, I tried the following:
[sys_bootTime] = getSystemBootTime([]);
sys_bootTime_conv = datetime(sys_bootTime.year,sys_bootTime.month,sys_bootTime.day,sys_bootTime.hour,...
sys_bootTime.min,floor(sys_bootTime.second),mod(sys_bootTime.second,1).*1000);
timeoffset = (sys_bootTime_conv+seconds(GetSecs))-datetime('now');
milliseconds(timeoffset)
timeoffset is on the same timescale as the difference seen in the experiments. Restarting the computer results in a small timeoffset. However, this timeoffset increases the longer the computer has been left running.
In the above section of code, the function getSystemBootTime() first calls a powershell script that gets the last boot time and then parses it into the year, month, day, hour, min, and seconds/milliseconds. Please see the following attached gist links for the getSystemBootTime.m and getSystemBootTime.ps1 files.
Since GetSecs is a compiled mex file, I do not have access to the backend of the function to debug. So, I’m not sure if I was supposed to use a different time than the system bootup time, or if the bootup time is wrong, or if I should be doing something else.
Any help will be appreciated!
-Liangyu