Module eyekit.tools

Miscellaneous utility functions.

Functions

def create_stimuli(input_texts, output_stimuli, *, screen_width, screen_height, color='black', background_color='white', **kwargs)

Create PNG stimuli for a set of texts. This may be useful if you want to use Eyekit to create your experimental stimuli. If input_texts is a string, it will be treated as a path to a directory of .txt files. If input_texts is a list, it is assumed to be a list of texts (strings or lists of strings). If input_texts is a dictionary, it should be of the form {'stim_id': TextBlock, ...}. output_stimuli must be a path to a directory. The screen_width and screen_height must be specified and should match the final display size of the experimental stimuli (typically, the experimental computer's screen resolution). A color and background_color can optionally be specified (defaulting to black on white). Additional arguments are passed to TextBlock, and may include position, font_face, font_size, and line_height (see TextBlock for more info). The function will also store the texts as TextBlock objects in stimuli.json for use at the analysis stage.

def align_to_screenshot(text_block, screenshot_path, *, output_path=None, show_text=True, show_guide_lines=True, show_bounding_boxes=False)

Given a TextBlock and the path to a PNG screenshot file, produce an image showing the original screenshot overlaid with the text block (shown in green). If no output path is provided, the output image is written to the same directory as the screenshot file. This is useful for establishing TextBlock parameters (position, font size, etc.) that match what participants actually saw in your experiment.

def font_size_at_72dpi(font_size, at_dpi=96)

Convert a font size at some dpi to the equivalent font size at 72dpi. Typically, this can be used to convert a Windows-style 96dpi font size to the equivalent size at 72dpi.

def discard_short_fixations(fixation_sequence, threshold=50)
def discard_out_of_bounds_fixations(fixation_sequence, text_block, threshold=100)
def snap_to_lines(fixation_sequence, text_block, method='warp', **kwargs)

Deprecated in 0.4. Use FixationSequence.snap_to_lines().