eyekit.tools API documentation
Description: Miscellaneous utility functions.

# Module `eyekit.tools`

Miscellaneous utility functions.

View code on GitHub

## Functions

`def create_stimuli(input_texts, output_stimuli, *, screen_width: int, screen_height: int, color: str = 'black', background_color: str = '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.

  View code on GitHub
`def align_to_screenshot(text_block, screenshot_path, *, output_path=None, show_text: bool = True, show_guide_lines: bool = True, show_bounding_boxes: bool = 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.

  View code on GitHub
`def font_size_at_72dpi(font_size, at_dpi: int = 96) ‑> float`

  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.

  View code on GitHub
`def discard_short_fixations(fixation_sequence, threshold=50)`

  Deprecated in 0.4 and removed in 0.6. Use `FixationSequence.discard_short_fixations()`.

  View code on GitHub
`def discard_out_of_bounds_fixations(fixation_sequence, text_block, threshold=100)`

  Deprecated in 0.4 and removed in 0.6. Use `FixationSequence.discard_out_of_bounds_fixations()`.

  View code on GitHub
`def snap_to_lines(fixation_sequence, text_block, method='warp', **kwargs)`

  Deprecated in 0.4 and removed in 0.6. Use `FixationSequence.snap_to_lines()`.

  View code on GitHub