Skip to main content

Driver for the PST Chronos response box

Project description

psychopy-chronos

Python driver for the PST Chronos response box, with a drop-in PsychoPy keyboard replacement.

Installation

pip install psychopy-chronos

Windows driver

Install the USB driver from the chronos_driver_win/ folder before first use if you never installed E-Prime on your machine.

Usage

Standalone

from chronos import Chronos

with Chronos() as box:
    events = box.get_events()

PsychoPy Builder

Add a Code Component with this in the Before Experiment tab:

from chronos import HybridKeyboard
from psychopy.hardware import keyboard
keyboard.Keyboard = HybridKeyboard

All Builder Keyboard Response components will then capture Chronos button presses alongside regular keyboard input. Buttons are coded '1' through '5' left to right, so add them to the allowed keys list in your Keyboard Response component.

To save hardware timestamps, add this to the End Routine tab:

if key_resp.response_log:
    thisExp.addData('chronos_hw_us',
        [getattr(k, 'hw_timestamp_us', '') for k in key_resp.response_log])
    thisExp.addData('chronos_pc_time_s',
        [getattr(k, 'tDown', '') for k in key_resp.response_log])

Hardware timestamps and drift correction

Each press is timestamped by both the host PC (chronos_pc_time_s, seconds from experiment start) and the Chronos internal crystal (chronos_hw_us, microseconds).

The crystal drifts relative to the PC clock. I measured +68.7ppm on my laptop (1001 presses over 685s, about 47ms of total drift). The drift is linear and correctable offline by regressing chronos_pc_time_s onto chronos_hw_us:

import numpy as np
slope, intercept = np.polyfit(hw_us_array, pc_time_array, 1)
corrected_rt = slope * hw_rt_us + intercept

Drift magnitude will vary across units. The test script used for this measurement is in test_chronos_timing.py.

chronos_hw_us is a 32-bit counter that wraps every 71.6 minutes. Use modulo 2^32 arithmetic for elapsed time calculations across long sessions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psychopy_chronos-0.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

psychopy_chronos-0.0.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file psychopy_chronos-0.0.1.tar.gz.

File metadata

  • Download URL: psychopy_chronos-0.0.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for psychopy_chronos-0.0.1.tar.gz
Algorithm Hash digest
SHA256 aeec4c6e65690e1b939f4b7e6d95cf6a9fcc1351a39610172117a64aeff5e0e6
MD5 4760a8c55d4a99663c9429eca7b14ec5
BLAKE2b-256 6d0561b606d338865974af5cef30c4d4eef2e3b1c9e9c08b2c88410579ba22b2

See more details on using hashes here.

File details

Details for the file psychopy_chronos-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for psychopy_chronos-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9791d395f1292cbc4f6c04b4db36198eb9272c881f3aca7dd1d5084a6d4d2024
MD5 9947658d5a0c0d0d7337ceff02865ddb
BLAKE2b-256 53969f454d46482562ee795995d3d1fd863d38a4e9d55bd1dd14c7a8c7e098ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page