How can I get the start time of the stimulus?

Dear all,

I am writing a stimulus program and need to obtain the start time of the stimulus so that I can align it with the system time later.

I tested the following code in matlab:

startTime = PsychPortAudio( 'Start’, pa, 1,0,1); % play audio and return the onset time
timeonset = posixtime(datetime( now))*1000; % system time

And I found that “startTime” and “timeonset” are not the same and their intervals are not fixed. “timeonset” is a POSIX time (number of seconds elapsed since 00:00:00 1-Jan-1970 UTC) while the specific encoding format of “startTime” is not clear.

I need “startTime” to ensure the stimulation precision in time. So, do I have any methods to get the POXIS format for “startTime”?

Thanks,
Ado

PTB timestamps consistently uses that returned by GetSecs. For MAC and Windows, GetSecs=0 typically means the time of last computer restart. You can have more information from

doc GetSecs

If you want to get the relationship between posixtime and GetSecs, following should be close to a constant:

posixtime(datetime('now')) - GetSecs
1 Like

See GetSecs AllClocks?

1 Like