Module eyekit.tools
Miscellaneous utility functions.
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_textsis a string, it will be treated as a path to a directory of .txt files. Ifinput_textsis a list, it is assumed to be a list of texts (strings or lists of strings). Ifinput_textsis a dictionary, it should be of the form{'stim_id': TextBlock, ...}.output_stimulimust be a path to a directory. Thescreen_widthandscreen_heightmust be specified and should match the final display size of the experimental stimuli (typically, the experimental computer's screen resolution). Acolorandbackground_colorcan optionally be specified (defaulting to black on white). Additional arguments are passed toTextBlock, and may includeposition,font_face,font_size, andline_height(seeTextBlockfor more info). The function will also store the texts asTextBlockobjects instimuli.jsonfor use at the analysis stage. 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
TextBlockand 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 establishingTextBlockparameters (position, font size, etc.) that match what participants actually saw in your experiment. 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.
def discard_short_fixations(fixation_sequence, threshold=50)-
Deprecated in 0.4 and removed in 0.6. Use
FixationSequence.discard_short_fixations(). 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(). 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().