Jump to content

User Reference:BCI2000Certification: Difference between revisions

From BCI2000 Wiki
Awilson (talk | contribs)
 
(89 intermediate revisions by 8 users not shown)
Line 1: Line 1:
==Introduction==
==Introduction==
BCI2000 v2.0 and higher includes a certification procedure that can determine whether a computer system is capable of running all or some BCI2000 applications.  Because BCI2000 does not have a standardized hardware configuration, i.e., it can run on potentially ''any'' PC, this testing procedure is capable of running on any PC with BCI2000, with the results reporting which standard BCI2000 applications meet the minimum timing requirements. Different configurations are included in the certification procedure to test a range of likely setups for a given application, in which timing characteristics such as the sampling rate, inter-stimulus intervals, and stimulus duration, and other parameters, such as the number and size of the stimuli, are changed for each configuration.
BCI2000 includes a certification procedure that can determine whether a computer system is capable of running all or some BCI2000 applications.  Because BCI2000 does not have a standardized hardware configuration, i.e., it can run on potentially ''any'' PC, this testing procedure is capable of running on any PC with BCI2000, with the results reporting which standard BCI2000 applications meet the minimum timing requirements. Different configurations are included in the certification procedure to test a range of likely setups for a given application, in which timing characteristics such as the sampling rate, inter-stimulus intervals, and stimulus duration, and other parameters, such as the number and size of the stimuli, are changed for each configuration.


This document serves as the instruction manual for using the certification procedure, and describes how the procedure works to determine the timing characteristics of the BCI2000 system. The primary use for the certification procedure is to determine if the PC configuration used with BCI2000 is capable of running the core BCI2000 system, which is comprised of:
This document serves as the instruction manual for using the certification procedure, and describes how the procedure works to determine the timing characteristics of the BCI2000 system. The primary use for the certification procedure is to determine if the PC configuration used with BCI2000 is capable of running the core BCI2000 system, which is comprised of:
    
    
*Support for the the g.tec series of amplifiers, including the g.USBamp, g.MOBIlab, and the g.MOBIlab+ (bluetooth) amplifiers.
*Support for various biosignal amplifiers, including the g.USBamp, EGI GTEN 200, Nihon Kohden JE120-A, and many more on the [[Contributions:ADCs|ADCs]] page.  
*The AR, P3, FFT, and Matlab signal processing modules.   
*The AR, P3, FFT, and Matlab signal processing modules.   
*The CursorTask, P3Speller, and StimulusPresentation application modules.   
*The CursorTask, P3Speller, and StimulusPresentation application modules.   


Additionally, due to the extensibility of BCI2000, researchers who develop custom algorithms and applications, or use amplifiers not made by g.tec, can use the certification procedure to determine whether their custom modules are capable of running on a particular PC configuration.
Additionally, due to the extensibility of BCI2000, researchers who develop custom algorithms and applications can use the certification procedure to determine whether their custom modules are capable of running on a particular PC configuration.


The certification procedure works by comparing the differences in time of when BCI2000 ''expects'' an event to occur to when that event ''actually'' occurred. These events include a change in the display, an audio output through the system speakers, or an EEG sample being stored in the amplifier buffer. The times at which such events occur are recorded with the amplifier and stored in a data file. Changes in the display are found using an optical sensor in combination with the g.TRIGbox. The g.TRIGbox is a signal conditioner that generates trigger pulses for various sensors or input signals. When the sensor exceeds a threshold, the g.TRIGbox outputs a digital signal which is recorded on the amplifier. A similar procedure is used for audio detection: the sound output from the PC is input to the g.TRIGbox, and when the volume exceeds threshold, a high digital signal is output and recorded by the amplifier. This information can be used because BCI2000 stores a time-stamp for every event during an experiment. The difference between a time-stamp value and the time that the recorded event changes values are compared to find the latency for that particular event.  
The certification procedure works by comparing the differences in time of when BCI2000 ''expects'' an event to occur to when that event ''actually'' occurred. These events include a change in the display, an audio output through the system speakers, or an EEG sample being stored in the amplifier buffer. The times at which such events occur are recorded with the amplifier and stored in a data file. Changes in the display are found using an optical sensor and a triggering device. The documentation provided throughout this page uses the g.tec g.TRIGbox, although any device which can provide a digital or analog trigger to the amplifier can be used. The g.TRIGbox is a signal conditioner that generates trigger pulses for various sensors or input signals. When the sensor exceeds a threshold, the g.TRIGbox outputs a digital or analog signal which is recorded on the amplifier. A similar procedure is used for audio detection: the sound output from the PC is input to the g.TRIGbox, and when the volume exceeds threshold, a digital or analog signal is output and recorded by the amplifier. This information can be used because BCI2000 stores a time-stamp for every event during an experiment. The difference between a time-stamp value and the time that the recorded event changes values are compared to find the latency for that particular event.  


These latencies can be affected by many external influences, including hardware deficiencies (such as low RAM, slow CPU speed, or a video card of low quality), and other software running in the background while the experiment is being run.
These latencies can be affected by many external influences, including hardware deficiencies (such as low RAM, slow CPU speed, or a video card of low quality), and other software running in the background while the experiment is being run.


==Latencies==
This document serves as the BCI2000Certification manual. As an example, this page will describe the certification procedure for the g.USBamp with visual and auditory stimuli triggered with the g.TRIGbox. At the end of the page, the certification results for using BCI2000 with three biosignal amplifiers (the g.USBamp, EGI GTEN 200, and Nihon Kohden JE120-A) are provided. A discussion and derivation of the specific system latencies are found [https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3161621/ here].
Briefly, the different latencies inherent in the BCI2000 system include amplifier latency, processing latency, output latency, and the sum of these, the system latency. Additionally, the block duration jitter will be measured.  The figure below provides a timeline of events that occur within a single block of data, with significant time points labeled. This figure provides an accurate account of the order in which events occur within a block of data, although the time intervals are not necessarily to scale.
==Video Demonstration==
<span id="TimeLine"></span>
<youtube alignment="center">https://youtu.be/yh7ifhCh2v0</youtube>
==Compiling the BCI2000Certification Programs==
The BCI2000Certification procedure actually consists of two separate programs, including a graphical user interface that simplifies the task of selecting and starting tests, and a program that performs the data analysis and returns results. These programs are compiled automatically with the other BCI2000 programs. Compilation is only supported in BCI2000 v3.0 with the Visual Studio or MinGW compilers. Instructions can be found at [[Programming_Howto:Building_BCI2000]]. At the point where you start CMake, be sure to check BUILD TOOLS in the BUILD menu.


[[Image:timeline3.png|frame|none|Timeline of events. Time intervals are not to scale.]]
[[image:CMakeBuildTools.png|frame|none|Check the BUILD TOOLS box to build the certification tester and analysis tool.]]


===Defining Latencies===
==Using the BCI2000Certification Procedure==
====Amplifier Latency====
===Starting the Tester User Interface===
Amplifier Latency is the minimum delay between the time that a signal is presented at the amplifier input, to when it has been acquired in the source module. Depending on configuration, this may comprise physical signal delay in the amplifier, digitization, transmission from the amplifier to the PC, and processing time inside a hardware driver. That minimum delay occurs for the last sample of a data block, which, unlike its preceding samples in the same block, will spend only a minimum time in hardware and software buffers. In [[#TimeLine|Timeline]],
# The compiled programs can be found in <code>BCI2000/tools/BCI2000Certification</code>.  
# Navigate to this folder, and double-click the <code>BCI2000CertificationTester.exe</code> file.
# The certification tool opens, as below.


Amplifier latency = <math>t_{0}-t_{-1}</math>.
This program shows a list of all of the procedures to be tested for the loaded configuration. Detailed instructions for using the interface follow.


For amplifiers connected via bandwidth-limited serial interfaces, transmission latency may have a measurable impact on amplifier latency, depending on the hardware. When using USB 2.0, as is the case for the g.USBamp, transmission latency may generally neglected, as illustrated by the following example: USB 2.0 has a maximum transmission rate of 480 Mbit/s. If we are acquiring 16 channels of 32-bit data, and transmitting in blocks of 16 samples, this is 8192 bits of data; at USB 2.0 speed, this should take roughly 17 <math>\mu</math>s to transfer. However, a more realistic approximation for USB 2.0 speeds is 240 Mbit/s, which increases the transfer delay to 34 <math>\mu</math>s. For sampling rates below 30 kHz, this is less than a single sample's duration.
[[image:Certificationtool.png|frame|none|The BCI2000Certification user interface.]]
[[image:Tester02.PNG|frame|none|The BCI2000Certification user interface.]]


In addition to amplifier latency, system performance will be influenced by buffering latency. Buffering latency is dependent on the sample block buffer size: When a data sample is digitized, it is not immediately transferred to the PC, but is stored in memory on the amplifier. The PC then makes the appropriate request to the amplifier, and a block of data is transferred all at once to reduce the processing load. This implies that a signal that is digitized at the start of the buffer must wait until the buffer is full to be read into the PC. For example, if the sample block size is 16 samples, the first sample must wait 15 more samples before it can be used in the application. Fortunately, this latency is always known, and can be reduced with a higher sampling rate and/or smaller block sizes, assuming the PC can handle the increased overhead. Buffering latency does not affect the acquisition-to-display latency, because processing occurs immediately after a block's last sample, which is not affected. Still, it is an important factor to keep in mind, because a large sample block size and/or a small sample rate will decrease the refresh rate for the application (e.g., at a sample rate of 256 Hz and a sample block size of 128 samples, the application will only be refreshed every 0.5 s.)
===Loading Configuration Files===
The BCI2000 certification procedure uses a configuration file and different combinations of BCI2000 parameter fragments to control the tests. The configuration file (stored as an <code>*.ini</code> file) describes all of the certification tests. The parameter fragments store information about the amplifier and application module applied in each test. More detail about the contents of the configuration file can be found below. While it is possible to edit these by hand, in most circumstances it is simpler to use the graphical user interface provided.  


====Processing Latency====
# In the BCI2000Certification tool, select <code>File->Open *.ini</code>
Processing Latency is the total time it takes for the data to be processed by all BCI2000 modules (SignalSource, SignalProcessing, and Application).
# Navigate to the folder <code>BCI2000/tools/BCI2000Certification</code>.
# Load the file named <code>BCI2000Certification_16ch_100ms.ini</code> if using a 16-channel system. (This tutorial assumes a 16-channel system).
# If using more than 16 channels, then the amplifier parameter files must be modified.
## Navigate to <code>BCI2000/tools/BCI2000Certification/parms/</code>, and open the file <code>Certification_gUSBamp_24.prm</code> in Notepad.
## Find the parameter titled '''DeviceIDMaster''', and replace the existing device ID (e.g., <code>UA-2007.04.12</code> with the ID of your master device.
## Next, find the parameter titled '''DeviceIDs''', and replace the IDs with the IDs of your amplifiers. The first in the list should be identical to the '''DeviceIDMaster''' value. For example, you might enter: <code>DeviceIDs= 2 UA-2007.04.12 UA-2006.10.13</code> (the \#2 corresponds to the number of devices being used).
## Repeat these steps for the file <code>Certification_gUSBamp_32.prm</code>.
## Note that these steps are not necessary if only one g.USBamp is being used.
# All 100 tests in this configuration are loaded into the GUI.


Processing latency = <math>t_{2}-t_{0}</math>.
===User Interface Components===
This section describes each user interface component, referring to the figure below.


Processing latency strongly depends on CPU speed, and if this latency becomes too large, high CPU load will probably be the cause, implying decreased or unsuitable BCI2000 performance.
[[image:Certificationtool2.png|frame|none|The BCI2000Certification user interface components.]]


====Output Latency====
====1. Configuration: Task List====
Output Latency is the latency from the time that the Application module issues a command to change the display or issue a sound (or another output), to the time that this output actually occurs.
The task list shows all tasks that have been loaded from the configuration file or created within the GUI. To run a specific test, it should have a checkmark next to it. In order to select or deselect all tasks, press the <code>Select All</code> check box at the bottom of the list.


Output latency = <math>t_{3}-t_{2}</math>.
It is possible to create new tasks, remove tasks, and copy tasks within the interface as well. To create a new task, press the <code>+</code> button. A new task is created at the bottom of the list; the task details must be filled in (described next). It is often easier to copy a similar task than to create a new one from scratch. To do so, select the desired task, and press <code>Copy</code>. The new task should be renamed appropriately. To remove a task, select a task and press the <code>-</code> button.


====System Latency====
====Creating Custom Tests====
System Latency is the minimum time interval between a change in amplifier input, and a causally related change in application output. This is the sum of the above latencies, Amplifier, Processing, and Output.  
With the BCI2000Certification tool, you can test performance on a wide range of different parameters and applications. You can create a custom .ini file that will contain the name of each test, the desired signal processing module, sampling rate, block size, application, and parameter files. You will need to first create a parameter file for the test you wish to run. If you want to be able to edit the block size and sampling rate from the Certification tester GUI or its .ini file, you must omit those variables from your parameter files as they will overwrite any variables you set in the Certification Tester. For example, if you wanted to test an application that you have developed for BCI2000 using several sampling rates and block sizes you would first need to create the two parameter files for the application, and source with no sampling rate or block size specified, then export them to the <code>/BCI2000Certification/parms/</code> folder. Once you have the two parameter files, you may link to them in a new .ini file located under the <code>/BCI2000Certification/</code> directory and run them as described below.


System latency = <math>t_{3} - t_{-1}</math>.
====2. Configuration: Task Details====
The right side of the GUI displays the details of the currently selected task. Each option is described here.


====Block Duration, Block Duration Jitter====
;Task Name
Block Duration is the time interval between adjacent blocks of data, normalized to the ideal duration of a data block as determined from sampling rate and sample block size:
:The name of the task. This must not contain any spaces, and must be unique.


Block Duration = <math>\frac{t_{5}-t_{0}}{\mathrm{SampleBlockSize}/\mathrm{SamplingRate}}</math>.
;Signal Source
:The amplifier that should be used, if different from the amplifier set in the global options. Generally, this should not need to be used, since all tasks should use the same amplifier.


When the system operates in real time, mean Block Duration will always be 1. Measuring Block Duration has the purpose of obtaining Block Duration Jitter as its standard deviation.
;Signal Processing
:The signal processing module that should be started and used for the given task. This should usually be either <code>ARSignalProcessing</code>, <code>P3SignalProcessing</code>, or <code>DummySignalProcessing</code>, depending on the specific application.


===Measuring Latencies===
;Application
The procedure for measuring the system latencies are below. In general, a combination of recorded events and software time-stamps recorded in BCI2000 data files to determine when important events occur, with ms or better time resolution.
:The application that is run for the task. This will typically be <code>CursorTask</code>, <code>P3Speller</code>, or <code>StimulusPresentation</code>
[[Image:OutTimeline1.png|thumb|500px|none|Recorded events used for measuring latencies.]]


====Measuring Amplifier Latency====
;Parameters
In [[#TimeLine|TimeLine]], Amplifier Latency is the time interval between the sampling of a data block's last sample, and its acquisition into the source module's data buffer:
:A list of the parameter fragments that should be used for this task. Typically, at least two parameter files are required. The first should be the amplifier-specific fragment that configures the amplifier for the correct number of channels. The second should be the application-specific fragment that configures how the application appears on the screen. Parameter files can be added and removed with the <code>+</code> and <code>-</code> buttons, respectively. All files should be placed in the <code>BCI2000/tools/BCI2000Certification/parms</code> folder.
<center><math>
\mathrm{AmplifierLatency} = t_{0} - t_{-1}
</math></center>


To measure this latency, the Source module will set a digital output on the amplifier to a high value at time <math>t_0</math> immediately following data acquisition, as indicated in [[#overview|Overview]]. The digital output level is 3.3 V, so a voltage divider may required to attenuate the signal level to the range of amplifier input. This signal is then recorded on an input channel on the amplifier (time <math>t_{1}</math>).
;Sample Rate
:The sampling rate that should be used for this task. Note that it must be supported by the amplifier used.


In the recorded data, we may then identify <math>t_{-1}</math>, which is the beginning of sample block <math>n</math>, by its sample offset, which also coincides with BCI2000 state changes. <math>t_1</math> may be identified by a change in the recorded signal, occurring in the channel that was connected to the digital output during measurement.
;Sample Block Size
<center><math>
:The sample block size (in samples). In the provided parameter files, the sample block size is always equal to 100ms, regardless of the sampling rate.
\mathrm{AmplifierLatency} \approx t_{0} - t_{-1}.
</math></center>


====Measuring Processing Latency====
;Amp Channel
The processing latency is defined as the amount of time that it takes for the computer to process the data after acquiring it, to when the application module output is changed. In [[#TimeLine|TimeLine]], this is the time from <math>t_{0}</math> to <math>t_{2}</math>. Processing latency is calculated using two timestamps saved with every block of data, <math>SourceTime</math> and <math>StimulusTime</math>. <math>SourceTime</math> is saved at <math>t_0</math>, immediately following data acquisition in the Source module, and <math>StimulusTime</math> is saved at <math>t_2</math> immediately following application presentation in the Application module. Therefore, processing latency for each block of data is calculated as the difference between time stamps:
:This is the analog channel that records the amplifier digital output (i.e., the digital output recorded back in on an analog channel). This signifies the onset of acquisition of a block. This value should be between 1 and the number of channels.


<center><math>
;Amp Stream
\mathrm{Processing Latency} = \mathrm{StimulusTime} - \mathrm{SourceTime} = t_{2} - t_{0}.
:This is the digital channel that records the amplifier digital output (i.e., the digital output recorded back in on a digital input channel).
</math></center>


====Measuring Application Output Latency====
;Video Channel
<span id="outOverview"></span>
:The recorded analog channel containing video event markers.
There are many possible application output types, including visual (i.e., the computer screen), audio, or mechanical (e.g., a robotic arm). The core BCI2000 system primarily uses visual and audio output, and so the default testing system will focus on these.


Both visual and audio output can be measured using the g.TRIGbox signal conditioner, which accepts inputs from optical sensors, microphones, or any other input. The user sets a threshold for the input signals, and the g.TRIGbox outputs a digital pulse whenever this threshold is exceeded. This output is then recorded back into the amplifier system, so that the analysis program can measure the response times for each output.
;Video Stream
:The recorded digital input channel containing video event markers.


We identify event <math>t_0</math> by a change in the data channel connected to the amplifier's digital output, and event <math>t_3</math> by a change in the data channel connected to the g.TRIGbox, and compute their difference. Also, both events are affected by Amplifier Latency in the same way, so we may ignore Amplifier Latency, and have
;Video State
<center><math>\begin{matrix}
:The BCI2000 state that contains the event markers for the video event, e.g., TargetCode or StimulusCode.
\mathrm{Output Latency} = t_{3} - t_{2} = (t_3-t_0)-(t_2-t_0) = (t_3-t_0)-\mathrm{ProcessingLatency}.
\end{matrix}</math></center>


====Measuring System Latency====
;Video State Values
As defined above, System Latency is the sum of Amplifier Latency, Processing Latency, and Output Latency. It is important to realize that the system latency is dependent on the output modality used, i.e., the video system latency and the audio system latency will vary on the same system due to the differences in output latencies.
:A list of state change values that should be detected by the analysis. For example, if values <code>4 11</code> are used, then the analysis tool will examine when the StimulusCode state changes to either 4 or 11, and then examine when the Video Channel changes.
The system latency may be measured
#directly, by identifying <math>t_{-1}</math> as the beginning of a data block by its sample index, and <math>t_3</math> by the signal change in the channel connected to the g.TRIGbox, and then calculating<br /><math>\textrm{SystemLatency}=t_3-t_{-1}</math>,
#or indirectly, by using the previously measured quantities<br /><math>\textrm{SystemLatency}=\mathrm{AmplifierLatency}+\mathrm{ProcessingLatency}+\mathrm{OutputLatency}</math>.


====Measuring Block Duration====
;Audio Channel
Block Duration is measured as the time between adjacent blocks of data, divided by the theoretical ideal value, which is the sample block duration. For the actual measurement, we use the difference between subsequent <math>\textrm{SourceTime}</math> time stamps which are recorded at <math>t_0</math> and <math>t_8</math> in [[#TimeLine|Timeline]]:
:The recorded analog channel containing audio event markers.


<center><math>
;Audio Stream
\mathrm{BlockDuration} = \frac{t_{5} - t_{0}}{\mathrm{SampleBlockSize}/\mathrm{SamplingRate}}
The recorded digital input channel containing audio event markers.
=\frac{\Delta \mathrm{SourceTime}}{\mathrm{SampleBlockSize}/\mathrm{SamplingRate}}
</math></center>


===Latency Calculation Overview===
;Audio State
Latencies are calculated by comparing changes in a BCI2000 state value to changes in a recorded signal. The analysis program follows these general steps in calculating the various latencies:
:The BCI2000 state that contains the event markers for the audio event, e.g., TargetCode or StimulusCode.


#Determine which threshold values to use based on the ''thresh''  definition in the BCI2000Certification.cfg file, which defines a threshold based on the amplifier used. For example, the g.USBamp has an input range of -250 mV to + 250 mV, and the g.TRIGbox outputs from 0 to 200 mV, so the threshold used is about 12.5 mV.
;Audio State Values
#Traverse the state values for a selected state and find where the state changes from 0 to a given value (or any value). The sample at which this occurs is saved for later use in <math>stateChangePos</math>.
:A list of state change values that should be detected by the analysis. For example, if values <code>4 11</code> are used, then the analysis tool will examine when the StimulusCode state changes to either 4 or 11, and then examine when the Video Channel changes.
#When this occurs, start looking through <math>Signal_{norm}</math> to find when a rising edge exceeds the determined threshold value. The sample at which this occurs is saved in <math>sigChangePos</math>.
#The latency for the <math>n</math>th state change is calculated as:
#:<center><math>\begin{matrix}
latency_n = \frac{sigChangePos_n-stateChangePos_n}{SampleRate}
\end{matrix}</math></center>
#:and is stored in an array.
#Once the entire state vector is traversed, the mean, standard deviation, minimum and maximum values for this latency are calculated and reported.


==Getting Started With the Default Tests==
====3. Control: Global Settings====
This section provides step-by-step instructions on running the default certification procedure. Note that some cables must be assembled before the testing can be done; see the end of this document for information on assembling the cables.
[[image:Tester02.PNG|frame|none|The BCI2000Certification user interface.]]
As the name suggests, the options under Global Settings are applied to all tasks, and are described here.


===Set Default Parameters===
;Window Left, Top
Using a text editor, open the CertificationMain.prm file in the BCI2000/tools/BCI2000Certification/parms/ folder. Many of the settings should be left alone, except for some of the following cases.  
:The position of the left and top sides of the application window. If using multiple monitors, this position should take this into account. For example, if the application window is to the right of the main monitor, and the main monitor has a resolution of 1280x1024 pixels, then <code>Window Left</code> should be set to 1280, and <code>Window Top</code> to 0.


====Sampling Rate====
;Window Width, Height
This is set to 512 by default. This can be changed to another value that will apply to all tests, except those that explicitly override it in their own parameter file.
:The width and height of the application window.


====Display parameters====
;Global Signal Source
These are on the lines that begin with <code>Application:Window</code>. For many labs, the default settings should work fine; the window is setup to appear in the top-left corner of the main window (<code>WindowLeft= 0</code> & <code>WindowTop= 0</code> ), and is 800 wide by 800 pixels tall (<code>WindowWidth= 800</code> & <code>WindowHeight= 800</code> ).
:The executable that should be used by all applications. This value is overwritten by the Signal Source value set for individual tasks.


Users with a dual-screen configuration may wish to change this so that the BCI2000 window is on the secondary monitor; to do so, the <code>WindowLeft</code>  parameter should be changed, which depends on the resolution and orientation of both monitors. For example, if the 2nd monitor is to the right of the primary monitor, and both monitors have a resolution of 1280x1024 pixels, setting <code>WindowLeft</code>  to <code>1280</code>  will place the window on the 2nd monitor. Similarly, if the 2nd monitor is to the left of the primary monitor, setting <code>WindowLeft</code>  to <code>-1280</code> will accomplish the same thing. If the monitors have different resolutions (e.g., monitor 1 is 1600x1200 and monitor 2 is 1024x768, located to the right of the 1st monitor), the position should change accordingly. For example, in this scenario, to set the window to the right of the main window, set <code>WindowLeft</code>  to <code>1600</code> . Finally, set the <code>WindowWidth</code> & <code>WindowHeight</code>  to appropriate values for full-screen, if desired. To summarize, for the dual-screen case in which monitor 1 is 1600x1200 pixels, and monitor 2, to the right of 1, is 1024x768 pixels, and the BCI2000 window should be full-screen on monitor 2, the parameters should look like:
;Data Output Directory
:The directory where all of the data should be saved during the task. This will appear relative to <code>BCI2000/tools/BCI2000Certification/</code>, or at a given absolute path. '''NOTE that if data already exists in this directory, additional data will be saved to it!''' To avoid combining new data with earlier results, the existing directory with the same name should be renamed or deleted.
<code>Application:Window int WindowWidth= 1024 ...<br>
Application:Window int WindowHeight= 768 ...<br>
Application:Window int WindowLeft= 1600 ...<br>
Application:Window int WindowTop= 0 ...<br>
</code>
Note that nothing following the ... needs to be changed above in the parameter file.


===Connect the Amplifier to the Trigger Box, and Attach Sensors===
;BCI2000 Directory
[[Image:connections.png|frame|none|Connections overview]]
:This is the directory containing the BCI2000 program files, e.g., <code>C:\BCI2000\prog</code>


This section describes the steps for connecting the necessary hardware. Refer to the Connections Overview figure above for additional information; each step is numbered in this figure.
;Additional Application Module command line arguments
:Additional arguments to add to the command line when starting the application module.


#Connect the amplifier to the computer; the supported g.tec amps are connected via USB, RS232, or Bluetooth.
;Shell execute before
#Connect the Digital I/O cable (see bottom of this document) to the amplifier on the Digital I/O port.
:Execute command in the shell before running the experiment (e.g., ''taskkill /IM explorer'' to terminate the explorer shell and taskbar).
#Connect the reference and ground wires from the assembled amplifier cables to the amplifier reference and ground connections.
#Connect the amplifier cables with the safety connectors into channels 1, 2, and 3 on the g.USBamp.
#Connect the digital output line to the channel 1 amplifier cable.
#Connect the A output from the trigger box to the channel 2 amplifier cable.
#Connect the B output from the trigger box to the channel 3 amplifier cable.
#Connect the optical sensor plug to the g.TRIGbox, using the optical sensor input channel A.
#Connect the computer audio output using a stereo cable to the g.TRIGbox, using the high-level input channel B.


===Setup Sensor Thresholds===
;Shell execute after
The audio and optical sensors each have a threshold setting on the g.TRIGbox, along with an LED indicating whether the current input is above threshold for each channel. At rest, each trigger should be off; if any is on, turn the threshold knob counter-clockwise until the LED is off.
:Execute command in the shell after the experiment has finished.


====Audio Threshold====
====4. Control: Controls====
To set the audio threshold, set audio volume on the computer to maximum. On Windows, to make this process easier in the future, go to the Start menu, click the Control Panel, and go to Sounds. In the Sound window, click the box that puts the volume icon in the task bar. A small speaker should now appear in the bottom-right of the screen in the task bar. Click this icon, and slide the volume up to the max; when you click on this slider, Windows emits a short beep to give an idea of the volume level, which can be used to set the threshold. To do so, make sure that the stereo audio cable is plugged into the g.TRIGbox, and click the slider to emit a sound, checking that the green LED is flashing when you click the slider. If it is not, turn the threshold knob for channel B counter-clockwise, and click the slider again. If it is still not working after several tries, unplug the audio cable from the computer, and check that you can hear the beep through the speakers. If you cannot, make sure that the sound is not muted, and that the sound drivers are properly installed. If you can hear it, plug the audio cable back into the computer audio output (NOT the microphone input), and make sure the g.TRIGbox has power; the light next to the power switch should flash momentarily if the battery levels are OK. You can also use a wall power source (see the g.TRIGbox manual for more information). The threshold is set correctly when the channel B LED is off at rest, and is on when a sound is played.
This panel handles starting and stopping the procedure, and running the analysis.


====Video Threshold====
;Auto Set Config
To set the video threshold, first tape the optical sensor to the monitor in approximately the correct location, based on the information in the latencyTest.prm file for the window position and dimensions. To activate the optical trigger on the g.TRIGbox, drag a white window, such as a Notepad window, in the background under the sensor. Move the threshold knob for channel A until the LED for that channel is just on (i.e., turning it down just a little turns the trigger off). The sensor will be placed more accurately in the following step.
:Automatically press '''Set Config''' upon starting BCI2000. This is required for complete automation of the procedure. When unchecked, BCI2000 will pause after loading parameters, and you will be able to inspect parameters for debugging purposes. You will have to press '''Set Config''' manually to proceed.


===Starting the Software===
;Auto Start
Navigate to BCI2000/tools/BCI2000Certification, and double-click the BCI2000Certification.exe program. The BCI2000 program should start, with the output window in the location specified in the latencyTest.prm file. If there are any errors at startup, the BCI2000 error log will report them. If there are errors, correct them, exit out of the BCI2000Certification.exe program, and restart the program.
:Automatically start the test after '''Set Config''' is pressed. This is required for complete automation of the procedure.


===Setting up the Optical Sensor===
;Auto Quit
Each application has a unique display configuration, where the visual target of interest is located in a specific position on the monitor. Generally, the optical sensor will not likely have to be moved far in between tasks due to the design of the parameter files. However, it is still necessary to ensure that the sensor is in the correct position for each task, and to be able to change the position if necessary. This section describes the process to find the correct location on the monitor for the sensor. To begin, the certification procedure should be started.
:Automatically quit BCI2000 after each task. This is required for complete automation of the procedure.


====P3Speller====
;Start
The P3Speller task has an group of letters arranged into rows and columns. The analysis uses the letter in the 3rd column and 3rd row, which will contain the letter X when the program is run. This location should be very close to that specified for the CursorTask, described above. Fortunately, the arrangement of the letters is shown before the test starts, which allows the sensor to be adjusted if necessary. All of the following default tasks are setup so that the optical sensor does not need to be moved from this position.
:Starts the selected tasks.


====CursorTask====
;Analyze
In the default configuration, the optical sensory does not need to be moved from the position used for the P3Speller task. For custom tests, the flashing object must either be placed under the sensor, or the sensor needs to be moved to the correct position.
:Starts the analysis tool. This uses the directory entered in the '''Data Output Directory''' setting. See the documentation for the analysis tool for more information on the analysis procedure.


====StimulusPresentation====
;Progress
For the StimulusPresentation tasks, a single large icon appears in the center of the screen, which will be detected by the sensor. The default location of the sensor as defined for the CursorTask should be able to capture the icon on the screen. However, if the task begins and it appears that it is outside the icon location, move the sensor to the middle of the icon. Keep in mind that it may have to be relocated for following tasks.
:While running, a progress bar appears and text provides information about the current running task, and how many tasks remain. The progress bar window includes a Cancel button, which will stop the procedure after the current task finishes.


===Running the Tests===
===Setting Up and Running the Certification Procedure===
Once the optical sensor is setup and calibrated for a task, begin the testing process. To start the process, press the Start button in the BCI2000 operator window. At the end of each task, the program will quit automatically, and the next one will start automatically. For each task, press the Start button to begin.
# Load the appropriate configuration file, based on the number of amplifiers that you will be using and as described above.
# Plug-in and turn on the amplifier(s).
# Configure the multi-monitor system, if applicable.
# Enter the appropriate screen dimensions under <code>Window Width</code>, etc.
# Prepare to place the optical detector on the monitor by using a ring of double-sided tape. The exact placement on the monitor will depend on the tasks used, and will be determined shortly. Plug the detector into the Optical Input A on the g.TRIGbox.
# Using a 1/8th in. cable, connect the headphone output on the PC to the Low Level input D of the g.TRIGbox.
# Connect the g.TRIGbox Trigger Out (D-Sub connector) to digital I/O 1 port of the g.USBamp using a standard cable provided by g.tec.
# Specify the ''Video Stream'' as ''DigitalInput1'' and the ''Audio Stream'' as ''DigitalInput4'' in the ''Events Configuration'' tab.
# Alternately, the audio and video event markers can be sampled by the analog channels. In this case you will need to specify the ''Video Channel'' and ''Audio Channel'' in the ''Events Configuration'' tab. In this case, leave the ''Video Stream'' and ''Audio Stream'' fields empty.
# In addition to measuring the latency of visual and auditory stimuli, you can also evaluate the delay of the analog-to-digital converter (ADC). This is done by connecting ''DigitalOutput1'' of the Digital I/O 1 port of the amplifier to the amplifier's digital input or analog input. This requires a custom cable. For details, see the [[User_Reference:BCI2000Certification#Assembling Required Cables|Assembling Required Cables]] section below. For the g.USBamp, specify the ''Amp Stream'' as ''DigitalInput0'' or the ''Amp Channel'' as the input channel accordingly.
<!-- # Next, the connectors should be configured. The procedure for creating connector cables is described in detail later in this document. To summarize the procedure for the g.USBamp, and as shown in the figure below:
## Using the digital I/O breakout connector for the g.USBamp, tie pin 3 (digital out 1) to pin 4 (digital in 0).
## Connect the digital out 1 female connector to a male connector, and plug the signal wire of the male connector into channel 1 of the amp.
## Connect output A of the g.TRIGbox to channel 2 of the amplifier.
## Connect output B of the g.TRIGbox to channel 3 of the amplifier.
## Using several EEG jumper wires, jumper the 3 ground cables together and input them to the Ground and Ref inputs of the amplifier.-->
# Next, the location to place the optical detector will be determined. The first task will be run, showing the location on the screen to place the connector.
# Press the Start button. BCI2000 will start shortly, and the application window will appear. In this test, the P300 Speller application is shown first.
# Place the detector over the "X" on the screen.
# Adjust the threshold on the g.TRIGbox for connector A so that it blinks on and off with the appearance of the "X". It may be necessary to turn off the lights in the room so that ambient light does not interfere with the optical detector.
# When finished placing the detector and setting the threshold, press Cancel in the BCI2000Certification GUI, and then Quit BCI2000. Navigate to the location of the Data folder (e.g., <code>BCI2000/tools/BCI2000Certification/</code>) and delete the data folder.
# Make sure that the computer volume is turned all the way up, and not muted.To set the audio threshold, set audio volume on the computer to maximum. On Windows, to make this process easier in the future, go to the Start menu, click the Control Panel, and go to Sounds. In the Sound window, click the box that puts the volume icon in the task bar. A small speaker should now appear in the bottom-right of the screen in the task bar. Click this icon, and slide the volume up to the max; when you click on this slider, Windows emits a short beep to give an idea of the volume level, which can be used to set the threshold. To do so, make sure that the stereo audio cable is plugged into the g.TRIGbox, and click the slider to emit a sound, checking that the green LED is flashing when you click the slider. If it is not, turn the threshold knob for channel B counter-clockwise, and click the slider again. If it is still not working after several tries, unplug the audio cable from the computer, and check that you can hear the beep through the speakers. If you cannot, make sure that the sound is not muted, and that the sound drivers are properly installed. If you can hear it, plug the audio cable back into the computer audio output (NOT the microphone input), and make sure the g.TRIGbox has power; the light next to the power switch should flash momentarily if the battery levels are OK. You can also use a wall power source (see the g.TRIGbox manual for more information). The threshold is set correctly when the channel B LED is off at rest, and is on when a sound is played.


Occasionally, the optical sensor may not be in the exact correct place for a given task.You should be able to see changes in on the video channel (channel 2 by default) in the window showing the recorded channels. If the signal is not changing when it should be (e.g., during the correct visual stimulus), you may try increasing the threshold to catch the stimulus, or you may need to place the sensor in the correct location. To do this, place the sensor in the better location, then quit the current BCI2000 test, and quit the BCI2000Certification program. The procedure will need to be restarted.
[[File:Usbampconnections.png|800px|thumb|center|upright=2.5|Connectors schematic.]]


When the testing is complete, the BCI2000CertAnalysis program will automatically start. It will analyze the data that have been collected, and return the results in the results.txt file. In general, a Pass or Fail will be written next to a task, and each task component, if it passed or failed the test. For more information on interpreting results, see below.


==BCI2000Certification: Additional Information==
The previous section on Getting Started provided information to quickly setup and run the default tests. This section provides detailed information about each file used, and how to modify the files for your specific system and applications.


===Overview of Important Files===
# You are now ready to run all of the tests. To do so, press the Start button on the GUI.
There are several important files that are used in the BCI2000 Certification procedure. These files and their contents are described in this section.  
# While testing, some tasks may not complete correctly, either because they are too computationally intensive for the selected computer system, or some other mistake or artifact occurred during the test. In this case, BCI2000 can be Quit manually, and the remaining tasks will be run. At the end of all tasks, you can then de-select all tasks, and re-check just the ones that need to be completed. It is necessary to delete data files in the data folder from unusable runs prior to running them again, so that the bad data is not included in the analysis.
# When all tasks are complete, press the <code>Analyze</code> button to analyze the collected data. This procedure is detailed later in this document.


====BCI2000Certification.ini====
===Analyzing Data===
The BCI2000Certification.ini file contains the information that defines each task configuration. It is located in the BCI2000/tools/BCI2000Certification/ folder. It specifies the parameter file, the SignalSource, SignalProcessing, and Application modules, and the analysis definitions for each task. It contains all of the default tests, although it can easily be expanded to include additional or customized task configurations.
[[Image:CertAnalysis.png|frame|none|The BCI2000 analysis tool.]]
Simply pressing the <code>Analyze</code> button in the Tester will start the Analysis program. It is also possible to run the program in the BCI2000Certification directory by starting <code>BCI2000CertificationAnalysis.exe</code>.


Each task is defined by a set of '''case-insensitive''' , space-separated fields, as described below. A * indicates an optional field. The % character indicates a comment, and everything following that character is ignored.
# The BCI2000CertificationTester program stores information about how to interpret a session in the session data file itself. From there, it is picked up by the analysis program. You don't have to provide BCI2000CertificationTester .ini files to the analysis program.
# The analysis program will open in a new GUI window. When you clicked "analyze" in the tester program, the analyzer's file list is already populated. Otherwise, appropriate folders and files must be entered for this session:
## Press the "+" button to select the folder containing your data files. When you select the folder, all data files contained within its subfolders are added automatically.
# Finally, set the directory for the output file. Typically, this should be the same folder that contains all of the data files.
# When the parameters have been correctly configured, press "Run" to start the analysis, which can take several minutes. Note that debug builds run very slowly, so you should always use a release build for analysis.
# When finished, the analysis tool will display results at several levels of detail. On top, a summary is displayed, then a list of requirements is shown, with a global result for each requirement. Further down, results are shown for individual files.
# To store results for documentation, you may press ''Save and Open...'' to save results to a text file, which can be found in the folder choosen at the bottom left, defaulting to the data folder. The file name will have the format <code>results_(date)_(time).txt</code>. Additionally, this contents of this file will be opened automatically at the end of the process in a new window.


*'''name''' The name of the task, which should be unique. This generally describes the task. It must not contain any spaces. This value determines the path to the saved data file, and the name of the file itself. For example, the name StimulusPresentation_512 would create a file at <code>./Data/StimulusPresentation_512001/StimulusPresentation_512S001R01.dat</code> Example:
===Interpreting Analysis Results===
**<code>name StimulusPresentation_512</code>


*'''parm'''The BCI2000 *.prm file used for this task. It should be placed in the BCI2000/tools/BCI2000Certification/parms/ folder. Note that the CertificationMain.prm is included in ''all''  configurations by default, and does not need to be listed here. This file contains the information for this specific task configuration. See above for further information.
The certification analysis results are shown as the overall result at the top of the analysis tool. In the example below, 33/60 tasks passed, while 27 tasks did not meet the success criteria. Additionally, 48 tasks are missing data, as they do not include auditory stimuli (this is by design). In more detail, the results are segregated into three sections, with overlapping information contained in each section. These sections are Requirements, Performance Statistics, and Individual Tasks. The Requirements section provides details about the global performance of the various certification tests. The success criteria are somewhat arbitrary and are based on our experience measuring response latency in various setups. The Performance Statistics section contains very similar information, with the statistics reported at the top level for easy viewing. Finally, the Individual Tasks section organizes the certification results by task.
**<code>parm SimpleAV.prm</code>


*'''source''' The SignalSource module to be used for this test. The g.tec g.USBamp system is used in all configurations by default. If the g.MOBIlab or g.MOBIlab+ are used, the SignalSource module should be changed to the appropriate executable. All BCI2000 executables are located in BCI2000/prog/. Examples:
[[Image:Analysis03.PNG|frame|none|The BCI2000 analysis results. Results are described in three sections: Requirements, Performance Statistics, and Individual Tasks.]]
**<code>'source gUSBampSource.exe'''</code>
**<code>source gMOBIlabSource.exe</code>


*'''sigproc''' The SignalProcessing module that is used for this configuration. This is likely dependent on the application used as well. This program should be located in BCI2000/prog/. Example:
Navigating into the sub-menu structure provides details about the various tests run, including the stimulus source, the method used to determine the event latency, and the event latency and variance across trials.  
**<code>sigproc P3SignalProcessing.exe</code>
[[Image:6.PNG|frame|none|The BCI2000 analysis results. Individual Tasks.]]


*'''app''' The application for this configuration. This program should be located in BCI2000/prog/. Example:
The results text file contains detailed results for all tasks. A sample output for a single task is shown here:
**<code>app StimulusPresentation.exe</code>


*'''*amp''' This is a single value that gives the channel that is used to compute the amplifier latency. Example:
[[Image:Analysis_03_3.PNG|frame|none|The BCI2000 analysis results. The top of the file includes details about the global results.]]
**<code>amp 0</code>
[[Image:Analysis03_4.PNG|frame|none|The BCI2000 analysis results. Throughout the file there are details about each task.]]


*'''*dAmp''' This is a single value that specifies a digital input channel that is used to compute the amplifier latency. Example:
**<code>dAmp 15</code>


*'''*vid''' This field is followed by 3 values, that give the channel number that is recording the video output, and the state name and state value to use as a trigger for the comparison. See the example entry for more information. Example:
====A Note on "Pass/Fail"====
**<code>vid 1 StimulusCode 1</code>
The values that determine whether or not a task passes or fails are determined somewhat arbitrarily. For example, we determined that an audio output latency of more than 65 ms is unacceptable for psychophysical research, e.g., BCIs. In the example shown, the audio output latency was ~62 ms for all tasks with audio, and thus these tasks registered as a "pass." However, it is ultimately up to the researcher to determine what is acceptable system timing; this method provides a method of quantifying the system latency values to simplify the process of making these decisions.


*'''*aud'''  This field is followed by 3 values, that give the channel number that is recording the audio output, and the state name and state value to use as a trigger for the comparison. See the example entry for more information. Example:
You may move the slider near the top of the window in order to display the original GUI elements you saw before clicking "Run". When clicking the checkbox close to "Override requirements", a small editor window appears, containing code for all requirements applied to the data. You may modify requirements there, as you see fit.
**<code>aud 1 StimulusCode 1</code>


*'''skip''' Entering '''skip'''  will cause this task to not be run or analyzed. This is used to reduce the number of tasks that are run, which helps to repeat individual tasks that may have had problems in previous sessions.
====Visualizing Certification Test Results using GNUPlot====


*'''end''' This must come at the end of each task definition.
If you have GNUPlot installed, you can also visualize the distribution of latencies. Simply right-click on the field and select ''plot.''


In addition to task-specific entries, there are several global entries that will apply to every task, unless explicitly overwritten in that task. This allows the user to quickly change settings for all tasks simultaneously, e.g., if tests will be run using a g.tec g.USBamp for one set of tests, and a g.tec g.MOBIlab for another. Global entries must be defined at the beginning of the BCI2000Certification.ini file outside of the task definitions. These entries are defined as:


*'''source''' The SourceModule to be used for all tests, unless explicitly overwritten by an individual task. Otherwise identical to the '''source'''  definition in a task entry.
[[Image:CertificationTool_GNUPlot.PNG|frame|none|GNU Plot.]]
*'''export''' This entry does not use any other parameters on the line on which it is defined. If '''export'''  is present in the BCI2000Certification.ini file, test results will be written to a comma-separated-value (CSV) text file that is located in the folder where data is saved for each task. For example, if the data folder is BCI2000/tools/BCI2000Certification/latencyData/, then the export file for the SimpleTarget task will be placed in the folder BCI2000/tools/BCI2000Certification/latencyData/SimpleTarget.


Here is a full example entry that includes two tasks.
==Assembling Required Cables==
Depending on what hardware and the latencies of interest are, you may or may not need to assemble custom cables. If you are interested in measuring the audio and visual latency with the gTRIGbox and an amplifier manufactured by a company other than g.tec, you will need to assemble a custom cable going from the output of the gTRIGbox to the digital inputs or analog inputs of your amplifier. It is also possible measure the audio and visual latency without the gTRIGbox, but this will require another trigger onset detection method. If you have a g.tec g.USBamp and want to measure the system latency and the ADC latency, you can follow the following guide.  


<pre>
In the following sections, we provide examples on how to build this cable if you’re using the gTRIGbox and a gUSBamp with a UB serial number (see the [[User_Reference:gUSBampADC#Digital_Inputs|gUSBamp digital input page]] for more information regarding the difference pin assignments between serial numbers). There are two versions of the gTRIGbox, an older legacy version with four 3.5 mm audio connector outputs, and a newer one that has a 15 pin D-sub type connector. We describe the process of building cables for both of these devices.
source gUSBampSource
export


name StimulusPresentation_512
===Legacy gTRIGbox===
parm StimulusPresentation_512.prm
[[Image:Usbampconnections_legacy.png|frame|none|Connectors schematic.]]
sigproc P3SignalProcessing
====Amplifier Input====
app StimulusPresentation
Parts List:
amp 0
dAmp 15
vid 1 StimulusCode 3
aud 2 StimulusCode 3
end


name CursorTask_1200
*3 Male Mono Audio Connectors 
parm CursorTask_1200.prm
*6 12in+ Safety Connector Wires (to USB amplifier input), different colors 
source gMOBIlab
*Soldering Iron and Solder
sigproc ARSignalProcessing
app CursorTask
amp 0
dAmp 15
vid 1 TargetCode 1
end
</pre>


The <code>StimulusPresentation</code>  task uses the <code>gUSBampSource</code>  source module, and records block-triggered digital outputs on channel 0, video output triggered off of stimulus code 3 on channel 1, and audio output triggered off of stimulus code 3 on channel 2. The <code>SimpleTarget</code>  tasks overrides the global <code>source</code> entry, and uses its own <code>source</code>  definition, specifying that a gMOBIlab should be used for acquisition instead of a gUSBamp. Finally, the <code>export</code>  entry is set at the beginning, so test results for all files are output to a CSV file.
This section describes how to assemble cables that connect the output of the g.TRIGbox to the amplifier input channels.


The BCI2000Certification.ini file contains many task definitions. Each entry is read by the BCI2000Certification.exe program, and is entered as a separate task to be run and then analyzed.
# Strip the free ends of the 6 safety connector wires (~1/4 in)
# Take one wire, and solder the wire to the "signal" pad of one of the mono audio connectors.
# Solder another wire to the "ground" pad of the same connector.
# If necessary, pass the wires through end of the connector that screws in to cover the connection (see below, in the ''g.USBamp Amplifier Plug'').


====BCI2000Certification.cfg====
[[Image:ampPlug_1.png|frame|none|g.USBamp Amplifier Plug]]
The latencyTest.prm file is located in the BCI2000/tools/BCI2000Certification/ folder. It contains many default settings and definitions that determine how the results are interpreted, and should generally not be changed by the user. The timing definitions provide the absolute maximum latencies in ms for each step in the system chain, and include the Amp, ProcLat, VidOut, AudOut, VidSys, AudSys, and Jitter (see below for explanations). Timing definitions can include either one or two fields; the first field is mandatory, and is the mean value in ms, while the second field is optional, and is the standard deviation in ms.


*'''Amp''' The amplifier latency.
Each connector now has a signal and ground wire that can be connector to the g.USBamp inputs, or any amplifier that accepts the standard EEG connector.
*'''ProcLat''' The processing latency.
*'''VidOut''' The video output latency.
*'''AudOut''' The audio output latency.
*'''VidSys''' The video system latency.
*'''AudSys''' The audio system latency.
*'''Jitter''' The system jitter. This is the difference, in ms, between the actual block duration and theoretical block duration, which is determined by the block size.
*'''Threshold Source Value''' This is the threshold defined for a specific SignalSource module. Individual amplifiers may have different input ranges, resulting in recording signals with different ranges of magnitude. The '''Source'''  entry is a value in mV. For example, the threshold setting for the g.USBamp is '''Threshold gUSBampSource 12.5''' .
*'''ResultOut''' This is the file that contains the testing results.
*'''DataDir''' The default data directory. It defaults to latencyData in the BCI2000/tools/BCI2000Certification/ folder.  


These values should not generally be changed by the user, although they may be updated in future BCI2000 versions.
====Digital I/O Cable====


====CertificationMain.prm====
Parts List:
This parameter file contains some of the default task parameters common to every test, including the save location, monitor configuration, sampling rate, and visualization settings. Note that these parameters can be overwritten in the *.prm files for each individual test configuration.
 
*3 Colored Electrical Wires
*7-Pin Digital Connector from '''g.tec'''
*Soldering Iron and Solder 
*Silicone or electrical tape for insulation 
*1 Female Mono Audio Plug 


====BCI2000Certification.exe====
In order to access the digital I/O pins on the g.USBamp, a connector needs to be assembled. The 7-pin digital I/O connector should be ordered through g.TEC, the manufacturer of the g.USBamp.
This file controls the execution of each task. It parses the BCI2000Certification.ini and BCI2000Certification.cfg files to determine which files and tasks to run, and controls the CPU load monitor. When all tasks are complete, this program calls the BCI2000Analysis.exe program to handle the analysis of the collected data.


====BCI2000CertAnalysis.exe====
At least three wires are needed for the circuit, which connect to the digital output 1 pin, the digital input 0 pin, and the ground pin.
This program analyzes the data collected, and reports results to a data file. It uses the DataDir parameter in the BCI2000Certification.cfg file to determine where the data is located. Results are output to results.txt in the BCI2000/tools/BCI2000Certification/ folder.
[[Image:DigIO.png|frame|none|g.USBamp Digital I/O Pins]]
[[Image:digConnector.png|frame|none|g.USBamp Digital I/O Pins]]


====Parameter Files====
# Strip the ends of the 3 wires (~1/4 in)
Each task should have it's own parameter file that contains the unique configuration and settings for that task. For example, there may be several configurations that use the g.USBamp, ARSignalProcessing, and CursorTask, each with its own parameter file. These files end in .prm, and are placed in the BCI2000/tools/BCI2000Certification/parms/ folder.
# Take one wire, and solder the wire to the "signal" pad of the female mono audio connectors.
# Solder another wire to the "ground" pad of the same connector.
# If necessary, pass the wires through end of the connector that screws in to cover the connection (see below, in the ''g.USBamp Amplifier Plug'').
# Solder the ground wire to the center ground pin on the digital I/O connector.
# Locate the top of the connector by locating the small plastic notch, and locate pins 3 and 4 relative to the notch.
# Solder the signal wire from the mono connector to pin 3 (digital out 1)
# Finally, solder the remaining wire (it has not been connected to anything yet) between pin 3 and pin 4. This connects the digital output directly to the digital input.
# It may be helpful to insulate the wires from the casing using either a piece of black electrical tape, or an insulating gel, like silicone. If a gel is used, be sure to let it set for several hours or overnight. It is also probably a good idea to check the electrical connection with a multimeter prior to insulating.
# Next, attach the rubber sleeve over the end of the part with the female threads, as shown in the panel.
# Slide the smaller metal sleeve over the wires, then slide the larger rubber sleeve over the wires.


===Interpreting Results===
[[Image:digPlug.png|frame|none|g.USBamp Digital Wire Plug]]
Results are recorded to the BCI2000/tools/BCI2000Certification/results.txt file. The results for each task, and each applicable latency tested, are reported here. If the entire task  passed, then each test performed met the minimum timing requirements specified in the BCI2000Certification.cfg file. If one or more did not pass, then the specific test that did not pass the test has Fail written next to it.


====What if a Task Did Not Pass?====
# For the next step, attach the two metallic pieces that surround the cables, shown laying to the sides in the figure below.
TO BE ADDED.
# One of the metal pieces has a small groove in it, which should be placed over the notch on the connector; the other metal piece fits on the opposite side of the connector.
# Push the small metal sleeve up to the side piece with the groove, and rotate the sleeve until the notch fits in the groove.
# Place the end piece over the connector, with the red dot on top and aligned with the connector notch.
# Finally, slide the rubber sleeve over the connector, and screw the sleeve into the end piece.


==Certification Protocol==
[[Image:finalDigCable.png|frame|none|g.USBamp Digital I/O Cable]]
This section describes how the testing protocol is run, the various components involved in the certification analysis, and how to interpret results.


===Running the Tests===
The plug is assembled next, similar to the. Solder the signal wire from Pin 3 (Digital Out 1) on the digital I/O connector to the signal connector on the female mono plug, and solder the ground wire to the outer ground connector on the plug. The below figure shows this; in this figure, the red wire is the signal wire, and the brown wire is the ground.
The certification protocol consists of running several BCI2000 applications in multiple configurations to determine if each application meets the minimum requirements for BCI2000, and to determine if individual configurations of an application meet the requirements. For example, the CursorFeedback task may be tested with several combinations of sampling rates, sample block sizes, and processed channels, only some of which may work with a given computer setup.
===Latest gTRIGbox===
There are two ways to connect the output of the gTRIGbox to the g.USBamp, “Analog” or “Digital”, as indicated in the figure below. Pins connected by a <span style="color:#f97e00">orange</span> dotted line denote connections that are necessary to measure the amplifier latency.
[[File:Usbampconnections.png|800px|thumb|center|upright=2.5|Connectors schematic.]]


The testing set is run from a single batch file called LatencyAnalysis.bat. This file is located in the folder BCI2000/tools/BCI2000Certification/batch. This batch file executes additional batch files in this folder, each corresponding to a different application configuration. Each of these batch files starts the Operator module, automatically loading multiple parameter files used for a given configuration. There is a general-purpose parameter file called latencyTest.prm that all configurations use. This file configures the save location for all latency tests, as well as default window positions and sampling rates. A second parameter file is passed to the operator that contains the parameters for a unique application configuration. After starting the operator module, the batch file starts the SignalSource module, SignalProcessing module, and Application module. The loaded configuration is set automatically, and the user needs only to press the start button to start the analysis.
[[File:GTrigBoxOutputSchematic.png|800px|thumb|center|upright=2.5|gTrigBox output schematic.]]


==Software Templates==
====Digital Configuration====
This describes how to implement the testing protocols for your own amplifier system and custom applications. This is useful for determining if your hardware setup and software is capable of maintaining an acceptable level of performance for real-time testing.
The digital configuration uses digital I/O 1 on the back of the g.tec amplifier. It requires a specific 7 pin g.tec connector that can be ordered from g.tec, the manufacturer of the g.USBamp.
Parts list for digital cable:
# One 15 pin D-Sub Type Female Connector
# One 7 pin Digital Pin Connector from g.tec
# Electrical Wire
# Soldering Iron and Solder


===Amplifier Latency===
The D-Sub Type connector can be purchased such that you only need to strip the electrical wires and then insert them to receptacles that tighten with a screwdriver, thus reducing the need for any soldering. This makes the process of assembling the cable easier. In example of this type of connector is shown below:
The amplifier latency requires an output that can be recorded by the amplifier. In the case of the g.USBamp, a digital output line is used, although either analog or digital outputs could be used in a system.


In the SignalSource module code for your custom amp, find the Process function. Near the beginning of this function, before any data is acquired, set the output signal to 0, either a digital low or analog value of 0 V. This will be dependent on the particular amplifier and API used; for the g.USBamp, this function call looks like:
[[File:F15pin_d-sub_connector.jpg|600px|thumb|center|upright=2.5|15 Pin D-Sub Connector with Breakout Board.]]
<br><code>
GT_SetDigitalOut ( m_hdev.at(0), (UCHAR)1, (UCHAR)0);
</code><br>


This sets the digital output 1 on device 0 to a value of 0.
In the gUSB Digital Out cables we have seen, here is the coloring of the wires:
{| class="wikitable"
|-
! colspan="2" style="text-align:center; font-weight:bold;" | DIGITAL I/O CABLE
|-
| gTRIGbox Wire Color
| g.USBamp Digital I/O 1
|-
| Blue
| 7
|-
| White
| 1
|-
| Brown
| 2
|-
| Green
| 3
|-
|Yellow
|4
|-
|Pink
|5 or 6
|-
|Grey
|5 or 6
|}


At the end of the Process function, the output should be set to a high level. A similar function call will be used to above, only the value is 1 instead of 0; again, the function will be dependent on the system used, and whether analog or digital output is used. Here is the code for the g.USBamp:
<br><code>
GT_SetDigitalOut ( m_hdev.at(0), (UCHAR)1, (UCHAR)1);
</code><br>


This sets the digital output 1 on device 0 to a value of 1.
<!--
{| class="wikitable"
|-
! colspan="2" style="text-align:center; font-weight:bold;" | DIGITAL
|-
| gTRIGbox Output
| g.USBamp Digital I/O 1
|-
| 1 (GND)
| 7
|-
| 2 (A)
| 2
|-
| 3 (B)
| 3
|-
| 4 (C)
| 4
|-
| -
| style="color:#f97e00;" | 1 & 5
|}
-->
=====Procedure for Assembling Cable=====
# Cut 3 pieces of wire, each the same length (about 3 ft should be sufficient).
# Strip the ends of these pieces of wire, leaving about a quarter-inch of wire exposed.
# Start with the D-Sub connector. Connect each of the pins in ''gTRIGbox Output'' column of the table above to its own piece of wire.
# Solder the other ends of each of these wires to its appropriate location, as defined in the table above, on the g.USBamp digital I/O connector.
# If you also want to measure amplifier latency, strip and solder a piece of wire between pins 1 and 5 on the g.USBamp digital I/O connector.
# When assembling the digital I/O connector, it may be helpful to insulate the wires from the casing using either a piece of black electrical tape or an insulating gel, like silicone. If a gel is used, be sure to let it set for several hours or overnight. It is also probably a good idea to check the electrical connection with a multimeter prior to insulating.
# Next, attach the rubber sleeve over the end of the part with the female threads, as shown in the panel.
# Slide the smaller metal sleeve over the wires, then slide the larger rubber sleeve over the wires.


===Visual and Audio Latency===
====Analog Configuration====
Developing new video and optical latency tests does not necessarily require adding additional code to existing modules (beyond any customization already done).
The analog configuration uses the analog inputs on the front on the amplifier to measure latency. To also measure the amplifier latency you will need a specific g.tec connector.
Parts list to make analog cable to measure system latency:
# One 15 pin D-Sub Type Female Connector
# Five Safety Connector Wires (to USB amplifier input)


==Supported Hardware==
If you also want to measure amplifier latency, you will also need:
A list of officially supported hardware configurations, and suggested minimum requirements is provided.
# One 7 pin Digital Pin Connector from g.tec
# One Additional Safety Connector Wire (to USB amplifier input)
# Two resistors for Voltage Divider
# Soldering Iron and Solder


===Supported and Tested Hardware===
If you use the D-Sub connector with a breakout board and do not want to measure amplifier latency, you will not need to do any soldering, making assembly quite easy. Below is a table of what pin connections must be made. The wiring diagram above provides a guide for what pins need to be connected.  
====Amplifiers====
<!--
 
The connections shown in <span style="color:#f97e00">orange</span> are necessary to measure amplifier latency.  
*g.USBamp 
{| class="wikitable"  
*gMOBIlab (Serial RS232) 
|-
*gMOBIlab (Bluetooth) 
! colspan="3" style="text-align:center; font-weight:bold;" | ANALOG
*TDT Pentusa (RX5) 
|-
 
| gTRIGbox Output
===Minimum Requirements===
| g.USBamp Digital I/O 1
This table shows the minimum requirements for running BCI2000.
| g.USBamp Analog Input
 
{| border="1"
|+ Minimum System Requirements for BCI2000
! CPU
| 1 GHz
|-
|-
! RAM
| 1 (GND)
|512 MB (dependent on OS; 1 GB for Windows Vista)
| -
| REF & GND
|-
|-
! Video Card
| 9  (A)
|32 MB VRam; Hardware OpenGL Support
| -
| 2
|-
|-
! Sound Card
| 10 (B)
|
| -
| 3
|-
|-
! Monitor
| 11 (C)
|
| -
| 4
|-
|-
! OS
| -
|Windows 2000; Windows XP SP2 or Greater; Windows Vista
| style="color:#f97e00;" | 5
| style="color:#f97e00;" | 1
|}
|}
-->
=====Procedure for Assembling Cable=====
# Strip the ends of five wires with safety connectors at one end, leaving a quarter-inch exposed (if you want to measure amplifier latency, strip one additional wire).
# Start with the D-Sub connector. Connect each of the pins as shown in the connector schematic to its own piece of safety connector wire.
# If you also want to measure amplifier latency, a voltage divider is necessary to bring the 5V output at the gUSBamp's digital output at pin 5 down to a voltage less than 250mV (the max input range on the gUSBamp's analog inputs). Selecting a <math>R_1</math> and <math>R_2</math> such that the following equation is satisfied would result in a 100mV signal at the analog inputs:
<math>0.02 = \frac{R_2}{R_1+R_2}</math>
# Assemble this voltage divider by soldering the resistors, pin 5 on the digital I/O, and additional safety connector together as detailed in the connectors schematic. You can also use a bread board to avoid soldering.
# When assembling the digital I/O connector, it may be helpful to insulate the wires from the casing using either a piece of black electrical tape or an insulating gel, like silicone. If a gel is used, be sure to let it set for several hours or overnight. It is also probably a good idea to check the electrical connection with a multimeter prior to insulating.
# Next, attach the rubber sleeve over the end of the part with the female threads, as shown in the panel.
# Slide the smaller metal sleeve over the wires, then slide the larger rubber sleeve over the wires.


===Voltage Divider & Amplifier Input===
== Troubleshooting ==
Parts List:
Things to watch out for:
 
*Parameter files for gUSBamp with channels greater than 16 have pre-defined amplifier IDs. Please set these to your amplifier IDs.
*4 Male Mono Audio Connectors 
*BCI2000Certification runs BCI2000 applications from the working directory: <tt>C:\BCI2000\tools\BCI2000Certification</tt>. The images folder there doesn't contain all required images for <tt>CursorTask</tt> or a sounds folder for "StimulusPresentation"If necessary, paste the images and sounds folder from the <tt>BCI2000/prog</tt> directory into the <tt>BCI2000/tools/BCI2000Certification</tt> directory - overwriting what is currently in that directory.
*6 12in Safety Connector Wires (to USB amplifier input), different colors  
*4 3in Wires 
*Soldering Iron and Solder 
*resistors for voltage dividers 
This section describes how to assemble cables that connect the output of the g.TRIGbox to the amplifier input channels.
 
Strip the free ends of all 6 safety connector wires, about <math>\frac{1}{4}</math> in. If you are not using voltage dividers, solder 4 of the wires directly  to the center signal connection on the 4 mono audio connectors. Cover the connection.
 
[[Image:ampPlug_1.png|frame|none|g.USBamp Amplifier Plug]]
 
Next, twist the two remaining safety connector wire ends together, and solder them together. Solder the 4 short wires to the ground connections on the mono plugs. Finally, solder the 4 ground wires to the two safety connector wires that were twisted together and soldered previously, as shown here.
 
[[Image:ampPlugs_2.png|frame|none|g.USBamp Amplifier Plugs]]
 
These plugs can plug directly into the g.TRIGbox outputs, and the safety connectors plug into the channels 1-4 inputs on the g.USBamp; the ground wires plug into the ground and reference on the g.USBamp.
 
===Digital I/O Cable===
 
Parts List:
 
*3 Colored Wires 
*7-Pin Digital Connector from g.tec 
*Soldering Iron and Solder 
*Silicone or electrical tape for insulation 
*1 Female Mono Audio Plug 
 
In order to access the digital I/O pins on the g.USBamp, a connector needs to be assembled. The 7-pin digital I/O connector should be ordered through g.TEC, the manufacturer of the g.USBamp.
 
At least three wires are needed for the circuit, which connect to the digital output 1 pin, the digital input 0 pin,  and the ground pin (Fig. \ref{fig:digIO}).
[[Image:DigIO.png|frame|none|g.USBamp Digital I/O Pins]]
 
To start, cut three 10 in wires, preferably with different colors to differentiate between the signal and ground wires. Cut back a small portion of the ground wire, and solder it to the center ground pin on the connector. Now, find the top of the connector by locating the small plastic notch, and locate pins 3 and 4 relative to the notch. Solder one wire to pin 3, and the remaining wire to pin 4. It may be helpful to insulate the wires from the casing using either a piece of black electrical tape, or an insulating gel, like silicone. If a gel is used, be sure to let it set for several hours or overnight. It is also probably a good idea to check the electrical connection with a multimeter prior to insulating.
 
[[Image:digConnector.png|frame|none|g.USBamp Digital I/O Pins]]
 
Next, attach the rubber sleeve over the end of the part with the female threads, as shown in Fig. \ref{fig:digFinal} in the left side of the figure. Slide the smaller metal sleeve over the wires, then slide the larger rubber sleeve over the wires, as shown in Fig. \ref{fig:digFinal}.
 
For the next step, attach the two metallic pieces that surround the cables, shown laying to the sides in Fig. \ref{fig:digFinal}. One of the metal pieces has a small groove in it, which should be placed over the notch on the connector; the other metal piece fits on the opposite side of the connector. Push the small metal sleeve up to the side piece with the groove, and rotate the sleeve until the notch fits in the groove.
 
Place the  end piece over the connector, with the red dot on top and aligned with the connector notch. Finally, slide the rubber sleeve over the connector, and screw the sleeve into the end piece.
 
[[Image:finalDigCable.png|frame|none|g.USBamp Digital I/O Cable]]


The plug is assembled next. Solder the signal wire from Pin 3 (Digital Out 1) on the digital I/O connector to the signal connector on the female mono plug, and solder the ground wire to the outer ground connector on the plug. Figure \ref{fig:digplug} shows this; in this figure, the red wire is the signal wire, and the brown wire is the ground.
==See also==
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]]


[[Image:digPlug.png|frame|none|g.USBamp Digital Wire Plug]]
[[Category:Performance Measurement]][[Category:Data Analysis Tools]][[Category:Video]]

Latest revision as of 17:59, 3 September 2024

Introduction

BCI2000 includes a certification procedure that can determine whether a computer system is capable of running all or some BCI2000 applications. Because BCI2000 does not have a standardized hardware configuration, i.e., it can run on potentially any PC, this testing procedure is capable of running on any PC with BCI2000, with the results reporting which standard BCI2000 applications meet the minimum timing requirements. Different configurations are included in the certification procedure to test a range of likely setups for a given application, in which timing characteristics such as the sampling rate, inter-stimulus intervals, and stimulus duration, and other parameters, such as the number and size of the stimuli, are changed for each configuration.

This document serves as the instruction manual for using the certification procedure, and describes how the procedure works to determine the timing characteristics of the BCI2000 system. The primary use for the certification procedure is to determine if the PC configuration used with BCI2000 is capable of running the core BCI2000 system, which is comprised of:

  • Support for various biosignal amplifiers, including the g.USBamp, EGI GTEN 200, Nihon Kohden JE120-A, and many more on the ADCs page.
  • The AR, P3, FFT, and Matlab signal processing modules.
  • The CursorTask, P3Speller, and StimulusPresentation application modules.

Additionally, due to the extensibility of BCI2000, researchers who develop custom algorithms and applications can use the certification procedure to determine whether their custom modules are capable of running on a particular PC configuration.

The certification procedure works by comparing the differences in time of when BCI2000 expects an event to occur to when that event actually occurred. These events include a change in the display, an audio output through the system speakers, or an EEG sample being stored in the amplifier buffer. The times at which such events occur are recorded with the amplifier and stored in a data file. Changes in the display are found using an optical sensor and a triggering device. The documentation provided throughout this page uses the g.tec g.TRIGbox, although any device which can provide a digital or analog trigger to the amplifier can be used. The g.TRIGbox is a signal conditioner that generates trigger pulses for various sensors or input signals. When the sensor exceeds a threshold, the g.TRIGbox outputs a digital or analog signal which is recorded on the amplifier. A similar procedure is used for audio detection: the sound output from the PC is input to the g.TRIGbox, and when the volume exceeds threshold, a digital or analog signal is output and recorded by the amplifier. This information can be used because BCI2000 stores a time-stamp for every event during an experiment. The difference between a time-stamp value and the time that the recorded event changes values are compared to find the latency for that particular event.

These latencies can be affected by many external influences, including hardware deficiencies (such as low RAM, slow CPU speed, or a video card of low quality), and other software running in the background while the experiment is being run.

This document serves as the BCI2000Certification manual. As an example, this page will describe the certification procedure for the g.USBamp with visual and auditory stimuli triggered with the g.TRIGbox. At the end of the page, the certification results for using BCI2000 with three biosignal amplifiers (the g.USBamp, EGI GTEN 200, and Nihon Kohden JE120-A) are provided. A discussion and derivation of the specific system latencies are found here.

Video Demonstration

Compiling the BCI2000Certification Programs

The BCI2000Certification procedure actually consists of two separate programs, including a graphical user interface that simplifies the task of selecting and starting tests, and a program that performs the data analysis and returns results. These programs are compiled automatically with the other BCI2000 programs. Compilation is only supported in BCI2000 v3.0 with the Visual Studio or MinGW compilers. Instructions can be found at Programming_Howto:Building_BCI2000. At the point where you start CMake, be sure to check BUILD TOOLS in the BUILD menu.

Check the BUILD TOOLS box to build the certification tester and analysis tool.

Using the BCI2000Certification Procedure

Starting the Tester User Interface

  1. The compiled programs can be found in BCI2000/tools/BCI2000Certification.
  2. Navigate to this folder, and double-click the BCI2000CertificationTester.exe file.
  3. The certification tool opens, as below.

This program shows a list of all of the procedures to be tested for the loaded configuration. Detailed instructions for using the interface follow.

The BCI2000Certification user interface.
The BCI2000Certification user interface.

Loading Configuration Files

The BCI2000 certification procedure uses a configuration file and different combinations of BCI2000 parameter fragments to control the tests. The configuration file (stored as an *.ini file) describes all of the certification tests. The parameter fragments store information about the amplifier and application module applied in each test. More detail about the contents of the configuration file can be found below. While it is possible to edit these by hand, in most circumstances it is simpler to use the graphical user interface provided.

  1. In the BCI2000Certification tool, select File->Open *.ini
  2. Navigate to the folder BCI2000/tools/BCI2000Certification.
  3. Load the file named BCI2000Certification_16ch_100ms.ini if using a 16-channel system. (This tutorial assumes a 16-channel system).
  4. If using more than 16 channels, then the amplifier parameter files must be modified.
    1. Navigate to BCI2000/tools/BCI2000Certification/parms/, and open the file Certification_gUSBamp_24.prm in Notepad.
    2. Find the parameter titled DeviceIDMaster, and replace the existing device ID (e.g., UA-2007.04.12 with the ID of your master device.
    3. Next, find the parameter titled DeviceIDs, and replace the IDs with the IDs of your amplifiers. The first in the list should be identical to the DeviceIDMaster value. For example, you might enter: DeviceIDs= 2 UA-2007.04.12 UA-2006.10.13 (the \#2 corresponds to the number of devices being used).
    4. Repeat these steps for the file Certification_gUSBamp_32.prm.
    5. Note that these steps are not necessary if only one g.USBamp is being used.
  5. All 100 tests in this configuration are loaded into the GUI.

User Interface Components

This section describes each user interface component, referring to the figure below.

The BCI2000Certification user interface components.

1. Configuration: Task List

The task list shows all tasks that have been loaded from the configuration file or created within the GUI. To run a specific test, it should have a checkmark next to it. In order to select or deselect all tasks, press the Select All check box at the bottom of the list.

It is possible to create new tasks, remove tasks, and copy tasks within the interface as well. To create a new task, press the + button. A new task is created at the bottom of the list; the task details must be filled in (described next). It is often easier to copy a similar task than to create a new one from scratch. To do so, select the desired task, and press Copy. The new task should be renamed appropriately. To remove a task, select a task and press the - button.

Creating Custom Tests

With the BCI2000Certification tool, you can test performance on a wide range of different parameters and applications. You can create a custom .ini file that will contain the name of each test, the desired signal processing module, sampling rate, block size, application, and parameter files. You will need to first create a parameter file for the test you wish to run. If you want to be able to edit the block size and sampling rate from the Certification tester GUI or its .ini file, you must omit those variables from your parameter files as they will overwrite any variables you set in the Certification Tester. For example, if you wanted to test an application that you have developed for BCI2000 using several sampling rates and block sizes you would first need to create the two parameter files for the application, and source with no sampling rate or block size specified, then export them to the /BCI2000Certification/parms/ folder. Once you have the two parameter files, you may link to them in a new .ini file located under the /BCI2000Certification/ directory and run them as described below.

2. Configuration: Task Details

The right side of the GUI displays the details of the currently selected task. Each option is described here.

Task Name
The name of the task. This must not contain any spaces, and must be unique.
Signal Source
The amplifier that should be used, if different from the amplifier set in the global options. Generally, this should not need to be used, since all tasks should use the same amplifier.
Signal Processing
The signal processing module that should be started and used for the given task. This should usually be either ARSignalProcessing, P3SignalProcessing, or DummySignalProcessing, depending on the specific application.
Application
The application that is run for the task. This will typically be CursorTask, P3Speller, or StimulusPresentation
Parameters
A list of the parameter fragments that should be used for this task. Typically, at least two parameter files are required. The first should be the amplifier-specific fragment that configures the amplifier for the correct number of channels. The second should be the application-specific fragment that configures how the application appears on the screen. Parameter files can be added and removed with the + and - buttons, respectively. All files should be placed in the BCI2000/tools/BCI2000Certification/parms folder.
Sample Rate
The sampling rate that should be used for this task. Note that it must be supported by the amplifier used.
Sample Block Size
The sample block size (in samples). In the provided parameter files, the sample block size is always equal to 100ms, regardless of the sampling rate.
Amp Channel
This is the analog channel that records the amplifier digital output (i.e., the digital output recorded back in on an analog channel). This signifies the onset of acquisition of a block. This value should be between 1 and the number of channels.
Amp Stream
This is the digital channel that records the amplifier digital output (i.e., the digital output recorded back in on a digital input channel).
Video Channel
The recorded analog channel containing video event markers.
Video Stream
The recorded digital input channel containing video event markers.
Video State
The BCI2000 state that contains the event markers for the video event, e.g., TargetCode or StimulusCode.
Video State Values
A list of state change values that should be detected by the analysis. For example, if values 4 11 are used, then the analysis tool will examine when the StimulusCode state changes to either 4 or 11, and then examine when the Video Channel changes.
Audio Channel
The recorded analog channel containing audio event markers.
Audio Stream

The recorded digital input channel containing audio event markers.

Audio State
The BCI2000 state that contains the event markers for the audio event, e.g., TargetCode or StimulusCode.
Audio State Values
A list of state change values that should be detected by the analysis. For example, if values 4 11 are used, then the analysis tool will examine when the StimulusCode state changes to either 4 or 11, and then examine when the Video Channel changes.

3. Control: Global Settings

The BCI2000Certification user interface.

As the name suggests, the options under Global Settings are applied to all tasks, and are described here.

Window Left, Top
The position of the left and top sides of the application window. If using multiple monitors, this position should take this into account. For example, if the application window is to the right of the main monitor, and the main monitor has a resolution of 1280x1024 pixels, then Window Left should be set to 1280, and Window Top to 0.
Window Width, Height
The width and height of the application window.
Global Signal Source
The executable that should be used by all applications. This value is overwritten by the Signal Source value set for individual tasks.
Data Output Directory
The directory where all of the data should be saved during the task. This will appear relative to BCI2000/tools/BCI2000Certification/, or at a given absolute path. NOTE that if data already exists in this directory, additional data will be saved to it! To avoid combining new data with earlier results, the existing directory with the same name should be renamed or deleted.
BCI2000 Directory
This is the directory containing the BCI2000 program files, e.g., C:\BCI2000\prog
Additional Application Module command line arguments
Additional arguments to add to the command line when starting the application module.
Shell execute before
Execute command in the shell before running the experiment (e.g., taskkill /IM explorer to terminate the explorer shell and taskbar).
Shell execute after
Execute command in the shell after the experiment has finished.

4. Control: Controls

This panel handles starting and stopping the procedure, and running the analysis.

Auto Set Config
Automatically press Set Config upon starting BCI2000. This is required for complete automation of the procedure. When unchecked, BCI2000 will pause after loading parameters, and you will be able to inspect parameters for debugging purposes. You will have to press Set Config manually to proceed.
Auto Start
Automatically start the test after Set Config is pressed. This is required for complete automation of the procedure.
Auto Quit
Automatically quit BCI2000 after each task. This is required for complete automation of the procedure.
Start
Starts the selected tasks.
Analyze
Starts the analysis tool. This uses the directory entered in the Data Output Directory setting. See the documentation for the analysis tool for more information on the analysis procedure.
Progress
While running, a progress bar appears and text provides information about the current running task, and how many tasks remain. The progress bar window includes a Cancel button, which will stop the procedure after the current task finishes.

Setting Up and Running the Certification Procedure

  1. Load the appropriate configuration file, based on the number of amplifiers that you will be using and as described above.
  2. Plug-in and turn on the amplifier(s).
  3. Configure the multi-monitor system, if applicable.
  4. Enter the appropriate screen dimensions under Window Width, etc.
  5. Prepare to place the optical detector on the monitor by using a ring of double-sided tape. The exact placement on the monitor will depend on the tasks used, and will be determined shortly. Plug the detector into the Optical Input A on the g.TRIGbox.
  6. Using a 1/8th in. cable, connect the headphone output on the PC to the Low Level input D of the g.TRIGbox.
  7. Connect the g.TRIGbox Trigger Out (D-Sub connector) to digital I/O 1 port of the g.USBamp using a standard cable provided by g.tec.
  8. Specify the Video Stream as DigitalInput1 and the Audio Stream as DigitalInput4 in the Events Configuration tab.
  9. Alternately, the audio and video event markers can be sampled by the analog channels. In this case you will need to specify the Video Channel and Audio Channel in the Events Configuration tab. In this case, leave the Video Stream and Audio Stream fields empty.
  10. In addition to measuring the latency of visual and auditory stimuli, you can also evaluate the delay of the analog-to-digital converter (ADC). This is done by connecting DigitalOutput1 of the Digital I/O 1 port of the amplifier to the amplifier's digital input or analog input. This requires a custom cable. For details, see the Assembling Required Cables section below. For the g.USBamp, specify the Amp Stream as DigitalInput0 or the Amp Channel as the input channel accordingly.
  11. Next, the location to place the optical detector will be determined. The first task will be run, showing the location on the screen to place the connector.
  12. Press the Start button. BCI2000 will start shortly, and the application window will appear. In this test, the P300 Speller application is shown first.
  13. Place the detector over the "X" on the screen.
  14. Adjust the threshold on the g.TRIGbox for connector A so that it blinks on and off with the appearance of the "X". It may be necessary to turn off the lights in the room so that ambient light does not interfere with the optical detector.
  15. When finished placing the detector and setting the threshold, press Cancel in the BCI2000Certification GUI, and then Quit BCI2000. Navigate to the location of the Data folder (e.g., BCI2000/tools/BCI2000Certification/) and delete the data folder.
  16. Make sure that the computer volume is turned all the way up, and not muted.To set the audio threshold, set audio volume on the computer to maximum. On Windows, to make this process easier in the future, go to the Start menu, click the Control Panel, and go to Sounds. In the Sound window, click the box that puts the volume icon in the task bar. A small speaker should now appear in the bottom-right of the screen in the task bar. Click this icon, and slide the volume up to the max; when you click on this slider, Windows emits a short beep to give an idea of the volume level, which can be used to set the threshold. To do so, make sure that the stereo audio cable is plugged into the g.TRIGbox, and click the slider to emit a sound, checking that the green LED is flashing when you click the slider. If it is not, turn the threshold knob for channel B counter-clockwise, and click the slider again. If it is still not working after several tries, unplug the audio cable from the computer, and check that you can hear the beep through the speakers. If you cannot, make sure that the sound is not muted, and that the sound drivers are properly installed. If you can hear it, plug the audio cable back into the computer audio output (NOT the microphone input), and make sure the g.TRIGbox has power; the light next to the power switch should flash momentarily if the battery levels are OK. You can also use a wall power source (see the g.TRIGbox manual for more information). The threshold is set correctly when the channel B LED is off at rest, and is on when a sound is played.
Connectors schematic.


  1. You are now ready to run all of the tests. To do so, press the Start button on the GUI.
  2. While testing, some tasks may not complete correctly, either because they are too computationally intensive for the selected computer system, or some other mistake or artifact occurred during the test. In this case, BCI2000 can be Quit manually, and the remaining tasks will be run. At the end of all tasks, you can then de-select all tasks, and re-check just the ones that need to be completed. It is necessary to delete data files in the data folder from unusable runs prior to running them again, so that the bad data is not included in the analysis.
  3. When all tasks are complete, press the Analyze button to analyze the collected data. This procedure is detailed later in this document.

Analyzing Data

The BCI2000 analysis tool.

Simply pressing the Analyze button in the Tester will start the Analysis program. It is also possible to run the program in the BCI2000Certification directory by starting BCI2000CertificationAnalysis.exe.

  1. The BCI2000CertificationTester program stores information about how to interpret a session in the session data file itself. From there, it is picked up by the analysis program. You don't have to provide BCI2000CertificationTester .ini files to the analysis program.
  2. The analysis program will open in a new GUI window. When you clicked "analyze" in the tester program, the analyzer's file list is already populated. Otherwise, appropriate folders and files must be entered for this session:
    1. Press the "+" button to select the folder containing your data files. When you select the folder, all data files contained within its subfolders are added automatically.
  3. Finally, set the directory for the output file. Typically, this should be the same folder that contains all of the data files.
  4. When the parameters have been correctly configured, press "Run" to start the analysis, which can take several minutes. Note that debug builds run very slowly, so you should always use a release build for analysis.
  5. When finished, the analysis tool will display results at several levels of detail. On top, a summary is displayed, then a list of requirements is shown, with a global result for each requirement. Further down, results are shown for individual files.
  6. To store results for documentation, you may press Save and Open... to save results to a text file, which can be found in the folder choosen at the bottom left, defaulting to the data folder. The file name will have the format results_(date)_(time).txt. Additionally, this contents of this file will be opened automatically at the end of the process in a new window.

Interpreting Analysis Results

The certification analysis results are shown as the overall result at the top of the analysis tool. In the example below, 33/60 tasks passed, while 27 tasks did not meet the success criteria. Additionally, 48 tasks are missing data, as they do not include auditory stimuli (this is by design). In more detail, the results are segregated into three sections, with overlapping information contained in each section. These sections are Requirements, Performance Statistics, and Individual Tasks. The Requirements section provides details about the global performance of the various certification tests. The success criteria are somewhat arbitrary and are based on our experience measuring response latency in various setups. The Performance Statistics section contains very similar information, with the statistics reported at the top level for easy viewing. Finally, the Individual Tasks section organizes the certification results by task.

The BCI2000 analysis results. Results are described in three sections: Requirements, Performance Statistics, and Individual Tasks.

Navigating into the sub-menu structure provides details about the various tests run, including the stimulus source, the method used to determine the event latency, and the event latency and variance across trials.

The BCI2000 analysis results. Individual Tasks.

The results text file contains detailed results for all tasks. A sample output for a single task is shown here:

The BCI2000 analysis results. The top of the file includes details about the global results.
The BCI2000 analysis results. Throughout the file there are details about each task.


A Note on "Pass/Fail"

The values that determine whether or not a task passes or fails are determined somewhat arbitrarily. For example, we determined that an audio output latency of more than 65 ms is unacceptable for psychophysical research, e.g., BCIs. In the example shown, the audio output latency was ~62 ms for all tasks with audio, and thus these tasks registered as a "pass." However, it is ultimately up to the researcher to determine what is acceptable system timing; this method provides a method of quantifying the system latency values to simplify the process of making these decisions.

You may move the slider near the top of the window in order to display the original GUI elements you saw before clicking "Run". When clicking the checkbox close to "Override requirements", a small editor window appears, containing code for all requirements applied to the data. You may modify requirements there, as you see fit.

Visualizing Certification Test Results using GNUPlot

If you have GNUPlot installed, you can also visualize the distribution of latencies. Simply right-click on the field and select plot.


GNU Plot.

Assembling Required Cables

Depending on what hardware and the latencies of interest are, you may or may not need to assemble custom cables. If you are interested in measuring the audio and visual latency with the gTRIGbox and an amplifier manufactured by a company other than g.tec, you will need to assemble a custom cable going from the output of the gTRIGbox to the digital inputs or analog inputs of your amplifier. It is also possible measure the audio and visual latency without the gTRIGbox, but this will require another trigger onset detection method. If you have a g.tec g.USBamp and want to measure the system latency and the ADC latency, you can follow the following guide.

In the following sections, we provide examples on how to build this cable if you’re using the gTRIGbox and a gUSBamp with a UB serial number (see the gUSBamp digital input page for more information regarding the difference pin assignments between serial numbers). There are two versions of the gTRIGbox, an older legacy version with four 3.5 mm audio connector outputs, and a newer one that has a 15 pin D-sub type connector. We describe the process of building cables for both of these devices.

Legacy gTRIGbox

Connectors schematic.

Amplifier Input

Parts List:

  • 3 Male Mono Audio Connectors
  • 6 12in+ Safety Connector Wires (to USB amplifier input), different colors
  • Soldering Iron and Solder

This section describes how to assemble cables that connect the output of the g.TRIGbox to the amplifier input channels.

  1. Strip the free ends of the 6 safety connector wires (~1/4 in)
  2. Take one wire, and solder the wire to the "signal" pad of one of the mono audio connectors.
  3. Solder another wire to the "ground" pad of the same connector.
  4. If necessary, pass the wires through end of the connector that screws in to cover the connection (see below, in the g.USBamp Amplifier Plug).
g.USBamp Amplifier Plug

Each connector now has a signal and ground wire that can be connector to the g.USBamp inputs, or any amplifier that accepts the standard EEG connector.

Digital I/O Cable

Parts List:

  • 3 Colored Electrical Wires
  • 7-Pin Digital Connector from g.tec
  • Soldering Iron and Solder
  • Silicone or electrical tape for insulation
  • 1 Female Mono Audio Plug

In order to access the digital I/O pins on the g.USBamp, a connector needs to be assembled. The 7-pin digital I/O connector should be ordered through g.TEC, the manufacturer of the g.USBamp.

At least three wires are needed for the circuit, which connect to the digital output 1 pin, the digital input 0 pin, and the ground pin.

g.USBamp Digital I/O Pins
g.USBamp Digital I/O Pins
  1. Strip the ends of the 3 wires (~1/4 in)
  2. Take one wire, and solder the wire to the "signal" pad of the female mono audio connectors.
  3. Solder another wire to the "ground" pad of the same connector.
  4. If necessary, pass the wires through end of the connector that screws in to cover the connection (see below, in the g.USBamp Amplifier Plug).
  5. Solder the ground wire to the center ground pin on the digital I/O connector.
  6. Locate the top of the connector by locating the small plastic notch, and locate pins 3 and 4 relative to the notch.
  7. Solder the signal wire from the mono connector to pin 3 (digital out 1)
  8. Finally, solder the remaining wire (it has not been connected to anything yet) between pin 3 and pin 4. This connects the digital output directly to the digital input.
  9. It may be helpful to insulate the wires from the casing using either a piece of black electrical tape, or an insulating gel, like silicone. If a gel is used, be sure to let it set for several hours or overnight. It is also probably a good idea to check the electrical connection with a multimeter prior to insulating.
  10. Next, attach the rubber sleeve over the end of the part with the female threads, as shown in the panel.
  11. Slide the smaller metal sleeve over the wires, then slide the larger rubber sleeve over the wires.
g.USBamp Digital Wire Plug
  1. For the next step, attach the two metallic pieces that surround the cables, shown laying to the sides in the figure below.
  2. One of the metal pieces has a small groove in it, which should be placed over the notch on the connector; the other metal piece fits on the opposite side of the connector.
  3. Push the small metal sleeve up to the side piece with the groove, and rotate the sleeve until the notch fits in the groove.
  4. Place the end piece over the connector, with the red dot on top and aligned with the connector notch.
  5. Finally, slide the rubber sleeve over the connector, and screw the sleeve into the end piece.
g.USBamp Digital I/O Cable

The plug is assembled next, similar to the. Solder the signal wire from Pin 3 (Digital Out 1) on the digital I/O connector to the signal connector on the female mono plug, and solder the ground wire to the outer ground connector on the plug. The below figure shows this; in this figure, the red wire is the signal wire, and the brown wire is the ground.

Latest gTRIGbox

There are two ways to connect the output of the gTRIGbox to the g.USBamp, “Analog” or “Digital”, as indicated in the figure below. Pins connected by a orange dotted line denote connections that are necessary to measure the amplifier latency.

Connectors schematic.
gTrigBox output schematic.

Digital Configuration

The digital configuration uses digital I/O 1 on the back of the g.tec amplifier. It requires a specific 7 pin g.tec connector that can be ordered from g.tec, the manufacturer of the g.USBamp. Parts list for digital cable:

  1. One 15 pin D-Sub Type Female Connector
  2. One 7 pin Digital Pin Connector from g.tec
  3. Electrical Wire
  4. Soldering Iron and Solder

The D-Sub Type connector can be purchased such that you only need to strip the electrical wires and then insert them to receptacles that tighten with a screwdriver, thus reducing the need for any soldering. This makes the process of assembling the cable easier. In example of this type of connector is shown below:

15 Pin D-Sub Connector with Breakout Board.

In the gUSB Digital Out cables we have seen, here is the coloring of the wires:

DIGITAL I/O CABLE
gTRIGbox Wire Color g.USBamp Digital I/O 1
Blue 7
White 1
Brown 2
Green 3
Yellow 4
Pink 5 or 6
Grey 5 or 6


Procedure for Assembling Cable
  1. Cut 3 pieces of wire, each the same length (about 3 ft should be sufficient).
  2. Strip the ends of these pieces of wire, leaving about a quarter-inch of wire exposed.
  3. Start with the D-Sub connector. Connect each of the pins in gTRIGbox Output column of the table above to its own piece of wire.
  4. Solder the other ends of each of these wires to its appropriate location, as defined in the table above, on the g.USBamp digital I/O connector.
  5. If you also want to measure amplifier latency, strip and solder a piece of wire between pins 1 and 5 on the g.USBamp digital I/O connector.
  6. When assembling the digital I/O connector, it may be helpful to insulate the wires from the casing using either a piece of black electrical tape or an insulating gel, like silicone. If a gel is used, be sure to let it set for several hours or overnight. It is also probably a good idea to check the electrical connection with a multimeter prior to insulating.
  7. Next, attach the rubber sleeve over the end of the part with the female threads, as shown in the panel.
  8. Slide the smaller metal sleeve over the wires, then slide the larger rubber sleeve over the wires.

Analog Configuration

The analog configuration uses the analog inputs on the front on the amplifier to measure latency. To also measure the amplifier latency you will need a specific g.tec connector. Parts list to make analog cable to measure system latency:

  1. One 15 pin D-Sub Type Female Connector
  2. Five Safety Connector Wires (to USB amplifier input)

If you also want to measure amplifier latency, you will also need:

  1. One 7 pin Digital Pin Connector from g.tec
  2. One Additional Safety Connector Wire (to USB amplifier input)
  3. Two resistors for Voltage Divider
  4. Soldering Iron and Solder

If you use the D-Sub connector with a breakout board and do not want to measure amplifier latency, you will not need to do any soldering, making assembly quite easy. Below is a table of what pin connections must be made. The wiring diagram above provides a guide for what pins need to be connected.

Procedure for Assembling Cable
  1. Strip the ends of five wires with safety connectors at one end, leaving a quarter-inch exposed (if you want to measure amplifier latency, strip one additional wire).
  2. Start with the D-Sub connector. Connect each of the pins as shown in the connector schematic to its own piece of safety connector wire.
  3. If you also want to measure amplifier latency, a voltage divider is necessary to bring the 5V output at the gUSBamp's digital output at pin 5 down to a voltage less than 250mV (the max input range on the gUSBamp's analog inputs). Selecting a R1 and R2 such that the following equation is satisfied would result in a 100mV signal at the analog inputs:

0.02=R2R1+R2

  1. Assemble this voltage divider by soldering the resistors, pin 5 on the digital I/O, and additional safety connector together as detailed in the connectors schematic. You can also use a bread board to avoid soldering.
  2. When assembling the digital I/O connector, it may be helpful to insulate the wires from the casing using either a piece of black electrical tape or an insulating gel, like silicone. If a gel is used, be sure to let it set for several hours or overnight. It is also probably a good idea to check the electrical connection with a multimeter prior to insulating.
  3. Next, attach the rubber sleeve over the end of the part with the female threads, as shown in the panel.
  4. Slide the smaller metal sleeve over the wires, then slide the larger rubber sleeve over the wires.

Troubleshooting

Things to watch out for:

  • Parameter files for gUSBamp with channels greater than 16 have pre-defined amplifier IDs. Please set these to your amplifier IDs.
  • BCI2000Certification runs BCI2000 applications from the working directory: C:\BCI2000\tools\BCI2000Certification. The images folder there doesn't contain all required images for CursorTask or a sounds folder for "StimulusPresentation". If necessary, paste the images and sounds folder from the BCI2000/prog directory into the BCI2000/tools/BCI2000Certification directory - overwriting what is currently in that directory.

See also

User Reference:Module Command Line Options, User Reference:Operator Module