esdalmaijer / PyGaze

an open-source, cross-platform toolbox for minimal-effort programming of eye tracking experiments
www.pygaze.org
GNU General Public License v3.0
671 stars 211 forks source link

how to get the timestamp (time.time()) from the corrected time stamp in the pygaze output #83

Closed DaniZz closed 6 years ago

DaniZz commented 7 years ago

hi,

I'm struggling to get the timestamp from the tsv output. I developed my own script to present stuff with pygame and it records the timestamp from the time.time() function. I see that in pyGaze that is corrected by the 'tracker timestamp'. I have no idea what it is and I would love to find a way to convert the 'time'-timestamp in the tsv into the time.time()-timestmap. Why is this correction useful anyway, and what is the internal time of the eyetracker? can this be done? I hope so otherwise I'm in big troubles.. thanks so much in advance!

DaniZz commented 7 years ago

edit:

I guess this is the culprit

        sample = self._tracker.get_frame()
        t1 = time.time()
        # put the sample in the Queue
        queue.put(sample)
        # release the Threading Lock
        self._lock.release()
        # Update the newest frame
        self._newestframe = copy.deepcopy(sample)
        # Calculate the clock difference
        self._clockdiff = sample['time'] - t1
DaniZz commented 7 years ago

I still have no idea about that 'time', but I managed to convert the timestamp from string format into unix timestamp format :)

thanks to this: http://stackoverflow.com/questions/26161156/python-converting-string-to-timestamp-with-microseconds

esdalmaijer commented 6 years ago

To provide some general information on this:

The way gaze recordings and events in an experiment are generally compared and matched is NOT through comparing timestamps. The ideal way is to use the log function of the EyeTracker class at the moment that your experiment changes, for example directly after calling the show function of a Display object. In this way, there is a log message in the gaze data file at the time of your screen update.

The reason for this, is that clocks on different devices do not necessarily run at the same pace. In other words: There is a drift in the difference between the two clocks. This means a direct comparison of the timestamps on both devices is not necessarily valid.

As for the trackertime, this is what the device (or the computer running the server that talks to the device) reports as its timestamps. They are useful, because the device is where your gaze data comes from. Timestamps in tracker time are thus the most precise indication of what gaze behaviour happened when. With the EyeTracker.log function, you can add a trigger/event/message (different people use different terms) to your eye data file, which will then also be assigned a timestamp in tracker time.