Contributions:ResponseTimeBox
Synopsis
A logger that stores event information (button, sound, light, TTL) from the Response Time Box into BCI2000 states.

The ResponseTime Box has 4 buttons, an audio port, a light port, a TTL in, TTL out, and a USB port. Power and serial communication is supplied through the USB port. This logger deals exclusively with version v5/6. More information on this version, along with the schematics and TTL pinouts, can be found at https://lobes.osu.edu/documents/RTBox_v56_user_manual.pdf
Location
http://www.bci2000.org/svn/trunk/src/contrib/Extensions/ResponseBox
Versioning
Authors
Ryan Gladwell (gladwell@neurotechcenter.org)
Will Engelhardt (engelhardt@neurotechcenter.org)
Version History
- 2022/07/25: Initial public release
Source Code Revisions
Functional Description
Oftentimes, the reaction time of a subject is measured by calculating the interval between a stimulus and the subject's reaction. However, difficulty can arise when devices with high latency are used to collect the exact time of the subject's reaction, or when the device clock is mismatched with the computer clock. The RTBox is designed to consolidate the entire experiment by directly measuring the stimulus onset (audio or light), the button press(es), and the time interval simultaneously with essentially no latency, thereby circumnavigating the aforementioned difficulties.
Integration into BCI2000
Compile the extension into your source module by enabling contributed extensions in your CMake configuration. You can do this by going into your root build folder and opening Configure.sh.cmd. In the CMake GUI, enable EXTENSIONS_ResponseBox and then click generate. Then recompile BCI2000. Once the extension is built into the source module, enable it by including --LogResponseBox=1 along the source module line within the batch file.
Configuring ResponseBoxLogger
The ResponseBoxLogger is configured by the LogResponseBox, RTButtonPress, RTLight, RTSound, RTSensitivity, and RTCOMPort parameters. If the LogResponseBox parameter box is left unchecked, the RTBox will not be read.
The logger is written to automatically find and connect to the RTBox comport. However, if the detection process is lengthy for some reason, or if the auto-detection fails, it will be necessary for the user to enter the hardware address of the RTBox into the RTCOMPort parameter manually. Make sure the RTBox is not being used by another program before attempting to connect.
To find the hardware address for the RTBox, press WIN + R and enter devmgmt.msc. In Device Manager, expand the section labeled Ports (Com & LPT). If this section does not exist, the serial cable might not be properly connected. Find the one labeled with "USB Serial Port" (COM4). The label (COM4 in this example) is the device name, and this is what the user should enter into the RTCOMPort parameter. Included in the ResponseBox extension is the SerialPort file, which is a package that is necessary for the ResponseBox extension to connect to the RTBox and work.

Parameters
The ResponseBox is configured in the Source tab. The configurable parameters are:
LogResponseBox- This parameter is a boolean that enables or disables all response box functions.RTButtonPress- This parameter is a boolean that enables or disables all button press or release events.RTLight- This parameter is a boolean that enables or disables any light detection by a photodiode in the light port.RTSound- This parameter is a boolean that enables or disables any sound detection by the sound portRTSensitivity- This parameter is an enumeration that sets the sensitivity of the light and sound ports. The higher the sensitivity, the less light and sound needed to trigger an event. Background light in bright rooms can cause the photodiode to stay triggered when the sensitivity is too high, so it is better to lower the sensitivity in such a setting. However, when sensitivity is lower, sound triggers need to be higher, so if one intends to use both light and sound, they ought to balance the sensitivity. This is why "More" sensitive is the default setting, because it allows for both sound detection and light detection in a bright room.RTCOMPort- This parameter sets the comport connection that the RTBox is connected to. Entering "auto" will cause BCI2000 to attempt to automatically find and connect to the RTBox comport. However, if "auto" fails, the user will need to manually input the RTBox comport address.
State Variables
Button1
This state has a value of 1 when button 1 is pressed, or when TTL pin 1 is stimulated, and 0 when released.
Button2
This state has a value of 1 when button 2 is pressed, or when TTL pin 2 is stimulated, and 0 when released.
Button3
This state has a value of 1 when button 3 is pressed, or when TTL pin 3 is stimulated, and 0 when released.
Button4
This state has a value of 1 when button 4 is pressed, or when TTL pin 4 is stimulated, and 0 when released.
Light
This state will spike to value 1 when the photodiode detects light, or when TTL pin 6 is stimulated, then return to 0.
Sound
This state will spike to value 1 when the sound port detects sound, or when TTL pin 5(low active) or 9(high active) are stimulated, then return to 0.
Aux
This state will spike to value 1 when TTL pin 8 is stimulated, then return to 0.
Event Time
EventTime1
This state will spike to the first 3 bytes of the current 6-byte device time whenever an event occurs (buttons, light, sound, or aux).
EventTime2
This state will spike to the last 3 bytes of the current 6-byte device time whenever an event occurs (buttons, light, sound, or aux).
Continuous Time
ConTime1
This state updates continuously along with the first 3 bytes of the 6-byte device time.
ConTime2
This state updates continuously along with the last 3 bytes of the 6-byte device time.
ParallelPort
The TTL OUT can be observed if the ParallelPortFilter extension is included. To do this, include "--LogParallelPort=LPT1 (or whichever ParallelPort is currently in use. The port can be found by looking under Ports (Com & LPT) in device manager)." More information on ParallelPortFiler can be found here: https://www.bci2000.org/mediawiki/index.php/Contributions:ParallelPortFilter. Pin outs for the TTL in DA-15 and TTL out DB-25 and specific instructions for writing to/reading from the box can be found below.