rusocsci package

Submodules

rusocsci.buttonbox module

RuSocSci module for the BITSI buttonbox

Copyright (C) 2013-2014 Wilbert van Ham, Radboud University Nijmegen Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.

class rusocsci.buttonbox.Buttonbox(id=0, port=None)[source]

Bases: object

Object that connects tot RuSocSci BITSI buttonbox. Typical usage:

from rusocsci import buttonbox

bb = buttonbox.Buttonbox() # connect to last inserted buttonbox

print("Press any key")
l = bb.waitKeys(10)
if l:
        print("key pressed: {}".format(l[0]))
else:
        print("no key pressed.")

or for non-blocking input (using the Python 3 print function):

from __future__ import print_function
from rusocsci import buttonbox
import time, sys

bb = buttonbox.Buttonbox() # connect to last inserted buttonbox

print("Press any key")
while not len(bb.getKeys()): # while there is no input
        print(".", end='')
        sys.stdout.flush()
        time.sleep(1)
clearEvents()[source]

Clear previous events that are still in the input buffer.

close()[source]
getButtons(buttonList=None)[source]

Returns a list of buttons that were pressed on the buttonbox.

Parameters:
buttonList : None or []

Allows the user to specify a set of keys to check for. Only keypresses from this set of keys will be removed from the keyboard buffer. If the keyList is None all keys will be checked and the key buffer will be cleared completely. NB, pygame doesn’t return timestamps (they are always 0)

timeStamped : False or True or Clock

If True will return a list of tuples instead of a list of keynames. Each tuple has (keyname, time). If a core.Clock is given then the time will be relative to the Clock‘s last reset there is no timestamp in our buttonbox. Use buttonbox.waitkeys if you want timestamps.

getKeys(keyList=None)[source]

Mutatis Mutandis identical to getButtons

sendMarker(markers=[False, False, False, False, False, False, False, False], val=None)[source]

Mutatis Mutandis identical to setLeds()

setLeds(leds=[False, False, False, False, False, False, False, False], val=None)[source]

Set buttonbox LEDs to a certain pattern

waitButtons(maxWait=inf, buttonList=None, timeStamped=False, flush=True)[source]

Same as getButtons(), but halts everything (including drawing) while awaiting input from buttonbox. Implicitly clears buttonbox, so any preceding buttonpresses will be lost.

Parameters:
maxWait : any numeric value.

Maximum number of seconds period and which buttons to wait for. Default is float(‘inf’) which simply waits forever.

buttonList:

List of one character strings containing the buttons to react to. All other button presses will be ignored. Note that for BITSI buttonboxes the buttons are identified by capital letters upon press and by lower case letters upon release.

Returns None if times out. Returns a list of one character upon succes, like the PsychoPy event module.

waitKeys(maxWait=inf, keyList=None, timeStamped=False)[source]

Mutatis Mutandis identical tot waitButtons

waitLeds(leds=[False, False, False, False, False, False, False, False], wait=1.0, val=None)[source]

Set buttonbox LEDs to a certain pattern and wait a while. Reset afterwards.

rusocsci.experiment module

RuSocSci module for the BITSI buttonbox

Copyright (C) 2013-2015 Wilbert van Ham, Radboud University Nijmegen Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.

class rusocsci.experiment.Experiment[source]

Bases: object

Experiment Handler

rusocsci.extended module

RuSocSci module for the BITSI extended buttonbox

Copyright (C) 2013,2014 Wilbert van Ham, Radboud University Nijmegen Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.

class rusocsci.extended.Extended(id=0, port=None)[source]

Bases: rusocsci.buttonbox.Buttonbox

calibrateSound()[source]
calibrateVoice()[source]
send(val)[source]

Set buttonbox LEDs to a certain pattern

sendMarker(leds=[False, False, False, False, False, False, False, False], val=None)[source]
setLeds(leds=[False, False, False, False, False, False, False, False], val=None)[source]

connect leds to signals output by computer

waitSound(maxWait=inf, flush=True, buttonList='S')[source]
waitVoice(maxWait=inf, flush=True, buttonList='V')[source]

rusocsci.joystick module

RuSocSci module for the red joystick

Copyright (C) 2013 Wilbert van Ham, Radboud University Nijmegen Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.

Known issues:
  • All usb2serial devices are detected. The list of joysticks therefore also contains buttonboxes.
class rusocsci.joystick.Joystick(id=0, port=None)[source]

Typical usage:

from rusocsci import joystick
import time

nJoys = joystick.getNumJoysticks() # to check if we have any
id=0
joy = joystick.Joystick(id)#id must be <= nJoys-1

while True:#while presenting stimuli
        x = joy.getX()
        time.sleep(1)
clearEvents()[source]
getAllAxes()[source]

Get a list of all current axis values

getAxis(axisId)[source]

Get the value of an axis by an integer id (from 0 to number of axes-1)

getNumAxes()[source]

Returns the number of joystick axes found

getNumHats()[source]

Get the number of hats on this joystick

getX()[source]

Returns the value on the X axis (equivalent to joystick.getAxis(0))

rusocsci.joystick.getNumJoysticks()[source]

” Return a count of the number of joysticks available. This really returns a count of all usb to serial devices

rusocsci.utils module

RuSocSci module for utilities, like listing USB to serial devices and connecting to them.

# Copyright (C) 2013 Wilbert van Ham, Radboud University Nijmegen # Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.

Known issues:
  • All usb to serial devices are detected. The list of devices therefore contains joysticks, buttonboxes and other usb to serial devices.
class rusocsci.utils.HideStderr(*args, **kw)[source]

Bases: object

A context manager that blocks stderr for its scope, usage:

from rusocsci import utils
import os
with utils.HideStderr():
        os.system('ls noexistentfile') # error will not show
class rusocsci.utils.HideStdout(*args, **kw)[source]

Bases: object

A context manager that blocks stdout for its scope, usage:

from rusocsci import utils
import os
with utils.HideStdout():
        os.system('ls -l') # output will not show
rusocsci.utils.getPort(id=0, port=None)[source]

Return serial port. id is position in list (0 is latest), port is ‘COM1’, /dev/tty, 0 or something similar. Note that port can also be a real serial port (non USB). returns serial connection and id string.

rusocsci.utils.open(port)[source]

Open serial port. port is ‘COM1’, /dev/tty, 0 or something similar. Note that port can also be a real serial port (non USB). returns serial connection and id string.

rusocsci.utils.serialList()[source]

Get a list of USB to serial devices connected. The returned list is that of the serial ports.

Module contents