File: cedrusResponseBox.rst

package info (click to toggle)
psychopy 2023.2.4%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 124,456 kB
  • sloc: python: 126,213; javascript: 11,982; makefile: 152; sh: 120; xml: 9
file content (96 lines) | stat: -rw-r--r-- 3,126 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
.. _cedrusButtonBox:

Cedrus Button Box Component
---------------------------------

This component allows you to connect to a Cedrus Button Box to collect key presses.

Before using your Cedrus response box make sure to install the `required drivers <https://cedrus.com/support/rbx30/tn1042_install_rbx30_win.htm>`_. From there, your response box should plug straight into your USB port! 

Properties
~~~~~~~~~~~~

Name : string
    Everything in a |PsychoPy| experiment needs a unique name. The name should contain only letters, numbers and underscores (no punctuation marks or spaces).

Start :
    The time that the button box is first read. See :ref:`startStop` for details.

Stop :
    Governs the duration for which the button box is first read. See :ref:`startStop` for details.

Force end of Routine : true/false
    If this is checked, the first response will end the routine.

Data
====
What information to save, how to lay it out and when to save it.

Allowed keys : None, or an integer, list, or tuple of integers 0-7
    This field lets you specify which buttons (None, or some or all of 0 through 7) to listen to.

Store : (choice of: first, last, all, nothing)
    Which button events to save in the data file. Events and the response times are saved, with RT being recorded by the button box (not by |PsychoPy|).

Store correct : true/false
    If selected, a correctness value will be saved in the data file, based on a match with the given correct answer.

Discard previous : true/false
    If selected, any previous responses will be ignored (typically this is what you want).

Hardware
========
Parameters for controlling hardware.

Device number: integer
    This is only needed if you have multiple Cedrus devices connected and you need to specify which to use.

Use box timer : true/false
    Set this to True to use the button box timer for timing information (may give better time resolution)

Data output
~~~~~~~~~~~~

buttonBox.keys : A list of keys that were pressed (e.g. 0, 1, 2 ...)

buttonBox.rt : A list of response times for each keypress


Special use cases
~~~~~~~~~~~~~~~~~~~~~

If you want to detect both key presses and key lifts from your cedrus response box, at the moment you will need to use custom code. Add a code component to your Routine and in the Begin Experiment use:

.. code-block::
    
    import pyxid2 as pyxid

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

    dev = devices[0] # get the first device to use


Then in the Each Frame tab use:

.. code-block::
    
    dev.poll_for_response()
    if dev.response_queue_size() > 0:
        response = dev.get_next_response()
        print(response)


The printed response will return if the key is being pressed (i.e. a key down event) or not (i.e. a key up event):

.. code-block::

    {'port': 0, 'key': 0, 'pressed': True, 'time': 953}
    {'port': 0, 'key': 0, 'pressed': False, 'time': 1298}
    {'port': 0, 'key': 0, 'pressed': True, 'time': 2051}
    {'port': 0, 'key': 0, 'pressed': False, 'time': 3140}


.. seealso::

	API reference for :class:`~psychopy.hardware.iolab`