Skip to main content

pbl-exp

Useful helper functions for running experiments at the Predictive Brain Lab (Bochum).

Overall, the philosophy is to provide simple and convenient tools for running experiments while logging events and experimental information across devices.

The library aims to log/send events to:

  • Pupil Labs eye tracker
  • SR Research Eyelink eye tracker
  • Lab Streaming Layer (LSL) streams
  • PsychoPy log files

This includes the use of PsychoPy GUI dialogs for user input and configuration.

This repository also provides examples for how to use these helper functions.

Installation

pip install pbl-exp

Usage

Conveniently connect to a Pupil Labs device and send events

from PBL.exp import get_pupil_labs_device

device, median_offset_ns = get_pupil_labs_device()

This will open a dialog asking you:

  1. Whether you want to connect to a Pupil Labs device.
  2. Which device to connect to if multiple devices are available.

If a device is selected, the function will return the device object and estimate the median clock offset in nanoseconds. If no device is selected, it will return None for both.

The clock offset can then be used to send events to the Pupil Labs device with corrected timestamps. For example:

from PBL.exp import send_event_to_pupil_labs

send_event_to_pupil_labs("event_name", device, median_offset_ns)

This event can also be called with device is None, which simplifies testing and debugging. In this case, the function will not attempt to send the event to any device but will still log the event with the provided timestamp.

Display fiducial markers in PsychoPy

Use create_fiducial_marker_stimuli to generate AprilTag or ArUco marker images as PsychoPy ImageStim objects. For example, create six AprilTag stimuli and display them throughout the experiment:

from psychopy import visual
from PBL.exp import create_fiducial_marker_stimuli

win = visual.Window(fullscr=True)

markers = create_fiducial_marker_stimuli(
    win=win,
    marker_family="36h11",
    marker_ids=range(6),
    marker_size_pixels=200,
    auto_layout=True,
    margin=50,
)

# Draw once per frame, or set autoDraw to keep them visible.
for marker in markers:
    marker.autoDraw = True

win.flip()

marker_family can be one of the AprilTag families "16h5", "25h9", "36h10", or "36h11"; an ArUco dictionary such as "4x4_50" or "6x6_250"; or "aruco_original". Choose marker_ids from the valid IDs for that dictionary. marker_size_pixels sets the square marker's width and height in pixels.

With auto_layout=True (the default), exactly 4, 6, or 8 markers are placed around the window perimeter. Their order in marker_ids determines their clockwise positions, starting at the top-left; margin is the minimum distance from a marker to the window edge in pixels. To control positions yourself or use a different number of markers, pass auto_layout=False and set each stimulus's pos in PsychoPy pixel coordinates:

markers = create_fiducial_marker_stimuli(
    win=win,
    marker_family="6x6_250",
    marker_ids=[10, 11],
    marker_size_pixels=200,
    auto_layout=False,
)
markers[0].pos = (-300, 0)
markers[1].pos = (300, 0)

Marker generation requires an OpenCV build with the aruco module. If it is unavailable, install an OpenCV build that includes the contributed modules, such as opencv-contrib-python.

Metadata

Release files for pbl-exp 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pbl-exp 0.3
File Size Uploaded Provenance Actions
pbl_exp-0.3.tar.gz 16.9 kB With provenance Details for pbl_exp-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pbl-exp 0.3
File Interpreter ABI Platform Actions
pbl_exp-0.3-py3-none-any.whl Python 3 none any Details for pbl_exp-0.3-py3-none-any.whl

Total release size: 28.3 kB

Release files / pbl_exp-0.3.tar.gz

Download URL pbl_exp-0.3.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4f5a812b5d3083794c45e39a36734619dda64f62d4a057c961c26336866808fb
BLAKE2b-256 checksum
How to use checksums
e9ddae4f915f99637028937345f50550382116a019bc567ef293c8ee6753e2b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / pbl_exp-0.3-py3-none-any.whl

Download URL pbl_exp-0.3-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b305a883f6532442c9eefc5647d484d472371d4d39bc04c09212f296256c19b8
BLAKE2b-256 checksum
How to use checksums
bf51071d2d3d704c078d11ed0a5621495b5ccf00ed87d3792763d68f4bcd8f14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for pbl-exp 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pbl_exp-0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page