This script shows how to convert Pupil Time to System Time and store timestamps in DateTime format.
Last active
December 2, 2022 14:16
-
-
Save elepl94/e6c5d55f94bd39dd3fffb718052a071a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load packages | |
library(readr) | |
library(tidyr) | |
library(lubridate) | |
# Load the desired .csv and info.player.json files from Pupil Player exports | |
data <- read_csv("../../../../data.csv") | |
info_player <- read_csv("../../info.player.json") | |
start_time_system <- extract_numeric(info_player[9,]) #System Time at recording start | |
start_time_synced <- extract_numeric(info_player[8,]) #Pupil Time at recording start | |
# Calculate the fixed offset between System and Pupil Time | |
offset <- start_time_system - start_time_synced | |
# Add the fixed offset to the timestamp(s) we wish to convert | |
data$system_timestamp <- data$pupil_timestamp+offset | |
# Convert System Time timestamps in datetime format | |
data$datetime <- as_datetime(data$system_timestamp, tz="UTC") #change tz accordingly to your timezone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment