Skip to content

Export Eye Tracker Data

Obital allows for easy logging of the relevant data going through the tracker. This data can be used to analyse eye movements, generate visualizations and much more.

Configure the Logger

The logger is accessed through the SessionManager instance we created earlier. It's possible to log several different modules within the framework, to get the required raw data. The modules to be logged can be set through the modulesToBeLogged(modules: [Modules]) method in the logger. The Modules object is an enum with each module and their equivalent index. Heres an overview of what you can log in each of the modules:

data features calibration gazeEstimation smoothPursuits
timestamp
frame
calibrated gaze point*
uncalibrated gaze point
targets
activated target
optical axis point
eye transformations
**Only logs when the system is calibrated*

Which modules to log is entirely up to you - it depends on what data you need for your analytics. Obviously, data is only generated if the module is active. For example, the calibration module only logs while a SPCalibrationViewController is active, and smooth pursuits only while running a SPViewController. The features logs as long as the session is running.

Configure the logger before you need to use it - for example in viewDidLoad():

func viewDidLoad() {
    // Make an array of modules to be logged based on the enumeration 'allModulesToBeLogged'
    let modules: [EyeLogger.Modules] = [.features]
    sessionManager?.logger.modulesToBeLogged(modules: modules)
}

Starting and Stopping the Logger

Now we're ready to log. It's as simple as toggling it in the view controller:

// Toggles logging, and exports it if the logging is completed.
// Try to attach this method to a button push to trigger it manually.
func log() {
    guard let logPaths = sessionManager?.logger.toggle() else { return }
    exportFiles(filePaths: logPaths)
}

// Takes the URL's and greates a UIActivityController that allows
// the user to select how they want to export the files.
func exportFiles(filePaths: [NSURL]) {
    // Create the activity controller
    let vc = UIActivityViewController(activityItems: filePaths,
                                      applicationActivities: [])
    // If you're running on iPad, you have to supply a source
    // rectangle for the popover.
    if let popOver = vc.popoverPresentationController {
        popOver.sourceView = self.view
        popOver.sourceRect = CGRect(x: 150, y:150, width: 0, height: 0)
    }
    // Display the popOver on top of the current view controller.  
    self.present(vc, animated: true, completion: nil)
}

This allows you to export the log files any way you like. The files will be exported as comma separated values in .csv format. You get one file per module logged.

Sample Data

Here's a small sample of a log file exported from the smooth pursuits module. Notice how the target columns are dynamically generated. Since the number of targets can vary while logging, the module automatically adds columns for all targets, and fills them accordingly. If a target is only visible part of the time, it simply won't get a value in the log for that timestamp.

time_stamp frame_no feature_point_x feature_point_y target_1_x target_1_y target_2_x target_2_y target_3_x target_3_y target_4_x target_4_y target_5_x target_5_y target_6_x target_6_y target_7_x target_7_y target_8_x target_8_y target_9_x target_9_y target_10_x target_10_y target_11_x target_11_y pridicted class
1587042423 779 0.001995 0.045610 288.469543 781.011292 105.504135 1042.954468 21.873465 1162.684692 64.242912 1102.026367 218.161758 881.667725 432.524750 574.773926 644.928650 270.684937 784.647400 70.655907 807.126526 38.473534 705.204651 184.390411 512.422607 460.387878 -1
1587042423 780 0.001809 0.045076 301.660461 762.126465 114.284866 1030.383545 23.444073 1160.436157 58.102383 1110.817505 206.287842 898.667114 418.666748 594.613831 633.442871 287.128601 779.196594 78.459534 809.448792 35.148876 714.559448 170.997757 525.817200 441.211395 -1
1587042423 781 -0.000004 0.044374 314.992004 743.040222 123.434715 1017.284119 25.494553 1157.500610 52.399471 1118.982178 194.670853 915.298584 404.806671 614.456604 621.693176 303.950104 773.304199 86.895439 811.292542 32.509300 723.551270 158.124496 539.079102 422.224915 -1
1587042423 782 -0.002292 0.043780 328.447968 723.775940 132.942505 1003.672302 28.022404 1153.881714 47.141125 1126.510132 183.324951 931.541992 390.961517 634.278198 609.693848 321.128937 766.977295 95.953316 812.655457 30.558014 732.169312 145.786407 552.192139 403.451508 -1
1587042423 783 -0.002968 0.043032 342.011871 704.357117 142.796646 989.564514 31.024542 1149.583618 42.333748 1133.392700 172.263977 947.377441 377.148071 654.054260 597.459656 338.644135 760.223694 105.622147 813.535950 29.297405 740.403137 133.998474 565.140381 384.914093 -1
1587042423 784 -0.003609 0.041453 355.667236 684.807373 152.985153 974.978210 34.497307 1144.611816 37.983212 1139.621216 161.501419 962.785767 363.383179 673.760803 585.005371 356.474335 753.051636 115.890114 813.933044 28.729006 748.242554 122.775078 577.908020 366.635284 -1
1587042423 785 -0.003800 0.039825 369.397369 665.150574 163.495560 959.930847 38.436466 1138.972290 34.094826 1145.187988 151.852875 976.599182 349.683746 693.373718 572.346252 374.597839 745.469788 126.744713 813.846069 28.853516 755.678040 112.129929 590.479431 348.637390 -1
1587042423 786 -0.003178 0.039503 383.185516 645.410645 174.315063 944.440979 42.837219 1132.671875 30.673317 1150.086426 141.700424 991.133972 336.066345 712.869080 559.497742 392.992554 737.487488 138.172699 813.275269 29.670774 762.700745 102.075989 602.839294 330.942322 -1
1587042423 787 -0.000993 0.042334 397.023621 625.599304 185.437561 928.517456 47.697380 1125.713867 27.721167 1154.312866 131.877594 1005.196838 322.539185 732.235291 546.467163 411.647736 729.108887 150.167831 812.220398 31.180954 769.305847 92.619789 614.980103 313.560852 -1
1587042423 788 -0.000535 0.045339 410.877411 605.765442 196.835495 912.199524 53.004940 1118.115234 25.245668 1157.856934 122.408691 1018.753052 309.135681 751.424500 533.286926 430.517334 720.354980 162.700455 810.684082 33.380318 775.477051 83.784691 626.871826 296.536011 -1