Skip to main content

Python library for interfacing with Cedrus XID devices, e.g. StimTracker, RB-x40, c-pod, and Lumina.

Project description

Python library for communicating with all Cedrus XID devices: StimTracker, RB-x40 response pads, c-pod, Lumina, and SV-1.

XID (eXperiment Interface Device) devices are used with software such as SuperLab, Presentation, and E-Prime for receiving input as part of stimulus/response testing experiments.

This handles all of the low level device handling for XID devices in python projects. The developer using this library must poll the attached device(s) for responses. Here's an example of how to do so, followed by an example of how to send a series of TTL signals:

import pyxid2
import time

# get a list of all attached XID devices
devices = pyxid2.get_xid_devices()

dev = devices[0] # get the first device to use
print(dev)
dev.reset_base_timer()
dev.reset_rt_timer()

# If you're trying to collect responses from a StimTracker Duo/Quad,
# you'll have to enable USB output for the appropriate response type.
# You can read about it here https://cedrus.com/support/xid/commands.htm
# in the SIGNAL FILTERING & FLOW section.
#dev.enable_usb_output('K', True)

# Note that not all XID commands are implemented in this library. You
# can send any arbitrary string to the XID device if you need one of the
# unimplemented commands, like so (second arg is return bytes expected):
#dev._send_command('iuK1', 0)

if dev.is_response_device():
    print ("Press a key!")
    while not dev.has_response():
        dev.poll_for_response()

    response = dev.get_next_response()
    print(response)
    dev.clear_response_queue()

dev.set_pulse_duration(300)

sleep_flash = .3
for bm in range(0, 16):
    mask = 2 ** bm
    print("activate_line bitmask: ", mask)
    #dev.activate_line(lines=[1,3,5,7,9,11,13,15])
    dev.activate_line(bitmask=mask)

    time.sleep(sleep_flash)

The response is a python dict with the following keys:

port: Device port the response was from (typically 0)
key: Response pad key pressed by the subject
pressed: True if the key was pressed, False if it was released
time: value of the Response Time timer when the key was pressed/released

Sending a TTL pulse signal via the library can be done via the following methods:

set_pulse_duration()
activate_line()
clear_line()

See the docstring for activate_line() for documentation on how to use it.

Timers

Each XID device has an internal timer. This timer can be reset via a USB command or automatically on the onset of a light sensor or onset of audio.

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

pyxid2-1.0.3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

pyxid2-1.0.3-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file pyxid2-1.0.3.tar.gz.

File metadata

  • Download URL: pyxid2-1.0.3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

File hashes

Hashes for pyxid2-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b7da934c40ba3f38c081dcd93ea0241836560424ef84d5b13937928269e5115b
MD5 8cc27e1212529575f3df331ca17fc18d
BLAKE2b-256 561fdddfcf39acbf5bb2bd54e8843c555d0614970509bcb636049e6c8b2f88e7

See more details on using hashes here.

File details

Details for the file pyxid2-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pyxid2-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

File hashes

Hashes for pyxid2-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9317e83dc6e16c500467c5b35d526ee6d92b76dcf0bdb86b8af655ff42ce2f12
MD5 4c54e75c80ce88bddd9b16c9870b3c79
BLAKE2b-256 8408cf44ba85776b945da05262ff3992c1e82997aa20d37530abd337ac780158

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