library(pupilr)
#> Loading required package: ggplot2
eye <- load_folder("../tests/test-data")
names(eye)
#> [1] "data"        "info"        "export_info" "surfaces"
class(eye)
#> [1] "list"   "pupilr"
head(eye$data$gaze[, 1:6])
#>   world_timestamp world_index confidence norm_pos_x norm_pos_y      base_data
#> 1        24406.30           0 0.99927369  0.7003364  0.5036496 24406.304517-1
#> 2        24406.31           0 0.12328624  0.7900259  0.4473870 24406.307113-0
#> 3        24406.31           0 0.99733253  0.6999799  0.5067002 24406.312586-1
#> 4        24406.32           0 0.07647939  0.8052472  0.4457641 24406.315182-0
#> 5        24406.32           0 0.99929332  0.6997234  0.5056053 24406.320655-1
#> 6        24406.32           0 0.20140568  0.8038345  0.4528181 24406.323251-0

Surfaces

Surfaces can be extracted from the entire object, or loaded on their own

sf <- eye$surfaces
sf <- open_surfaces("../tests/test-data")
names(sf$items)
#> [1] "unnamed"
head(sf$data$events)
#>   frame_number timestamp surface_name surface_uid event_type
#> 1            0  24406.30      unnamed  1552524777      enter
#> 2          137  24414.51      unnamed  1552524777       exit
#> 3          145  24414.81      unnamed  1552524777      enter
#> 4          150  24415.18      unnamed  1552524777       exit
#> 5          158  24415.52      unnamed  1552524777      enter
#> 6          271  24421.75      unnamed  1552524777       exit

Conversion

The conversion to eyer data format adds a class and does some transformations to the structure of the list and each data.frame with eye data, which is expected from the eyer package. Some information may be lost in the process.

eyer_eye <- as.eyer(eye)

class(eyer_eye)
#> [1] "list" "eyer"
# all surfaces are converted as well
class(eyer_eye$surfaces$items$unnamed)
#> [1] "list" "eyer"

# Or you can convert a single surface 
eyer_surface <- as.eyer(sf$items$unnamed)