Skip to main content
Skip table of contents

RESPONSEPixx

class responsepixx.ButtonListener(RPxName, buffBaseAddr=12000000, numBuffFrames=1000)

Bases: object

A convenient class to create button listeners for RESPONSEPixx button boxes.

Parameters:
  • RPxName (str) –

    uniquely identifies which RESPONSEPixx device is being used. This is used to

    define a dictionary that maps button numbers to button color strings. Accepted values (not case sensitive):

      1. ’handheld’

      1. ’handheld - mri’

      1. ’dual - mri’

      1. ’dual handheld’

      1. ’mri 10 button’

  • buffBaseAddr (int) – the memory address of the digital input log buffer in DATAPixx RAM. see pypixxlib._libdpx.DPxSetDinLog() (default = 12000000)

  • numBuffFrames (int) – the digital input log buffer size in frames. see pypixxlib._libdpx.DPxSetDinLog() (default = 1000)

__logStatus__

the logStatus dictionary created by pypixxlib._libdpx.DPxSetDinLog()

Type:

dict

__newData__

an index for new entries in the logStatus circular buffer

Type:

int

__logs__

all unique button events since most recent update. May be updated indefinitely

Type:

list

__logsTotal__

all unique button events since instantiation. May be updated indefinitely

Type:

list

__states__

Booleans indicating whether each button (i.e., digital input pin) is currently in the ‘on’ state. These are initialized using the digital input values.

Type:

list

__buttonDict__

maps button numbers (int) to button colors (str)

Type:

dict

__mri__

flag indicating whether an MRI safe RESPONSEPixx box is being used. This is necessary as MRI safe boxes have the opposite ground state

Type:

bool

__startTime__

time of RPixxListener instantiation in VPixx box time

Type:

float

__RPxName__

the type of RESPONSEPixx device being used

Type:

str

Exceptions:
  1. misspecified RPxName (see Arguments)

getAllButtonActivity(buttonSubset=None, numLogs=None, push=True, release=False)

This function allows the user to easily query all unique RESPONSEPixx button events since the instantiation of the RPixxListener object. This function does not actually update the Din logs.

Parameters:
  • buttonSubset (list) –

    indicates which buttons to return from the activity log.

    buttonSubset is passed through __ensureButtonSubsetIntegrity__(), which strictly ensures that it is a list of integers buttonSubset can be passed as either

    1. omitted (defaulted to None), which specifies to use all buttons

    2. a single integer

    3. a list of integers

  • numLogs (int) – indicates how many of the total list of logs to return starting backwards from the most recent log

  • push (bool) – indicates whether to include button pushes in the activity log. (default = True)

  • release (bool) – indicates whether to include button releases in the activity log. (default = True)

Returns:

Each element of the list is a unique, new RESPONSEPixx button event.

Each element is itself a list with 3 elements: [timestamp (float), button number (int), push/release (str)]

Return type:

list

Exceptions:
  1. if numLogs is not a single, positive integer

getButtonString(buttonSubset=None)

A method for returning a list of strings that give a description of all the RESPONSEPixx button(s) indicated by buttonSubset. The buttons specified in buttonSubset are used to retrieve the button strings from the __buttonDict__ attribute of this class.

Arugments:
buttonSubset (list): indicates which buttons to return from the activity log.

buttonSubset is passed through __ensureButtonSubsetIntegrity__(), which strictly ensures that it is a list of integers buttonSubset can be passed as either

  1. omitted (defaulted to None), which specifies to use all buttons

  2. a single integer

  3. a list of integers

Returns:

Each element in the list is a string, where the ith element describes

the ith button in the buttonSubset (e.g., “white button”)

Return type:

list

getNewButtonActivity(buttonSubset=None, push=True, release=False)

This function allows the user to easily query all unique RESPONSEPixx button events since the most recent call to updateLogs(). This function does not actually update the Din logs.

Parameters:
  • buttonSubset (list) –

    indicates which buttons to return from the activity log.

    buttonSubset is passed through __ensureButtonSubsetIntegrity__(), which strictly ensures that it is a list of integers buttonSubset can be passed as either

    1. omitted (defaulted to None), which specifies to use all buttons

    2. a single integer

    3. a list of integers

  • push (bool) – indicates whether to include button pushes in the activity log. (default = True)

  • release (bool) – indicates whether to include button releases in the activity log. (default = True)

Returns:

Each element of the list is a unique, new RESPONSEPixx button event.
Each element is itself a list with 3 elements:

[timestamp (float), button number (int), push/release (str)]

Return type:

list

getRPixxName()

Simply returns the name of the RESPONSEPixx type. This was passed to ButtonListener upon instantiation.

Returns:

name of the RESPONSEPixx device type.

Return type:

self.__RPxName__ (str)

getStartTime()

Simply returns the time of this ButtonListener was instantiated. Time stamp is grabbed from the DPx box.

Returns:

time stamp for when this object was instantiated in DPx time.

Return type:

self.__startTime__ (float)

isButtonActive(buttonSubset=None)

A fast and simple method for returning a list of Booleans indicating whether RESPONSEPixx button(s) are currently active since the most recent call to updateLogs(). This function does not update the Din logs.

Arugments:
buttonSubset (list): indicates which buttons to return from the activity log.

buttonSubset is passed through __ensureButtonSubsetIntegrity__(), which strictly ensures that it is a list of integers buttonSubset can be passed as either

  1. omitted (defaulted to None), which specifies to use all buttons

  2. a single integer

  3. a list of integers

Returns:

Each element in the list is a bool, where the ith element indicates whether

the ith button in the buttonSubset is active

Return type:

list

isListening()

Query whether the DATAPixx digital inputs are currently being logged.

Returns:

indicates whether the Din logs are running

Return type:

(bool)

pause()

Stop the current Din log.

resume()

Start the current Din log.

setButtonLEDs(buttonSubset=None, state=None, strength=1.0)

A method for flipping the state of the RESPONSEPixx button LED(s) indicated by buttonSubset.

Arugments:
buttonSubset (list): indicates which buttons to return from the activity log.

buttonSubset is passed through __ensureButtonSubsetIntegrity__(), which strictly ensures that it is a list of integers buttonSubset can be passed as either

  1. omitted (defaulted to None), which specifies to use all buttons

  2. a single integer

  3. a list of integers

state (any): indicates the how to adjust the state of the LED lights. If omitted, it is

defaulted to None, which will flip the state of the LEDs with respect to their current state. If this argument is provided, it will be casted to bool. If it cannot be casted to bool, this will raise an Exception. If state is True, this will ensure that the LEDs are turned on, regardless of their current state. If state is False, this will ensure that the LEDs are turned off, regardless of their current state. (default = None)

strength (float): indicates the brightness of the LED lights. Must be between

0 and 1. Values out side this range will elicit a warning. Values less than 0 will be defaulted to 0. Values greater than 1 will be defaulted to 1. (default = 1.0)

Exceptions:
  1. if argument ‘state’ cannot be casted to bool data type.

  2. if argument ‘strength’ cannot be casted to float data type. These would raise errors in DPxSetDinDataOutStrength() anyways, so may as well catch them here and give detailed feedback.

updateLogs()

This function allows the user to update the digital input log. They can therefore query the same digital input log multiple times without overwriting them.

This function may update the values of

__logs__ and __logsTotal__

waitForButton(buttonSubset=None, timeOut=inf)

This function allows the user to drop a blocking command whereby execution pauses until one or more unique RESPONSEPixx button(s) are activated. This function does update the Din logs. These updates cannot create conflicts, as this is a blocking function and no other queries can occur concurrently.

Parameters:
  • buttonSubset (list) –

    indicates which buttons to return from the activity log.

    buttonSubset is passed through __ensureButtonSubsetIntegrity__(), which strictly ensures that it is a list of integers buttonSubset can be passed as either

    1. omitted (defaulted to None), which specifies to use all buttons

    2. a single integer

    3. a list of integers

  • timeOut (float) – reaction time in seconds after which this blocking function terminates

Returns:

the reaction time of the button press in seconds

Return type:

rt (float)

Exceptions:
  1. if argument ‘timeOut’ cannot be casted to float data type or is less than zero. Detailed feedback is given.

This helper class is documented directly in the python file. See responsePixx.py for more information.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.