pupil-labs / pupil

Open source eye tracking
https://pupil-labs.com
GNU Lesser General Public License v3.0
1.46k stars 673 forks source link

how to compare timestamps to real time data #1500

Closed gaiaspicciarelli closed 5 years ago

gaiaspicciarelli commented 5 years ago

Hi, we are conducting an experiment using pupil labs glasses (without world camera as we need only pupil dilation data) but we are having some problems with the analysis of the data from pupil_position.csv. We need to compare the realtime data with the pupil diameter data (so we can know what happens at each moment as the pupil diameter changes). We are not able to do it with the timestamp, as this doesn't provide data referred to reality. We want to avoid doing it manually because, above other factors, it wouldn't be precise. Could you provide a solution? If the only way is programming, could you provide us a script? Thanks for your help

papr commented 5 years ago

What do you mean by realtime? Which clock are you referring to?

gaiaspicciarelli commented 5 years ago

I give you an example: We are saying numbers to the participant while recording the audio (with audio capture). How do we know which line of the raw data (pupil_position.csv) corresponds to the pupil diameter when we are saying the number 8 (for example)?

papr commented 5 years ago

The audio file has timestamps of their own (audio_timestamps.npy) which can be correlated to the timestamps in pupil_positions.csv

willpatera commented 5 years ago

@gaiaspicciarelli From what I see there are two topics to discuss here.

Correlating timestamps

Please check out documentation in the Data Format/Synchronization section of the docs https://docs.pupil-labs.com/#data-format - scroll down to the Synchronization section and you will find a code snippet that shows one such method for correlating data.

Converting timestamps to wall clock time

Please check out the info.csv file that is contained within each recording. You will find two keys Start Time (System) and Start Time (Synced). You can read more about the difference between Start Time System and Start Time Synced at https://docs.pupil-labs.com/#data-format (Start Time System is Unix Epoch at start time of the recording and Start Time Synced is Pupil Epoch at start time of the recording).

You can convert timestamps to wall time with some quick conversions. Here is an example on how to do this with Python using the start times in the info.csv file and an example first timestamp in the exported gaze_positions file:

import datetime
start_time_system = 1533197768.2805 # unix epoch timestamp
start_time_synced = 674439.5502 # pupil epoch timestamp
offset = start_time_system - start_time_synced
example_timestamp = 674439.4695
wall_time = datetime.datetime.fromtimestamp(example_timestamp + offset).strftime("%Y-%m-%d %H:%M:%S.%f")
print(wall_time)
# example output: '2018-08-02 15:16:08.199800' 

I will close this issue as I believe that we have responded to the question. If you feel otherwise, please make a comment and we can continue to discuss.

kayleeliyx commented 4 years ago

Hi! I'm exactly doing the same thing as you do. May I ask how can I get these data? Would you please elaborate on these?

start_time_system = 1533197768.2805 # unix epoch timestamp
start_time_synced = 674439.5502 # pupil epoch timestamp

and example_timestamp = 674439.4695 is :

image in pupil_position.cvs is that right? Thank you so much!!!