Module eyekit.io

Functions for reading and writing data.

Functions

def read(file_path)

Read in a JSON file. FixationSequence and TextBlock objects are automatically decoded and instantiated.

def write(data, file_path, compress=True)

Write arbitrary data to a JSON file. If compress is True, the file is written in the most compact way; if False, the file will be larger but more human-readable. FixationSequence and TextBlock objects are automatically serialized.

def import_asc(file_path, trial_begin_var, trial_begin_vals, extract_vars=[])

Import a single ASC file or a directory of ASC files. The importer looks for a trial_begin_var that is set to one of the trial_begin_vals, and then extracts all EFIX lines that occur within the subsequent STARTEND block. Optionally, you can specify other variables that you want to extract, resulting in imported data that looks like this:

{
  "trial_0" : {
    "trial_type" : "Experimental",
    "passage_id" : "passage_a",
    "response" : "yes",
    "fixations" : FixationSequence[[368, 161, 208], ..., [562, 924, 115]]
  }
}