psi.launcher package

Submodules

psi.launcher.api module

psi.launcher.experiment module

psi.launcher.icons module

Shared look for the icons of psi programs.

Every psi program’s icon is the same frame – a dark blue square with a thick white border – around a motif of its own (a chirp for cftscal, noise for noise-exp, the circuit-board trident for psi itself). Building them all through make_icon keeps the frame, palette and output sizes identical, so the programs read as one family on the taskbar.

Each program keeps a small make_icon.py script that draws its motif and calls make_icon. Rerun that script to regenerate the icon; the resulting image files are what the program ships, so this module (and matplotlib and Pillow, which it needs) is only required when making an icon, never when running the program. Install them with:

pip install psiexperiment[icons]

Examples

A minimal script that draws a sine wave inside the standard frame:

import numpy as np
from psi.launcher.icons import make_icon, plot_signal

def draw(ax):
    t = np.linspace(0, 1, 100)
    plot_signal(ax, t, np.sin(2 * np.pi * 2 * t))

make_icon(draw, 'main-icon.png', 'main-icon.ico')
psi.launcher.icons.BACKGROUND = 'midnightblue'

Color of the square behind the motif.

psi.launcher.icons.FILL = 'cornflowerblue'

Color for filled areas of the motif (e.g., the area under a signal).

psi.launcher.icons.FOREGROUND = 'white'

Color of the frame and of the motif’s lines.

psi.launcher.icons.FRAME_WIDTH = 10

Width of the frame, in points. Half of it falls outside the image, so the visible border is half as wide.

psi.launcher.icons.ICO_SIZES = [(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)]

Sizes Windows picks from when it renders the icon (taskbar, alt-tab, Explorer, …).

psi.launcher.icons.PNG_SIZE = 256

Width and height of the PNG, in pixels.

psi.launcher.icons.TRACE_WIDTH = 4

Width of the motif’s lines, in points.

psi.launcher.icons.make_icon(draw, png_path, ico_path=None, xlim=(-0.05, 1.05), ylim=(-1.5, 1.5))[source]

Draw an icon in the standard frame and save it.

Parameters:
  • draw (callable) – Called as draw(ax) with the matplotlib axes to draw the motif on. The axes fill the whole icon and are hidden; use data coordinates within xlim and ylim.

  • png_path (str or Path) – Where to save the icon as a PNG_SIZE x PNG_SIZE PNG. This is the file to load as a window icon.

  • ico_path (str or Path, optional) – Where to also save a Windows .ico holding every size in ICO_SIZES (e.g., for a desktop shortcut or a frozen executable). Skipped if not provided.

  • xlim (tuple of float) – Range of data coordinates spanning the icon from left to right.

  • ylim (tuple of float) – Range of data coordinates spanning the icon from bottom to top.

Returns:

png_path – Path the PNG was saved to.

Return type:

Path

psi.launcher.icons.plot_signal(ax, t, y, floor=None, width=4)[source]

Draw a signal as a white trace over a filled area.

This is the motif of the signal-based icons (cftscal’s chirp, noise-exp’s noise): the area below the signal is filled with FILL and the signal itself is drawn on top in FOREGROUND.

Parameters:
  • ax (matplotlib axes) – The axes passed to the draw function of make_icon.

  • t (array) – Horizontal positions of the samples, in data coordinates.

  • y (array) – Signal value at each position, in data coordinates.

  • floor (float, optional) – Lower edge of the filled area. Defaults to the bottom of the axes, which fills all the way to the frame.

  • width (float) – Width of the trace, in points.

psi.launcher.process_manager module

psi.launcher.settings module

Module contents

Framework for building launchers: GUIs that queue and run psi experiments.

A launcher lets the operator pick paradigms, preferences and plugins, then runs each experiment as a separate psi subprocess and tracks its progress over a websocket. The pieces are:

  • Experiment / FrozenExperiment (psi.launcher.experiment): one row of the launcher, before and after its run mode is fixed.

  • ProcessManager (psi.launcher.process_manager): runs the psi subprocesses and relays their events.

  • LauncherSettings (psi.launcher.settings): launcher state; subclass it and implement build_experiment.

  • Widgets (psi.launcher.widgets): ExperimentSequence, AddRemoveCombo, AddItem.

  • Icons (psi.launcher.icons): the shared look of psi program icons.

Everything is importable from psi.launcher.api (with the enaml import hook active). set_app_id, which a launcher’s main calls before building its GUI, lives in psi.application.

This package is provisional: its API may change between minor releases while the first few launchers built on it settle.