<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Swiftj</id>
	<title>BCI2000 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Swiftj"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php/Special:Contributions/Swiftj"/>
	<updated>2026-06-29T18:06:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11895</id>
		<title>User Tutorial:BCI2000Remote</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11895"/>
		<updated>2025-05-14T23:13:48Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Python Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends Operator Scripting commands to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the BCI2000RemoteLib library exist, such as Python, or MATLAB.&lt;br /&gt;
==Note==&lt;br /&gt;
BCI2000Remote is a means of interfacing with the BCI2000 Operator module meaning that there are potentially hundreds of ways we leverage this tool to have a meaningful interface with BCI2000. Because of this we will illustrate a few different integrations using different languages. This &amp;quot;How-to&amp;quot; will be separated into three separate sections: Python, C++, and Matlab.&lt;br /&gt;
==Python Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Find your Python folder. If you have an existing Python environment with your code find it using the Sys Library like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
locate_python = sys.exec_prefix&lt;br /&gt;
print(locate_python)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Locate your BCI2000Remote.py file which should have compiled into your prog folder. &lt;br /&gt;
Find where in your Python code you wish to integrate BCI2000. In this example I will show the minimum requirements for integration with BCI2000:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Set BCI2000 path&lt;br /&gt;
import sys, time&lt;br /&gt;
sys.path.append(&#039;C:\\BCI2000.x64\\prog&#039;)&lt;br /&gt;
&lt;br /&gt;
# BCI2000 setup&lt;br /&gt;
import BCI2000Remote&lt;br /&gt;
bci = BCI2000Remote.BCI2000Remote()&lt;br /&gt;
bci.WindowVisible = True&lt;br /&gt;
bci.WindowTitle   = &#039;BCI2000 Remote Python&#039;&lt;br /&gt;
bci.Connect()&lt;br /&gt;
bci.Execute(&#039;cd ${BCI2000LAUNCHDIR}&#039;)&lt;br /&gt;
bci.Execute(&#039;ADD EVENT Square 2 0&#039;)&lt;br /&gt;
bci.StartupModules((&#039;SignalGenerator&#039;, &#039;DummySignalprocessing&#039;, &#039;DummyApplication&#039;))&lt;br /&gt;
&lt;br /&gt;
bci.Execute(&#039;Wait for Connected&#039;)&lt;br /&gt;
bci.LoadParametersRemote(&#039;..\\parms\\fragments\\amplifiers\\SignalGenerator.prm&#039;)&lt;br /&gt;
bci.Execute(&#039;Wait for Running&#039;)&lt;br /&gt;
bci.Execute(&#039;Set event Square 1&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is how you import BCI2000Remote:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote1.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you instantiate the operator object:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote 2.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how to customize the operator and connect to it:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCI2000Remote2.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you add your states:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_4.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to specify your signal source, signal processing, and application modules:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_5.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to load a parameter file(you can learn more about parameters [[Technical_Reference:Parameter_File|here]]):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_6.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to connect and issue commands to BCI2000:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_666.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And finally, how to tell BCI2000 to set states to a value during runtime:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_8.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is run your code. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:BCIRemote_7.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C++ Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the C++ file or solution you would like to integrate with BCI2000 in Visual Studio, and find where it is located on your computer.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to the program&#039;s properties, and make the following changes:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; General, add the following folders from BCI2000 (64-bit)&#039;s src folder: &amp;lt;i&amp;gt; \core\Operator\BCI2000Remote, \shared\utils\Lib, \shared\config. &amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to Configuration Properties -&amp;gt; Linker -&amp;gt; Input, and add &amp;lt;i&amp;gt; ws2_32.lib &amp;lt;/i&amp;gt; to Additional Dependencies.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; Advanced, add &amp;lt;i&amp;gt;4996&amp;lt;/i&amp;gt; to the Disable Specific Warnings section.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add your Operator executable and the BCI2000RemoteLib dynamic library to the same directory as the program you intend to integrate. This can be found in the prog folder.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Also, add the following files to the directory with your program and &amp;lt;i&amp;gt;Operator.exe&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Make sure that you include all of your dependencies including BCI2000Remote.h&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Next, instantiate the BCI2000Remote object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Specify your startup modules and any flags you wish to start them with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; modules{ &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  if( !bci.StartupModules( modules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Load any parameter files and set subject information&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And here we just have BCI2000 send us back a feedback signal:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is compile and run it. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; Be sure to compile this in your prog folder. This can be done by navigating again to Configuration Properties -&amp;gt; General, and changing the Output Directory to the path of the BCI2000 prog folder.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; modules{ &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  if( !bci.StartupModules( modules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Load a parameter file, and set subject information&lt;br /&gt;
  bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Print feedback signal&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==MatlabTutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the Matlab file you would like to integrate with BCI2000.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Locate the BCI2000RemoteLib file in the BCI2000 prog folder, and BCI2000RemoteLib.h in src\core\Operator\BCI2000Remote, and load these into the Matlab file. Modify the file paths in &amp;lt;i&amp;gt;loadlibrary(...)&amp;lt;/i&amp;gt; as needed. &lt;br /&gt;
Note that BCI2000RemoteLib&#039;s file name has a &amp;quot;64&amp;quot; appended when it was built in 64 bit mode, and a &amp;quot;32&amp;quot; if built iin 32 bit mode.&lt;br /&gt;
In this tutorial, we will be using the 64 bit version.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
%% c library load, initial part&lt;br /&gt;
BCI2000root = &#039;C:\bci2000.x64&#039;;&lt;br /&gt;
if not(libisloaded(&#039;bci&#039;))&lt;br /&gt;
    loadlibrary(fullfile(BCI2000root,&#039;prog&#039;,&#039;BCI2000RemoteLib64&#039;),...&lt;br /&gt;
        fullfile(BCI2000root,&#039;src&#039;,&#039;core&#039;,&#039;Operator&#039;,&#039;BCI2000Remote&#039;,&#039;BCI2000RemoteLib.h&#039;), &#039;alias&#039;, &#039;bci&#039;)&lt;br /&gt;
end &lt;br /&gt;
libfunctions(&#039;bci&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Locate Operator.exe in the prog folder. Recover the memory, change the directory, and make the window visible in BCI2000. Again, modify the file path if it differs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
%need to call BCI2000Remote_Delete to recover the memory&lt;br /&gt;
bciHandle = calllib(&#039;bci&#039;, &#039;BCI2000Remote_New&#039;);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetOperatorPath&#039;, bciHandle, fullfile(BCI2000root,&#039;prog&#039;,&#039;Operator&#039;));&lt;br /&gt;
&lt;br /&gt;
% if we fail cto establish a connection to BCI2000Remote&lt;br /&gt;
if calllib(&#039;bci&#039;, &#039;BCI2000Remote_Connect&#039;, bciHandle) ~= 1&lt;br /&gt;
    fprintf(&#039;bci connect fail!&#039;)&lt;br /&gt;
    calllib(&#039;bci&#039;, &#039;BCI2000Remote_Delete&#039;, bciHandle); % call BCI2000Remote_Delete to recovery the memory&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
% Startup BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Change directory $BCI2000LAUNCHDIR&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Show window; Set title ${Extract file base $0}&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Reset system&#039;, 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Add new states, events, or parameters before starting up the system. Note that it is greatly preferred to use events instead of states because of timing precision.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
% Create new parameter (must be done before startup)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Add Parameter Application:TestParameterField string TestParameter= FirstNewParameter % % %&#039;, 0); &lt;br /&gt;
&lt;br /&gt;
% Define events&lt;br /&gt;
% Define new event with 1 bit of information (2 colors)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;add event Square 1 0&#039;, 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add in the proper modules (Signal Generator, Signal Processor, and Application). Refer to the documentation [[Technical_Reference:BCI2000Remote_Library]] for more information on BCI2000 remote functions. Also refer to the example Matlab code under [[Programming_Reference:BCI2000Remote_Class#Matlab_Example]].&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
% Startup system localhost&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Startup system localhost&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Establish connection to three modules&lt;br /&gt;
SourceModule = &#039;SignalGenerator&#039;;&lt;br /&gt;
modules      = libpointer(&#039;stringPtrPtr&#039;, {[SourceModule &#039; --local --LogKeyboard=1&#039;], &#039;DummySignalProcessing&#039;, &#039;DummyApplication&#039;});&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_StartupModules2&#039;, bciHandle, modules, 3);&lt;br /&gt;
&lt;br /&gt;
% Wait for connected before loading parameters!&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Connected&#039;, 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Load parameter files, modify parameters directly, and add watches after BCI2000 is connected. It can also be helpful to wait for bci2000 to start running (collecting data) before proceeding.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
% Load parameter files&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_LoadParametersRemote&#039;, bciHandle, fullfile(BCI2000root,&#039;parms&#039;,&#039;fragments&#039;,&#039;amplifiers&#039;,&#039;SignalGenerator.prm&#039;));&lt;br /&gt;
&lt;br /&gt;
% Set parameter values&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetDataDirectory&#039;, bciHandle, fullfile(BCI2000root,&#039;data&#039;,&#039;BJH&#039;));&lt;br /&gt;
&lt;br /&gt;
%Set watches to appear automatically&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;visualize watch Square&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Wait for the user to click SetConfig and Start&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Running&#039;, 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; While BCI2000 is running you can also get and set event and state values, and also get parameter values. Note that you cannot modify parameter values while BCI2000 is running. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
% Get parameter value&lt;br /&gt;
SamplingRate = calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetParameter&#039;, bciHandle, &#039;SamplingRate&#039;);&lt;br /&gt;
fprintf([&#039;\nSamplingRate: &#039; num2str(SamplingRate) &#039;Hz\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Get event value&lt;br /&gt;
[~,~,~,Square]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetEventVariable&#039;, bciHandle, &#039;Square&#039;, 0.0);&lt;br /&gt;
&lt;br /&gt;
% BCI2000 set white rectangle to 1 (true)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Set event Square 1&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Get state value&lt;br /&gt;
% Immediately after data block has been acquired from hardware, the &lt;br /&gt;
% DataIOFilter writes a 16-bit millisecond-resolution time stamp into the &lt;br /&gt;
% SourceTime state. Block duration is measured as the difference between&lt;br /&gt;
% two consecutive time stamps.&lt;br /&gt;
[~,~,~,SourceTime]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetStateVariable&#039;, bciHandle, &#039;SourceTime&#039;, 0.0);&lt;br /&gt;
fprintf([&#039;\nSourceTime: &#039;, num2str(SourceTime), &#039;\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Stop running BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetStateVariable&#039;, bciHandle, &#039;Running&#039;, 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=ZwLcovHZabw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]][[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11890</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11890"/>
		<updated>2025-05-13T00:29:02Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Using Use Expression Option */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|500px|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the event is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the event in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the three new components - &#039;&#039;BCI2000Start&#039;&#039;, &#039;&#039;BCIUpdateEvent&#039;&#039;, and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=550px heights=550px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new event called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This event will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;Events&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new event to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the event should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the event can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add Event into BCI2000&amp;quot;|PsychoPy - Add Event into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 Event - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateEvent&#039;&#039;&#039;. Fill in the fields &#039;&#039;Event Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 event we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the event &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateEvent1.png|alt=&amp;quot;PsychoPy - Update Event in BCI2000&amp;quot;|PsychoPy - Update Event in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created event to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy10.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;Events&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new event to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the event should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the event can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add Event into BCI2000&amp;quot;|PsychoPy - Add Event into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 Event - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateEvent&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the event &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET EVENT commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET EVENT responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update Event in BCI2000&amp;quot;|PsychoPy - Update Event in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created event to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciStart2.png&amp;diff=11889</id>
		<title>File:PsychoPyBciStart2.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciStart2.png&amp;diff=11889"/>
		<updated>2025-05-13T00:26:44Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:PsychoPyBciStart2.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy-Bci Stroop Extended Start with Use Expression Option&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11888</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11888"/>
		<updated>2025-05-12T22:24:35Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Using Response Component Variable Option */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|500px|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the event is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the event in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the three new components - &#039;&#039;BCI2000Start&#039;&#039;, &#039;&#039;BCIUpdateEvent&#039;&#039;, and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=550px heights=550px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new event called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This event will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;Events&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new event to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the event should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the event can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add Event into BCI2000&amp;quot;|PsychoPy - Add Event into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 Event - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateEvent&#039;&#039;&#039;. Fill in the fields &#039;&#039;Event Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 event we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the event &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateEvent1.png|alt=&amp;quot;PsychoPy - Update Event in BCI2000&amp;quot;|PsychoPy - Update Event in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created event to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy10.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciUpdateEvent1.png&amp;diff=11887</id>
		<title>File:PsychoPyBciUpdateEvent1.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciUpdateEvent1.png&amp;diff=11887"/>
		<updated>2025-05-12T22:21:18Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciStart1.png&amp;diff=11886</id>
		<title>File:PsychoPyBciStart1.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciStart1.png&amp;diff=11886"/>
		<updated>2025-05-12T22:19:37Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:PsychoPyBciStart1.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy-Bci Stroop Extended Start with Response Component Variable Option&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11885</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11885"/>
		<updated>2025-05-12T22:17:39Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Using Response Component Variable Option */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|500px|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the event is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the event in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the three new components - &#039;&#039;BCI2000Start&#039;&#039;, &#039;&#039;BCIUpdateEvent&#039;&#039;, and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=550px heights=550px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new event called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This event will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;Events&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new event to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the event should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the event can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add Event into BCI2000&amp;quot;|PsychoPy - Add Event into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 Event - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateEvent&#039;&#039;&#039;. Fill in the fields &#039;&#039;Event Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 event we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the event &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateEvent1.png|alt=&amp;quot;PsychoPy - Update Event in BCI2000&amp;quot;|PsychoPy - Update Event in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created event to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyDemoStart.png&amp;diff=11884</id>
		<title>File:PsychoPyDemoStart.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyDemoStart.png&amp;diff=11884"/>
		<updated>2025-05-12T22:14:56Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:PsychoPyDemoStart.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy Stroop Extended Demo Start&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11883</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11883"/>
		<updated>2025-05-12T22:12:20Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Integrating BCI2000 into PyschoPy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|500px|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the event is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the event in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the three new components - &#039;&#039;BCI2000Start&#039;&#039;, &#039;&#039;BCIUpdateEvent&#039;&#039;, and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=550px heights=550px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPy_Start.png&amp;diff=11882</id>
		<title>File:PsychoPy Start.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPy_Start.png&amp;diff=11882"/>
		<updated>2025-05-12T22:11:13Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:PsychoPy Start.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11881</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11881"/>
		<updated>2025-05-12T22:06:20Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Developer version */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|500px|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the event is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the event in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the three new components - &#039;&#039;BCI2000Start&#039;&#039;, &#039;&#039;BCIUpdateEvent&#039;&#039;, and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11880</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11880"/>
		<updated>2025-05-12T21:59:51Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* BCI2000Start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|500px|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the event is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the event in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039;, &#039;&#039;BCIUpdateEvent&#039;&#039;, and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:BCI2000Start.png&amp;diff=11879</id>
		<title>File:BCI2000Start.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:BCI2000Start.png&amp;diff=11879"/>
		<updated>2025-05-12T21:59:17Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:BCI2000Start.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyWithoutBCI.png&amp;diff=11878</id>
		<title>File:PsychoPyWithoutBCI.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyWithoutBCI.png&amp;diff=11878"/>
		<updated>2025-05-12T21:56:59Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:PsychoPyWithoutBCI.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy without BCI&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11877</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11877"/>
		<updated>2025-05-12T21:56:15Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Integrating BCI2000 into PyschoPy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the event is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the event in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039;, &#039;&#039;BCIUpdateEvent&#039;&#039;, and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:Psychopy&amp;diff=11876</id>
		<title>User Tutorial:Psychopy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:Psychopy&amp;diff=11876"/>
		<updated>2025-05-12T18:50:05Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. The video first describes the three components that are developed to remotely start BCI2000 from PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes on to an example.&lt;br /&gt;
&lt;br /&gt;
==Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy1.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039;, &#039;&#039;&#039;BCIUpdateEvent&#039;&#039;&#039;, and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:Psychopy2.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open PsychoPy and then open your experiment file (StroopExtended is what we use in the demo)&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy3.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the part of the experiment where you want to start BCI2000 (in this case the &#039;&#039;instruct&#039;&#039; tab) and look under the custom section of the components for the &#039;&#039;&#039;BCI Connect&#039;&#039;&#039; and &#039;&#039;&#039;BCI Update Event&#039;&#039;&#039; components&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy4.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the BCI2000 Start Component by clicking on it. &lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Enter the path to the prog folder in the BCI2000 directory where your BCI2000Remote.py file exists&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy5.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the events that you want to record separated by commas (the first value will always be the default value and the second value will always be the maximum value). It is strongly recommended to use events instead of states, as events are recorded on a per-sample basis, while states are recorded on a pre-block basis. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy6.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the BCIUpdateEvent component to where you want to update event values. You can either choose to simply pass a variable through BCIUpdateEvent, or you can specify that it execute a specific Python script by choosing the &amp;quot;Use Expression&amp;quot; ticker&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy7.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy8.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy9.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy10.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=yPacLewE3Xo&amp;amp;list=PL6LrR5Nj3cAxOxKHNsnqyKfLDGikpi8Qi&amp;amp;index=4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]][[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy10.png&amp;diff=11875</id>
		<title>File:Psychopy10.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy10.png&amp;diff=11875"/>
		<updated>2025-05-12T18:34:43Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:Psychopy10.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy9.png&amp;diff=11874</id>
		<title>File:Psychopy9.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy9.png&amp;diff=11874"/>
		<updated>2025-05-12T18:34:33Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:Psychopy9.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy8.png&amp;diff=11873</id>
		<title>File:Psychopy8.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy8.png&amp;diff=11873"/>
		<updated>2025-05-12T18:34:25Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:Psychopy8.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy7.png&amp;diff=11872</id>
		<title>File:Psychopy7.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy7.png&amp;diff=11872"/>
		<updated>2025-05-12T18:34:14Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:Psychopy7.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy6.png&amp;diff=11871</id>
		<title>File:Psychopy6.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy6.png&amp;diff=11871"/>
		<updated>2025-05-12T18:34:01Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:Psychopy6.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy5.png&amp;diff=11870</id>
		<title>File:Psychopy5.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy5.png&amp;diff=11870"/>
		<updated>2025-05-12T18:33:50Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:Psychopy5.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy4.png&amp;diff=11869</id>
		<title>File:Psychopy4.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy4.png&amp;diff=11869"/>
		<updated>2025-05-12T18:33:38Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:Psychopy4.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy2.png&amp;diff=11868</id>
		<title>File:Psychopy2.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Psychopy2.png&amp;diff=11868"/>
		<updated>2025-05-12T18:33:26Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: Swiftj uploaded a new version of File:Psychopy2.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11867</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11867"/>
		<updated>2025-05-12T16:41:58Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* BCI2000UpdateEvent */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the event is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the event in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039; and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11866</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11866"/>
		<updated>2025-05-12T16:40:28Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* BCI2000UpdateEvent */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|500px|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039; and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11865</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11865"/>
		<updated>2025-05-12T16:22:42Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* BCI2000UpdateEvent */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.PNG|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039; and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11864</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11864"/>
		<updated>2025-05-12T16:21:06Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCIUpdateEvent.png|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039; and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:BCIUpdateEvent.PNG&amp;diff=11863</id>
		<title>File:BCIUpdateEvent.PNG</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:BCIUpdateEvent.PNG&amp;diff=11863"/>
		<updated>2025-05-12T16:20:38Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11862</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11862"/>
		<updated>2025-05-12T16:17:53Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateEvent ===&lt;br /&gt;
Note: It is highly recommended to use EVENTS instead of STATES when recording experimental values using BCI2000. This is because the timing of events is on a per-sample basis, while states are recorded on a per-block basis. The time of recorded states can be delayed by up to a full block (often up to 100ms).&lt;br /&gt;
&lt;br /&gt;
This component defines which event to update and when. It takes the following parameters:&lt;br /&gt;
; Event Name : The name of the event in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the event. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the event.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the event is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET EVENT&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateEvent.png|alt=&amp;quot;BCI2000 update event component image showing its parameters&amp;quot;|BCIUpdateEvent Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateState Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039; and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Howto:Building_and_Customizing_BCI2000&amp;diff=11727</id>
		<title>Programming Howto:Building and Customizing BCI2000</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Howto:Building_and_Customizing_BCI2000&amp;diff=11727"/>
		<updated>2025-02-05T17:46:27Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Video Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial walks you through the process of obtaining the [[Programming_Reference:BCI2000_Source_Code|BCI2000 source distribution]], and using it to build and test your own custom [[BCI2000_Glossary#Filter|filters]], implemented in C++ inside your own custom [[BCI2000_Glossary#Core_Module|core module]]. It assumes that you have a good working knowledge of the C++ language,  and basic familiarity with the compiler/IDE that you are going to use.&lt;br /&gt;
&lt;br /&gt;
This tutorial is a simplified version of the previous [[Programming Howto:Quickstart Guide]], which is slightly outdated but kept in the wiki as it contains valuable suggestions and exercises.&lt;br /&gt;
&lt;br /&gt;
==Howto steps==&lt;br /&gt;
*[[Programming Howto:Install Prerequisites|Install Prerequisites]]&lt;br /&gt;
:shows you how to install TortoiseSVN, CMake, VisualStudio, and Qt.&lt;br /&gt;
*[[Programming Howto:Register with BCI2000 Project|Register with the BCI2000 Project]]&lt;br /&gt;
:explains how to obtain a BCI2000 user account.&lt;br /&gt;
*[[Programming Howto:Download the BCI2000 Sourcecode|Download the BCI2000 Sourcecode]]&lt;br /&gt;
:details the steps how to use TortoiseSVN to download the BCI2000 sourcecode.&lt;br /&gt;
*[[Programming Howto:Configure BCI2000 for Compilation|Configure BCI2000 for Compilation]]&lt;br /&gt;
:demonstrates how to use CMake to create a BCI2000 solution file.&lt;br /&gt;
*[[Programming Howto:Compile BCI2000|Compile BCI2000]]&lt;br /&gt;
:illustrates how to compile BCI2000 using VisualStudio.&lt;br /&gt;
*[[Programming Howto:Create a custom Signal Processing Module|Create a custom Signal Processing Module]]&lt;br /&gt;
:shows how to create a new BCI2000 module from a template.&lt;br /&gt;
*[[Programming Howto:Attach the Debugger to a BCI2000 Module|Attach the Debugger to a BCI2000 Module]]&lt;br /&gt;
:explains how to attach the VisualStudio debugger to a running module.&lt;br /&gt;
*[[Programming Howto:Programmatically wait for the Debugger in a BCI2000 Module|Programmatically wait for the Debugger in a BCI2000 Module]]&lt;br /&gt;
:explains how to halt execution of a BCI2000 module, and wait for the user to attach a debugger.&lt;br /&gt;
*[[Programming Howto:Deploy a Release version of a BCI2000 Module|Deploy a Release version of a BCI2000 Module]]&lt;br /&gt;
:demonstrates how to build a self-contained version of your new module.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
Note that this video is quite out of date - please install the currently released versions of TortoiseSVN, CMake, Qt, and Visual Studio instead of those recommended in the video.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/3Jz527f2n5o&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Howto]][[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:StimulusPresentationTask&amp;diff=11717</id>
		<title>User Reference:StimulusPresentationTask</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:StimulusPresentationTask&amp;diff=11717"/>
		<updated>2025-01-14T21:44:21Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Result */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The main purpose of this task is to present a sequential series of auditory and/or visual stimuli to the user of the BCI system.&lt;br /&gt;
&lt;br /&gt;
The StimulusPresentationTask is suited to implement evoked response (ERP) paradigms, as well as to display tasks for selective activation experiments, such as SMR screening sessions.&lt;br /&gt;
&lt;br /&gt;
The sequence and nature of the stimuli can be defined by the investigator. In addition to stimulus delivery, the task can optionally be used in conjunction with BCI2000&#039;s P300 Signal Processing module ([[User_Reference:P3TemporalFilter|P3TemporalFilter]]) to provide feedback to a selected stimulus in either a copy or a free mode.&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
&lt;br /&gt;
===Stimulus Definition===&lt;br /&gt;
&lt;br /&gt;
Stimuli are set up through a parameter defined by the application module. This implicitly defines the total number of stimuli as well as the details of each stimulus.&lt;br /&gt;
&lt;br /&gt;
Each stimulus is defined by the following properties:&lt;br /&gt;
  &lt;br /&gt;
#Caption &lt;br /&gt;
#Icon file &lt;br /&gt;
#Audio file &lt;br /&gt;
&lt;br /&gt;
In addition to stimuli that are part of the actual stimulation sequence, the [[#FocusOn|FocusOn]] &lt;br /&gt;
and [[#Result|Result]] parameters contain definitions for a stimulus that indicates what to focus on,&lt;br /&gt;
and a stimulus that presents the result. These stimuli are only used when the task is set to copy or free mode. &lt;br /&gt;
&lt;br /&gt;
The following table contains an example definition of two stimuli:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|              ||stimulus1 ||stimulus2&lt;br /&gt;
|-&lt;br /&gt;
|caption       ||Donkey || &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|icon          ||images\donkey.bmp  ||images\elephant.bmp&lt;br /&gt;
|-&lt;br /&gt;
|audio         || sounds\snicker.wav  ||sounds\trumpet.wav&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
A blank entry for caption/icon/audio file is accepted, and defines that no presentation of the respective element takes place (e.g., see caption in stimulus2). The stimulus definition parameter does &#039;&#039;not&#039;&#039; contain a description on how the stimuli are presented.&lt;br /&gt;
For further details, see the [[#Stimuli|Stimuli]] parameter description.&lt;br /&gt;
&lt;br /&gt;
====Stimulus Codes====&lt;br /&gt;
When defining a stimulus sequence, stimuli are referred to an integer ID called &#039;&#039;stimulus code&#039;&#039;.&lt;br /&gt;
The stimulus code associated with a stimulus corresponds to the column in which that stimulus is defined in the [[#Stimuli|Stimuli]] matrix parameter.&lt;br /&gt;
&lt;br /&gt;
In the recorded data file, stimulus presentation is indicated by the [[#StimulusCode|StimulusCode]] state.&lt;br /&gt;
During presentation of a stimulus, this state is set to the associated stimulus code.&lt;br /&gt;
&lt;br /&gt;
===Stimulus Sequence===&lt;br /&gt;
&lt;br /&gt;
Stimuli are presented in a certain sequence. This sequence can either be deterministic, i.e., defined by the investigator, or pseudo-random. &lt;br /&gt;
&lt;br /&gt;
====Deterministic Sequence:====&lt;br /&gt;
&lt;br /&gt;
The investigator defines the order by &lt;br /&gt;
entering a list of stimulus IDs to be presented. As an example: &lt;br /&gt;
&lt;br /&gt;
1 5 3 4 2 &lt;br /&gt;
&lt;br /&gt;
defines a sequence in which stimulus 1 is presented first, followed by stimulus 5, etc.&lt;br /&gt;
&lt;br /&gt;
====Random Sequence:====&lt;br /&gt;
&lt;br /&gt;
The investigator defines absolute stimulus frequencies for each stimulus, with the sum &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; of those values equaling the total number of stimulus presentations in the final sequence. The resulting random sequence is obtained by applying a random permutation to an arbitrary sequence that reproduces the given frequencies, with all &amp;lt;math&amp;gt;N!&amp;lt;/math&amp;gt; index permutations being equally probable (Block Randomization).&lt;br /&gt;
&lt;br /&gt;
As an example: &lt;br /&gt;
  &lt;br /&gt;
6 2 3&lt;br /&gt;
 &lt;br /&gt;
defines a sequence of 11 stimulus presentations with stimulus 1 being presented 6 times, stimulus 2, 2 times, and stimulus 3, 3 times. The resulting sequence &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; will be a permutation of &amp;lt;math&amp;gt;S_0 = [1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3]&amp;lt;/math&amp;gt;, and the probability for &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; to equal &amp;lt;math&amp;gt;S_0&amp;lt;/math&amp;gt; will be &amp;lt;math&amp;gt;\frac{6!\times2!\times3!}{(6+2+3)!}=1/4620&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Multiple sequences can be generated from the given frequencies. The investigator can define how many sequences are generated and presented.&lt;br /&gt;
&lt;br /&gt;
====P3Speller Compatible====&lt;br /&gt;
Sequences are random, with each stimulus being presented &#039;&#039;NumberOfSequences&#039;&#039; times, in a block-randomized fashion. When in copy mode, each entry in the &#039;&#039;ToBeCopied&#039;&#039; parameter corresponds to a &#039;&#039;NumberOfSequences&#039;&#039;-times repetition of all stimulus codes. In other &#039;&#039;InterpretMode&#039;&#039;s, stimulus presentation is repeated indefinitely. This mode is intended as a compatibility mode for transitioning experiments from or to the [[User Reference:P3SpellerTask|P3SpellerTask]].&lt;br /&gt;
&lt;br /&gt;
===Stimulus Delivery===&lt;br /&gt;
&lt;br /&gt;
For any stimulus, delivery occurs simultaneously for caption, icon, and audio. &lt;br /&gt;
When both caption and icon are defined, the caption appears overlaying the icon.&lt;br /&gt;
&lt;br /&gt;
An investigator can specify:&lt;br /&gt;
  &lt;br /&gt;
*[[#WindowWidth|Size and position]] of the target window. &lt;br /&gt;
&lt;br /&gt;
*[[#StimulusWidth|Width and height]] of caption and icon in percent of screen width/height, or that the icon should appear in its original pixel size.&lt;br /&gt;
&lt;br /&gt;
*Whether captions, icons, or audio files will be presented (i.e., a [[#IconSwitch|global switch]]). There are no individual switches for each stimulus. However, individual captions/icons/wave files are not presented if they are not defined (i.e., their respective entries are blank).&lt;br /&gt;
&lt;br /&gt;
*The [[#AudioVolume|volume for audio playback]] as a percentage of maximum volume. &lt;br /&gt;
&lt;br /&gt;
*[[#BackgroundColor|Window background color]] in RGB.&amp;lt;br /&amp;gt;(For convenience, RGB values may be entered in hexadecimal notation, e.g. &amp;lt;tt&amp;gt;0xff0000&amp;lt;/tt&amp;gt; for red.) &lt;br /&gt;
&lt;br /&gt;
*[[#CaptionColor|Caption color]] in RGB.&lt;br /&gt;
 &lt;br /&gt;
*The [[#StimulusDuration|duration]] of stimulus presentation.&amp;lt;br /&amp;gt;(Playback of audio extending above the specified duration will be muted.)&lt;br /&gt;
 &lt;br /&gt;
*The duration of an [[#ISIMinDuration|inter-stimulus interval]] following stimulus presentation.&amp;lt;br /&amp;gt;(During the inter-stimulus interval, the screen is blank and audio is turned off.) &lt;br /&gt;
&lt;br /&gt;
*Variance in inter-stimulus intervals, with probability distributed uniformly over the interval between minimum and maximum inter-stimulus interval.&lt;br /&gt;
&lt;br /&gt;
*For documentation purposes, a user can enter a [[#UserComment|comment]] to the specific run in a string parameter.&lt;br /&gt;
&lt;br /&gt;
==Processing of Classification Results==&lt;br /&gt;
&lt;br /&gt;
The task can be configured to interpret results communicated to it by the [[User Reference:P3TemporalFilter|P3 Signal Processing]] module. These results represent a judgment of which of the stimuli was most likely selected. Handling of these results is identical to the [[User Reference:P3SpellerTask|P3 Spelling Task]]. &lt;br /&gt;
&lt;br /&gt;
When it transmits a classification result, Signal Processing sets the state &#039;&#039;StimulusCodeRes&#039;&#039; to the stimulus code that was originally transmitted to it by the user application. For example, when Signal Processing sets &#039;&#039;StimulusCodeRes&#039;&#039;  to 3, it transmits classification results for stimulus 3. In addition, it sets &#039;&#039;StimulusTypeRes&#039;&#039;  to reflect the type of stimulus &lt;br /&gt;
(0=non-target, 1=target) when the system is in copy mode. Signal Processing transmits the classification result as one number (i.e., the first control signal).&lt;br /&gt;
&lt;br /&gt;
===Free Mode===&lt;br /&gt;
&lt;br /&gt;
The task can be configured to operate in free mode. In this case, the sequence of stimulus deliveries is followed by a time period, in which the Signal Processing classification result is presented. The final classification result is the stimulus with the highest classification result.&lt;br /&gt;
&lt;br /&gt;
In order to present this result, the system uses the stimulus defined in the &amp;lt;tt&amp;gt;result&amp;lt;/tt&amp;gt; column of the stimuli parameter. This presentation is followed by delivery of the determined stimulus. In other words, after a sequence of stimulus deliveries, the system might play a .wav file that says: &amp;quot;the result is,&amp;quot; followed by a .wav file that says &amp;quot;yes.&amp;quot; (assuming &amp;quot;yes&amp;quot; represents&lt;br /&gt;
the stimulus that produced the highest classification result).&lt;br /&gt;
&lt;br /&gt;
Finally, the task sends this result to the operator module as an ASCII text message so that it appears in a log window.&lt;br /&gt;
&lt;br /&gt;
Free mode does not terminate until the investigator suspends operation.&lt;br /&gt;
&lt;br /&gt;
===Copy Mode===&lt;br /&gt;
&lt;br /&gt;
Copy mode is similar to free mode. In copy mode, the investigator can define a list of stimuli to be copied (e.g., &amp;quot;3 5 4&amp;quot;). In this example, the user has to attend to stimulus 3 for the first sequence, 5 for the second sequence, etc.&lt;br /&gt;
&lt;br /&gt;
In addition to presenting the result, the delivery of stimuli is preceded by a presentation that describes the stimulus to which the user must attend. This presentation uses the stimulus that is defined in the [[#FocusOn|FocusOn]] parameter. This presentation is followed by delivery of the desired target stimulus. As an example, the system might say &amp;quot;Please focus on&amp;quot; ... &amp;quot;yes,&amp;quot; before it starts with the sequence of stimulus deliveries.&lt;br /&gt;
&lt;br /&gt;
Copy mode terminates (i.e., suspends the task) when the user has finished copying all stimuli specified by the investigator.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
{{ApplicationWindowParams}}&lt;br /&gt;
{{StimulusTaskParams}}&lt;br /&gt;
&lt;br /&gt;
====SequenceType====&lt;br /&gt;
Enumerated value selecting between&lt;br /&gt;
*0 deterministic sequence mode: the sequence is explicitly defined in the &#039;&#039;Sequence&#039;&#039; parameter; &lt;br /&gt;
*1 random sequence mode: the sequence is random, with pre-defined stimulus frequencies.&lt;br /&gt;
*2 P3Speller compatible mode: the sequence is random, with each stimulus being presented exactly &#039;&#039;NumberOfSequences&#039;&#039; times, in a block-randomized fashion. In copy spelling mode, one such sequence is presented for each entry in the &#039;&#039;ToBeCopied&#039;&#039; parameter. In other &#039;&#039;InterpretMode&#039;&#039;s, such sequences are repeated indefinitely; the current run must be stopped manually.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
In deterministic mode, a list of stimulus codes defining the sequence of presentations.&lt;br /&gt;
In random mode, a list of integer stimulus frequencies.&lt;br /&gt;
In P3Speller compatible mode, this parameter is ignored.&lt;br /&gt;
&lt;br /&gt;
====NumberOfSequences====&lt;br /&gt;
The number of sequence repetitions in a run (a run corresponds to a single data file).&lt;br /&gt;
&lt;br /&gt;
====ToBeCopied====&lt;br /&gt;
A list of stimulus codes defining a sequence of attended stimuli.&lt;br /&gt;
At the beginning of each presentation sequence, another entry from this list is announced as the attended stimulus (see [[#FocusOn|FocusOn]]).&lt;br /&gt;
&lt;br /&gt;
This parameter is only used in [[#InterpretMode|copy mode]].&lt;br /&gt;
&lt;br /&gt;
====UserComment====&lt;br /&gt;
An arbitrary string intended for documentation purposes.&lt;br /&gt;
&lt;br /&gt;
====Stimuli====&lt;br /&gt;
A matrix defining the properties of stimuli to be presented.&lt;br /&gt;
Columns of the &#039;&#039;Stimuli&#039;&#039; matrix correspond to individual stimuli and their stimulus codes.&lt;br /&gt;
For each stimulus, the following properties are defined by its row entries:&lt;br /&gt;
*Caption: a text string, with its size and color depending on the &#039;&#039;CaptionHeight&#039;&#039; and &#039;&#039;CaptionColor&#039;&#039; parameters;&lt;br /&gt;
*Icon: a graphic file (a number of formats are supported through libav), with its size depending on the &#039;&#039;StimulusWidth&#039;&#039; parameter;&lt;br /&gt;
*AV: an AV file (video with or without audio, or an audio file), with playback starting at the onset of the visual stimuli.&lt;br /&gt;
For backward compatibility reasons, each of these three rows must be present.&lt;br /&gt;
A blank entry for caption/icon/AV is accepted, and defines that no presentation of the respective element takes place.&lt;br /&gt;
Note that for Windows .bmp files, the top left pixel is taken to be the transparent background color, so results may not be as expected. Try a different format, or add a 1-pixel frame in a different color to the image.&lt;br /&gt;
&lt;br /&gt;
Additionally, a number of global stimulus parameters may be overridden with specific values for individual stimuli.&lt;br /&gt;
To do this, for each parameter to be individualized, add an additional row to the Stimuli matrix. The row label indicates the parameter to be changed, and has to be one of:&lt;br /&gt;
*StimulusDuration,&lt;br /&gt;
*EarlyOffsetExpression, &lt;br /&gt;
*ISIMinDuration, ISIMaxDuration, &lt;br /&gt;
*StimulusWidth, CaptionHeight, CaptionColor, AudioVolume.&lt;br /&gt;
&lt;br /&gt;
Whenever one of these rows is present, the corresponding global parameter will be ignored.&lt;br /&gt;
&lt;br /&gt;
====FocusOn====&lt;br /&gt;
In copy mode (see [[#InterpretMode|InterpretMode]]), the attended stimulus is presented prior to the stimulus sequence ([[#PreSequenceTime|PreSequenceTime]]),&lt;br /&gt;
preceded with a special announcement stimulus.&lt;br /&gt;
This stimulus&#039; properties are defined by the &#039;&#039;FocusOn&#039;&#039; parameter, which is a matrix in the same format as the &#039;&#039;Stimuli&#039;&#039; parameter.&lt;br /&gt;
Usually, this matrix has a single column; when multiple columns are present, all stimuli are presented concurrently.&lt;br /&gt;
To control the duration of the &amp;quot;FocusOn&amp;quot; announcement and the attended stimulus independently of the global [[#StimulusDuration|StimulusDuration]] parameter, a &#039;&#039;StimulusDuration&#039;&#039; row may be added in the &#039;&#039;FocusOn&#039;&#039; matrix.&lt;br /&gt;
&lt;br /&gt;
====Result====&lt;br /&gt;
In copy and free modes (see [[#InterpretMode|InterpretMode]]), the classification result is presented following the sequence ([[#PostSequenceTime|PostSequenceTime]]). Presentation of the predicted stimulus is preceded with an announcement stimulus.&lt;br /&gt;
This stimulus&#039; properties are defined by the &#039;&#039;Result&#039;&#039; parameter, which is a matrix in the same format as the &#039;&#039;Stimuli&#039;&#039; and &#039;&#039;FocusOn&#039;&#039; parameters.&lt;br /&gt;
As for the &amp;quot;FocusOn&amp;quot; parameter, to control the duration of the &amp;quot;Result&amp;quot; announcement and the predicted stimulus independently of the global [[#StimulusDuration|StimulusDuration]] parameter, a &#039;&#039;StimulusDuration&#039;&#039; row may be added in the &#039;&#039;Result&#039;&#039; matrix.&lt;br /&gt;
&lt;br /&gt;
====StimulusWidth====&lt;br /&gt;
For icon stimuli, stimulus width in percent of screen width.&lt;br /&gt;
Stimulus height is deduced from the stimulus&#039; aspect ratio, which is always conserved.&lt;br /&gt;
If this parameter is zero, all stimuli will be displayed unscaled, i.e. at their original pixel size.&lt;br /&gt;
{{StimulusParamOverride}}&lt;br /&gt;
&lt;br /&gt;
====CaptionHeight====&lt;br /&gt;
For text stimuli, the height of the stimulus&#039; caption in percent of screen height.&lt;br /&gt;
{{StimulusParamOverride}}&lt;br /&gt;
&lt;br /&gt;
====CaptionColor====&lt;br /&gt;
For text stimuli, the color of the stimulus&#039; caption, given as an RGB value.&lt;br /&gt;
{{StimulusParamOverride}}&lt;br /&gt;
&lt;br /&gt;
====BackgroundColor====&lt;br /&gt;
The background color of the stimulus rectangle, given as an RGB value. The height of the rectangle is defined by the CaptionHeight parameter, and its width depends on the caption&#039;s text width.&lt;br /&gt;
&lt;br /&gt;
====CaptionSwitch====&lt;br /&gt;
A boolean parameter to globally switch presentation of stimulus captions on or off.&lt;br /&gt;
To present captions for individual stimuli only, remove captions for other stimuli from the [[#Stimuli|Stimuli]] matrix.&lt;br /&gt;
&lt;br /&gt;
====IconSwitch====&lt;br /&gt;
A boolean parameter to globally switch presentation of icon stimuli on or off.&lt;br /&gt;
To present icons for individual stimuli only, leave icon entries for other stimuli blank in the [[#Stimuli|Stimuli]] matrix.&lt;br /&gt;
&lt;br /&gt;
====AudioSwitch====&lt;br /&gt;
A boolean parameter to globally switch presentation of audio stimuli on or off.&lt;br /&gt;
To present audio for individual stimuli only, remove audio entries for other stimuli from the [[#Stimuli|Stimuli]] matrix.&lt;br /&gt;
====AVSwitch====&lt;br /&gt;
A boolean parameter to globally switch presentation of AV stimuli on or off.&lt;br /&gt;
To present audio for individual stimuli only, remove AV entries for other stimuli from the [[#Stimuli|Stimuli]] matrix.&lt;br /&gt;
&lt;br /&gt;
====AudioVolume====&lt;br /&gt;
The volume for audio playback, in percent of maximum volume.&lt;br /&gt;
{{StimulusParamOverride}}&lt;br /&gt;
&lt;br /&gt;
====AVPlayToEnd====&lt;br /&gt;
If yes, AV stimuli will be played as long as they last; if no, AV stimuli will be aborted after the specified stimulus duration has expired.&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
{{ApplicationBaseStates}}&lt;br /&gt;
&lt;br /&gt;
{{StimulusTaskStates}}&lt;br /&gt;
&lt;br /&gt;
===SelectedStimulus===&lt;br /&gt;
When classification is performed, this state contains the stimulus code of the stimulus classified as the &amp;quot;selected&amp;quot; one.&lt;br /&gt;
&lt;br /&gt;
==Timeline==&lt;br /&gt;
{{StimulusTaskTimeline}}&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:P3TemporalFilter]], [[User Reference:P3SpellerTask]], [[Programming Reference:StimulusTask Class]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Filters]][[Category:User Application]][[Category:Specification]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:StimulusPresentationTask&amp;diff=11716</id>
		<title>User Reference:StimulusPresentationTask</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:StimulusPresentationTask&amp;diff=11716"/>
		<updated>2025-01-14T21:44:02Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* FocusOn */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The main purpose of this task is to present a sequential series of auditory and/or visual stimuli to the user of the BCI system.&lt;br /&gt;
&lt;br /&gt;
The StimulusPresentationTask is suited to implement evoked response (ERP) paradigms, as well as to display tasks for selective activation experiments, such as SMR screening sessions.&lt;br /&gt;
&lt;br /&gt;
The sequence and nature of the stimuli can be defined by the investigator. In addition to stimulus delivery, the task can optionally be used in conjunction with BCI2000&#039;s P300 Signal Processing module ([[User_Reference:P3TemporalFilter|P3TemporalFilter]]) to provide feedback to a selected stimulus in either a copy or a free mode.&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
&lt;br /&gt;
===Stimulus Definition===&lt;br /&gt;
&lt;br /&gt;
Stimuli are set up through a parameter defined by the application module. This implicitly defines the total number of stimuli as well as the details of each stimulus.&lt;br /&gt;
&lt;br /&gt;
Each stimulus is defined by the following properties:&lt;br /&gt;
  &lt;br /&gt;
#Caption &lt;br /&gt;
#Icon file &lt;br /&gt;
#Audio file &lt;br /&gt;
&lt;br /&gt;
In addition to stimuli that are part of the actual stimulation sequence, the [[#FocusOn|FocusOn]] &lt;br /&gt;
and [[#Result|Result]] parameters contain definitions for a stimulus that indicates what to focus on,&lt;br /&gt;
and a stimulus that presents the result. These stimuli are only used when the task is set to copy or free mode. &lt;br /&gt;
&lt;br /&gt;
The following table contains an example definition of two stimuli:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|              ||stimulus1 ||stimulus2&lt;br /&gt;
|-&lt;br /&gt;
|caption       ||Donkey || &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|icon          ||images\donkey.bmp  ||images\elephant.bmp&lt;br /&gt;
|-&lt;br /&gt;
|audio         || sounds\snicker.wav  ||sounds\trumpet.wav&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
A blank entry for caption/icon/audio file is accepted, and defines that no presentation of the respective element takes place (e.g., see caption in stimulus2). The stimulus definition parameter does &#039;&#039;not&#039;&#039; contain a description on how the stimuli are presented.&lt;br /&gt;
For further details, see the [[#Stimuli|Stimuli]] parameter description.&lt;br /&gt;
&lt;br /&gt;
====Stimulus Codes====&lt;br /&gt;
When defining a stimulus sequence, stimuli are referred to an integer ID called &#039;&#039;stimulus code&#039;&#039;.&lt;br /&gt;
The stimulus code associated with a stimulus corresponds to the column in which that stimulus is defined in the [[#Stimuli|Stimuli]] matrix parameter.&lt;br /&gt;
&lt;br /&gt;
In the recorded data file, stimulus presentation is indicated by the [[#StimulusCode|StimulusCode]] state.&lt;br /&gt;
During presentation of a stimulus, this state is set to the associated stimulus code.&lt;br /&gt;
&lt;br /&gt;
===Stimulus Sequence===&lt;br /&gt;
&lt;br /&gt;
Stimuli are presented in a certain sequence. This sequence can either be deterministic, i.e., defined by the investigator, or pseudo-random. &lt;br /&gt;
&lt;br /&gt;
====Deterministic Sequence:====&lt;br /&gt;
&lt;br /&gt;
The investigator defines the order by &lt;br /&gt;
entering a list of stimulus IDs to be presented. As an example: &lt;br /&gt;
&lt;br /&gt;
1 5 3 4 2 &lt;br /&gt;
&lt;br /&gt;
defines a sequence in which stimulus 1 is presented first, followed by stimulus 5, etc.&lt;br /&gt;
&lt;br /&gt;
====Random Sequence:====&lt;br /&gt;
&lt;br /&gt;
The investigator defines absolute stimulus frequencies for each stimulus, with the sum &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; of those values equaling the total number of stimulus presentations in the final sequence. The resulting random sequence is obtained by applying a random permutation to an arbitrary sequence that reproduces the given frequencies, with all &amp;lt;math&amp;gt;N!&amp;lt;/math&amp;gt; index permutations being equally probable (Block Randomization).&lt;br /&gt;
&lt;br /&gt;
As an example: &lt;br /&gt;
  &lt;br /&gt;
6 2 3&lt;br /&gt;
 &lt;br /&gt;
defines a sequence of 11 stimulus presentations with stimulus 1 being presented 6 times, stimulus 2, 2 times, and stimulus 3, 3 times. The resulting sequence &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; will be a permutation of &amp;lt;math&amp;gt;S_0 = [1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3]&amp;lt;/math&amp;gt;, and the probability for &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; to equal &amp;lt;math&amp;gt;S_0&amp;lt;/math&amp;gt; will be &amp;lt;math&amp;gt;\frac{6!\times2!\times3!}{(6+2+3)!}=1/4620&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Multiple sequences can be generated from the given frequencies. The investigator can define how many sequences are generated and presented.&lt;br /&gt;
&lt;br /&gt;
====P3Speller Compatible====&lt;br /&gt;
Sequences are random, with each stimulus being presented &#039;&#039;NumberOfSequences&#039;&#039; times, in a block-randomized fashion. When in copy mode, each entry in the &#039;&#039;ToBeCopied&#039;&#039; parameter corresponds to a &#039;&#039;NumberOfSequences&#039;&#039;-times repetition of all stimulus codes. In other &#039;&#039;InterpretMode&#039;&#039;s, stimulus presentation is repeated indefinitely. This mode is intended as a compatibility mode for transitioning experiments from or to the [[User Reference:P3SpellerTask|P3SpellerTask]].&lt;br /&gt;
&lt;br /&gt;
===Stimulus Delivery===&lt;br /&gt;
&lt;br /&gt;
For any stimulus, delivery occurs simultaneously for caption, icon, and audio. &lt;br /&gt;
When both caption and icon are defined, the caption appears overlaying the icon.&lt;br /&gt;
&lt;br /&gt;
An investigator can specify:&lt;br /&gt;
  &lt;br /&gt;
*[[#WindowWidth|Size and position]] of the target window. &lt;br /&gt;
&lt;br /&gt;
*[[#StimulusWidth|Width and height]] of caption and icon in percent of screen width/height, or that the icon should appear in its original pixel size.&lt;br /&gt;
&lt;br /&gt;
*Whether captions, icons, or audio files will be presented (i.e., a [[#IconSwitch|global switch]]). There are no individual switches for each stimulus. However, individual captions/icons/wave files are not presented if they are not defined (i.e., their respective entries are blank).&lt;br /&gt;
&lt;br /&gt;
*The [[#AudioVolume|volume for audio playback]] as a percentage of maximum volume. &lt;br /&gt;
&lt;br /&gt;
*[[#BackgroundColor|Window background color]] in RGB.&amp;lt;br /&amp;gt;(For convenience, RGB values may be entered in hexadecimal notation, e.g. &amp;lt;tt&amp;gt;0xff0000&amp;lt;/tt&amp;gt; for red.) &lt;br /&gt;
&lt;br /&gt;
*[[#CaptionColor|Caption color]] in RGB.&lt;br /&gt;
 &lt;br /&gt;
*The [[#StimulusDuration|duration]] of stimulus presentation.&amp;lt;br /&amp;gt;(Playback of audio extending above the specified duration will be muted.)&lt;br /&gt;
 &lt;br /&gt;
*The duration of an [[#ISIMinDuration|inter-stimulus interval]] following stimulus presentation.&amp;lt;br /&amp;gt;(During the inter-stimulus interval, the screen is blank and audio is turned off.) &lt;br /&gt;
&lt;br /&gt;
*Variance in inter-stimulus intervals, with probability distributed uniformly over the interval between minimum and maximum inter-stimulus interval.&lt;br /&gt;
&lt;br /&gt;
*For documentation purposes, a user can enter a [[#UserComment|comment]] to the specific run in a string parameter.&lt;br /&gt;
&lt;br /&gt;
==Processing of Classification Results==&lt;br /&gt;
&lt;br /&gt;
The task can be configured to interpret results communicated to it by the [[User Reference:P3TemporalFilter|P3 Signal Processing]] module. These results represent a judgment of which of the stimuli was most likely selected. Handling of these results is identical to the [[User Reference:P3SpellerTask|P3 Spelling Task]]. &lt;br /&gt;
&lt;br /&gt;
When it transmits a classification result, Signal Processing sets the state &#039;&#039;StimulusCodeRes&#039;&#039; to the stimulus code that was originally transmitted to it by the user application. For example, when Signal Processing sets &#039;&#039;StimulusCodeRes&#039;&#039;  to 3, it transmits classification results for stimulus 3. In addition, it sets &#039;&#039;StimulusTypeRes&#039;&#039;  to reflect the type of stimulus &lt;br /&gt;
(0=non-target, 1=target) when the system is in copy mode. Signal Processing transmits the classification result as one number (i.e., the first control signal).&lt;br /&gt;
&lt;br /&gt;
===Free Mode===&lt;br /&gt;
&lt;br /&gt;
The task can be configured to operate in free mode. In this case, the sequence of stimulus deliveries is followed by a time period, in which the Signal Processing classification result is presented. The final classification result is the stimulus with the highest classification result.&lt;br /&gt;
&lt;br /&gt;
In order to present this result, the system uses the stimulus defined in the &amp;lt;tt&amp;gt;result&amp;lt;/tt&amp;gt; column of the stimuli parameter. This presentation is followed by delivery of the determined stimulus. In other words, after a sequence of stimulus deliveries, the system might play a .wav file that says: &amp;quot;the result is,&amp;quot; followed by a .wav file that says &amp;quot;yes.&amp;quot; (assuming &amp;quot;yes&amp;quot; represents&lt;br /&gt;
the stimulus that produced the highest classification result).&lt;br /&gt;
&lt;br /&gt;
Finally, the task sends this result to the operator module as an ASCII text message so that it appears in a log window.&lt;br /&gt;
&lt;br /&gt;
Free mode does not terminate until the investigator suspends operation.&lt;br /&gt;
&lt;br /&gt;
===Copy Mode===&lt;br /&gt;
&lt;br /&gt;
Copy mode is similar to free mode. In copy mode, the investigator can define a list of stimuli to be copied (e.g., &amp;quot;3 5 4&amp;quot;). In this example, the user has to attend to stimulus 3 for the first sequence, 5 for the second sequence, etc.&lt;br /&gt;
&lt;br /&gt;
In addition to presenting the result, the delivery of stimuli is preceded by a presentation that describes the stimulus to which the user must attend. This presentation uses the stimulus that is defined in the [[#FocusOn|FocusOn]] parameter. This presentation is followed by delivery of the desired target stimulus. As an example, the system might say &amp;quot;Please focus on&amp;quot; ... &amp;quot;yes,&amp;quot; before it starts with the sequence of stimulus deliveries.&lt;br /&gt;
&lt;br /&gt;
Copy mode terminates (i.e., suspends the task) when the user has finished copying all stimuli specified by the investigator.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
{{ApplicationWindowParams}}&lt;br /&gt;
{{StimulusTaskParams}}&lt;br /&gt;
&lt;br /&gt;
====SequenceType====&lt;br /&gt;
Enumerated value selecting between&lt;br /&gt;
*0 deterministic sequence mode: the sequence is explicitly defined in the &#039;&#039;Sequence&#039;&#039; parameter; &lt;br /&gt;
*1 random sequence mode: the sequence is random, with pre-defined stimulus frequencies.&lt;br /&gt;
*2 P3Speller compatible mode: the sequence is random, with each stimulus being presented exactly &#039;&#039;NumberOfSequences&#039;&#039; times, in a block-randomized fashion. In copy spelling mode, one such sequence is presented for each entry in the &#039;&#039;ToBeCopied&#039;&#039; parameter. In other &#039;&#039;InterpretMode&#039;&#039;s, such sequences are repeated indefinitely; the current run must be stopped manually.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
In deterministic mode, a list of stimulus codes defining the sequence of presentations.&lt;br /&gt;
In random mode, a list of integer stimulus frequencies.&lt;br /&gt;
In P3Speller compatible mode, this parameter is ignored.&lt;br /&gt;
&lt;br /&gt;
====NumberOfSequences====&lt;br /&gt;
The number of sequence repetitions in a run (a run corresponds to a single data file).&lt;br /&gt;
&lt;br /&gt;
====ToBeCopied====&lt;br /&gt;
A list of stimulus codes defining a sequence of attended stimuli.&lt;br /&gt;
At the beginning of each presentation sequence, another entry from this list is announced as the attended stimulus (see [[#FocusOn|FocusOn]]).&lt;br /&gt;
&lt;br /&gt;
This parameter is only used in [[#InterpretMode|copy mode]].&lt;br /&gt;
&lt;br /&gt;
====UserComment====&lt;br /&gt;
An arbitrary string intended for documentation purposes.&lt;br /&gt;
&lt;br /&gt;
====Stimuli====&lt;br /&gt;
A matrix defining the properties of stimuli to be presented.&lt;br /&gt;
Columns of the &#039;&#039;Stimuli&#039;&#039; matrix correspond to individual stimuli and their stimulus codes.&lt;br /&gt;
For each stimulus, the following properties are defined by its row entries:&lt;br /&gt;
*Caption: a text string, with its size and color depending on the &#039;&#039;CaptionHeight&#039;&#039; and &#039;&#039;CaptionColor&#039;&#039; parameters;&lt;br /&gt;
*Icon: a graphic file (a number of formats are supported through libav), with its size depending on the &#039;&#039;StimulusWidth&#039;&#039; parameter;&lt;br /&gt;
*AV: an AV file (video with or without audio, or an audio file), with playback starting at the onset of the visual stimuli.&lt;br /&gt;
For backward compatibility reasons, each of these three rows must be present.&lt;br /&gt;
A blank entry for caption/icon/AV is accepted, and defines that no presentation of the respective element takes place.&lt;br /&gt;
Note that for Windows .bmp files, the top left pixel is taken to be the transparent background color, so results may not be as expected. Try a different format, or add a 1-pixel frame in a different color to the image.&lt;br /&gt;
&lt;br /&gt;
Additionally, a number of global stimulus parameters may be overridden with specific values for individual stimuli.&lt;br /&gt;
To do this, for each parameter to be individualized, add an additional row to the Stimuli matrix. The row label indicates the parameter to be changed, and has to be one of:&lt;br /&gt;
*StimulusDuration,&lt;br /&gt;
*EarlyOffsetExpression, &lt;br /&gt;
*ISIMinDuration, ISIMaxDuration, &lt;br /&gt;
*StimulusWidth, CaptionHeight, CaptionColor, AudioVolume.&lt;br /&gt;
&lt;br /&gt;
Whenever one of these rows is present, the corresponding global parameter will be ignored.&lt;br /&gt;
&lt;br /&gt;
====FocusOn====&lt;br /&gt;
In copy mode (see [[#InterpretMode|InterpretMode]]), the attended stimulus is presented prior to the stimulus sequence ([[#PreSequenceTime|PreSequenceTime]]),&lt;br /&gt;
preceded with a special announcement stimulus.&lt;br /&gt;
This stimulus&#039; properties are defined by the &#039;&#039;FocusOn&#039;&#039; parameter, which is a matrix in the same format as the &#039;&#039;Stimuli&#039;&#039; parameter.&lt;br /&gt;
Usually, this matrix has a single column; when multiple columns are present, all stimuli are presented concurrently.&lt;br /&gt;
To control the duration of the &amp;quot;FocusOn&amp;quot; announcement and the attended stimulus independently of the global [[#StimulusDuration|StimulusDuration]] parameter, a &#039;&#039;StimulusDuration&#039;&#039; row may be added in the &#039;&#039;FocusOn&#039;&#039; matrix.&lt;br /&gt;
&lt;br /&gt;
====Result====&lt;br /&gt;
In copy and free modes (see [[#InterpretMode|InterpretMode]]), the classification result is presented following the sequence ([[#PostSequenceTime|PostSequenceTime]]). Presentation of the predicted stimulus is preceded with an announcement stimulus.&lt;br /&gt;
This stimulus&#039; properties are defined by the &#039;&#039;Result&#039;&#039; parameter, which is a matrix in the same format as the &#039;&#039;Stimuli&#039;&#039; and &#039;&#039;FocusOn&#039;&#039; parameters.&lt;br /&gt;
As for the &amp;quot;FocusOn&amp;quot; parameter, to control the duration of the &amp;quot;Result&amp;quot; announcement and the predicted stimulus independently of the global [[#StimulusDuration|StimulusDuration]] parameter, a &#039;&#039;StimulusDuration&#039;&#039; column may be present in the &#039;&#039;Result&#039;&#039; matrix.&lt;br /&gt;
&lt;br /&gt;
====StimulusWidth====&lt;br /&gt;
For icon stimuli, stimulus width in percent of screen width.&lt;br /&gt;
Stimulus height is deduced from the stimulus&#039; aspect ratio, which is always conserved.&lt;br /&gt;
If this parameter is zero, all stimuli will be displayed unscaled, i.e. at their original pixel size.&lt;br /&gt;
{{StimulusParamOverride}}&lt;br /&gt;
&lt;br /&gt;
====CaptionHeight====&lt;br /&gt;
For text stimuli, the height of the stimulus&#039; caption in percent of screen height.&lt;br /&gt;
{{StimulusParamOverride}}&lt;br /&gt;
&lt;br /&gt;
====CaptionColor====&lt;br /&gt;
For text stimuli, the color of the stimulus&#039; caption, given as an RGB value.&lt;br /&gt;
{{StimulusParamOverride}}&lt;br /&gt;
&lt;br /&gt;
====BackgroundColor====&lt;br /&gt;
The background color of the stimulus rectangle, given as an RGB value. The height of the rectangle is defined by the CaptionHeight parameter, and its width depends on the caption&#039;s text width.&lt;br /&gt;
&lt;br /&gt;
====CaptionSwitch====&lt;br /&gt;
A boolean parameter to globally switch presentation of stimulus captions on or off.&lt;br /&gt;
To present captions for individual stimuli only, remove captions for other stimuli from the [[#Stimuli|Stimuli]] matrix.&lt;br /&gt;
&lt;br /&gt;
====IconSwitch====&lt;br /&gt;
A boolean parameter to globally switch presentation of icon stimuli on or off.&lt;br /&gt;
To present icons for individual stimuli only, leave icon entries for other stimuli blank in the [[#Stimuli|Stimuli]] matrix.&lt;br /&gt;
&lt;br /&gt;
====AudioSwitch====&lt;br /&gt;
A boolean parameter to globally switch presentation of audio stimuli on or off.&lt;br /&gt;
To present audio for individual stimuli only, remove audio entries for other stimuli from the [[#Stimuli|Stimuli]] matrix.&lt;br /&gt;
====AVSwitch====&lt;br /&gt;
A boolean parameter to globally switch presentation of AV stimuli on or off.&lt;br /&gt;
To present audio for individual stimuli only, remove AV entries for other stimuli from the [[#Stimuli|Stimuli]] matrix.&lt;br /&gt;
&lt;br /&gt;
====AudioVolume====&lt;br /&gt;
The volume for audio playback, in percent of maximum volume.&lt;br /&gt;
{{StimulusParamOverride}}&lt;br /&gt;
&lt;br /&gt;
====AVPlayToEnd====&lt;br /&gt;
If yes, AV stimuli will be played as long as they last; if no, AV stimuli will be aborted after the specified stimulus duration has expired.&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
{{ApplicationBaseStates}}&lt;br /&gt;
&lt;br /&gt;
{{StimulusTaskStates}}&lt;br /&gt;
&lt;br /&gt;
===SelectedStimulus===&lt;br /&gt;
When classification is performed, this state contains the stimulus code of the stimulus classified as the &amp;quot;selected&amp;quot; one.&lt;br /&gt;
&lt;br /&gt;
==Timeline==&lt;br /&gt;
{{StimulusTaskTimeline}}&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:P3TemporalFilter]], [[User Reference:P3SpellerTask]], [[Programming Reference:StimulusTask Class]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Filters]][[Category:User Application]][[Category:Specification]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:NatusADC&amp;diff=11672</id>
		<title>Contributions:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:NatusADC&amp;diff=11672"/>
		<updated>2024-11-25T23:51:30Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* On the Natus Computer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:NatusClinicalSystem.webp|thumb|400px|Example set-up for a Natus NeuroWorks clinical system]]&lt;br /&gt;
&lt;br /&gt;
== Function  ==&lt;br /&gt;
The NatusADC filter acquires raw data in real-time from Natus Headboxes over UDP connection for signal processing and visualizations. The overview of the NatusADC working is shown in the image below.&lt;br /&gt;
[[File:Prog_Ref_NatusADC_NatusWorking.png|center|800px|Overview of NatusADC working]]&lt;br /&gt;
&lt;br /&gt;
NatusDataServer processes and sends signal from the device to the client application. A project named XLDataExportClient reads signals from the device and calls the NatusDataServer&#039;s functions to send the signal to the client. NatusClient is the client application within the BCI2000 that receives the signals and does the initial processing. NatusPackageInterface contains the implementation of data transfer protocol between server/device and client and is used by NatusClient and NatusDataServer to communicate with each other over TCP and UDP. NatusDataServer and NatusPackageInterface are independent of BCI2000, whereas NatusClient relies on BCI2000. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The below image explains the context in which packet, blocks, samples and channels are used in this project. A packet may have one or block, a block may have one or more samples and a sample contains values for all the channels.&lt;br /&gt;
[[File:NatusPacketImage.png|center|600px|Packet, block and samples relationship]]  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;For more information about the Natus connection and specific commands, refer to the [[Programming Reference:NatusADC|Natus programming page]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: 5900&lt;br /&gt;
*Tested under: 7381&lt;br /&gt;
*Known to compile under:7381&lt;br /&gt;
*Broken since: --&lt;br /&gt;
*Natus software version: 9.2.1 Build 6524&lt;br /&gt;
*Natus Data Export Version: 9.4&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
* The NatusADC source module requires a proprietary SDK protected by an NDA with Natus. Please contact Natus for this NDA and for access to the XLDataExportClient SDK before attempting to use the NatusADC source module.&lt;br /&gt;
* It is also helpful to have an ethernet port available for the Natus computer. If your system does not have an ethernet port, consider using a USB ethernet dongle.&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
In theory, the module should work fine with all of the following Natus Headboxes. &lt;br /&gt;
# EEG32&lt;br /&gt;
# EEG128, EEG128FS&lt;br /&gt;
# Mobee32, Mobee32-02&lt;br /&gt;
# Mobee-24&lt;br /&gt;
# Connex/ Brain Monitor&lt;br /&gt;
# Trex&lt;br /&gt;
# EMU40&lt;br /&gt;
# EEG32u&lt;br /&gt;
# Quantum&lt;br /&gt;
# NeuroLink IP&lt;br /&gt;
# Bio-logic NetLink&lt;br /&gt;
# Bio-logic Traveler&lt;br /&gt;
&lt;br /&gt;
==== Drivers ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Connecting Natus to BCI2000 ==&lt;br /&gt;
The figure below should serve as a supplement to the instructions for connecting the Natus computer to the BCI2000 computer&lt;br /&gt;
[[File:NW_SDK_for_BCI2000.png|center|1000px|Neuroworks SDK for BCI2000]]&lt;br /&gt;
&lt;br /&gt;
=== On the Natus Computer ===&lt;br /&gt;
# Connect the BCI2000 computer to the Natus computer via ethernet (this may require a usb-to-ethernet adapter)&lt;br /&gt;
# Change the IP address of this port on the Natus computer to something on its own subnet, like 192.168.10.10. ***This must be a static IP address.*** You can follow a tutorial like [https://nordvpn.com/blog/how-to-change-your-ip-address/ this one] to change the IP address. The easiest way to confirm that you are changing the IP address of the correct port is to unplug the ethernet cable. The unplugged option will disappear.&lt;br /&gt;
# When starting a new study, set the sampling rate of the acquisition system by opening &amp;quot;Wave&amp;quot; and going to edit -&amp;gt; settings -&amp;gt; acquisition while a study is NOT running&lt;br /&gt;
#* Be sure that the Natus computer is set to acquire data over Ethernet and not USB if you intend to acquire data over 4kHz [[File:Natus1_StudySettings.jpg|center|600px|Set Natus Sampling Rate]]&lt;br /&gt;
# Start an EEG study in Neuroworks using the New EEG button. [[File:Natus2_StartStudy.jpg|center|1000px|Start a new Natus study]] You will need to enter the study information. [[File:Natus3_StudyInformation.jpg|center|600px|Enter the study information]] Note that you do not need to start the recording for the signal to stream to BCI2000. [[File:Natus4_StudyRunning.jpg|center|1000px|Study is running]]&lt;br /&gt;
&lt;br /&gt;
=== On the BCI2000 Computer ===&lt;br /&gt;
# Compile the NatusSignalSource source module after you have gotten access to the Natus data export service on the BCI2000 svn&lt;br /&gt;
# Change the IP address of the BCI2000 computer ethernet port to something on the same subnet, like 192.168.10.9, following the same steps as above.&lt;br /&gt;
# Open the command line on the BCI2000 computer and type &amp;quot;ping 192.168.10.10&amp;quot; to ensure you have a connection.&lt;br /&gt;
#* Note that if this does not work you may need to turn off firewalls on one or both machines&lt;br /&gt;
# Locate the included registry editing tool found in bci2000/src/private/SignalSource/NatusSignalSource/&lt;br /&gt;
# Edit the _SetSdkAcquisitionStationIp.reg registry editing tool (right-click, edit) to add the IP of the Natus computer to the BCI2000 computer&#039;s registry (i.e., 192.168.10.10)&lt;br /&gt;
# Run RegXLDataExportService.bat found in bci2000/src/private/SignalSource/NatusSignalSource/DataExport_9.4/XLDataExportService to register the DLL of the data export service. (This may not be necessary with the newest version?)&lt;br /&gt;
# Start the data export service executable XLDataExportSrv.exe found in bci2000/src/private/SignalSource/NatusSignalSource/DataExport_9.4/XLDataExportService&lt;br /&gt;
#* Note that this can be started before an EEG study has been started, or after an EEG study is already running&lt;br /&gt;
#* A small horizontal window should appear, indicating study data is streaming&lt;br /&gt;
# Create a BCI2000 batch file to start up the NatusSignalSource source module (An example batch file should be in the same NatusSignalSource folder after BCI2000 has been compiled)&lt;br /&gt;
# Launch BCI2000 using this batch file&lt;br /&gt;
# Open the config window and navigate to the source tab. Source parameters will vary according to your needs, but some recommended settings can be found below&lt;br /&gt;
#* SampleBlockSize: 100 (at a sampling rate of 2048, this yields a sample block size of 48.83ms. Note that the ratio of SampleBlockSize/ServerBlockSize needs to be a whole number for best performance. SampleBlockSize less than 48.83ms is not recommended.)&lt;br /&gt;
#* SamplingRate: auto (inherited from the Natus system)&lt;br /&gt;
#* ServerBlockSize: 1 (server buffer size. Larger ServerBlockSize can lead to performance issues.)&lt;br /&gt;
#* DecimationFactor: 1 (you can decimate the incoming sampled data by the DecimationFactor. The BCI2000 sampling rate will reflect the decimated rate.)&lt;br /&gt;
#* ServerIP: Set the IP address to localhost or 127.0.0.1&lt;br /&gt;
# Press “Set Config.” Data should begin streaming. Open the System Log from the BCI2000 Operator window to confirm that the sampling rate and channel count were inherited correctly from the Natus stream&lt;br /&gt;
&lt;br /&gt;
== Legacy Instructions for Connecting Natus to BCI2000 ==&lt;br /&gt;
=== On the Natus Computer ===&lt;br /&gt;
# If you have previously registered the XLDataExportClient.dll for an older version of the data export tool, you must first deregister this dll. Launch a command window as an administrator and type regsvr /u XLDataExportClient.dll&lt;br /&gt;
# Connect to the network via ethernet cable. Alternately, it is preferable to connect directly to the BCI2000 computer via ethernet.&lt;br /&gt;
# Copy the Export Service folder found in src\private\SignalSource\NatusSignalSource\DataExport_9.4\XLDataExportService to the hard drive of the computer running Natus Neuroworks or to a USB drive&lt;br /&gt;
# Note the IP address of the Natus computer (run “ipconfig” in the Command Prompt on the Natus computer). If the computers are directly connected with an ethernet cable, the IP address should be under &amp;quot;ethernet adapter ethernet&amp;quot; [[File:Natus7_IPaddress.jpg|center|600px|Run ipconfig on the Natus computer and note the IP address]]&lt;br /&gt;
# When starting a new study, set the sampling rate of the acquisition system by opening &amp;quot;Wave&amp;quot; and going to edit -&amp;gt; settings -&amp;gt; acquisition while a study is NOT running&lt;br /&gt;
#* Be sure that the Natus computer is set to acquire data over Ethernet and not USB if you intend to acquire data over 4kHz [[File:Natus1_StudySettings.jpg|center|600px|Set Natus Sampling Rate]]&lt;br /&gt;
# Start an EEG study in Neuroworks using the New EEG button. [[File:Natus2_StartStudy.jpg|center|1000px|Start a new Natus study]] You will need to enter the study information. [[File:Natus3_StudyInformation.jpg|center|600px|Enter the study information]] Note that you do not need to start the recording for the signal to stream to BCI2000. [[File:Natus4_StudyRunning.jpg|center|1000px|Study is running]]&lt;br /&gt;
# Run the executable XLDataExportSrv.exe found in the XLDataExportService folder that was copied to the Natus computer [[File:Natus5_DataExportServiceFolder.jpg|center|600px|Run the executable XLDataExportSrv.exe from the XLDataExportService folder]]&lt;br /&gt;
#* Note that this can be started before an EEG study has been started, or after an EEG study is already running&lt;br /&gt;
#* A small horizontal window should appear, indicating study data is streaming [[File:Natus6_DataExportServiceRunning.jpg|center|1000px|Natus Data Export Service Running]]&lt;br /&gt;
&lt;br /&gt;
=== On the BCI2000 Computer ===&lt;br /&gt;
# Connect to the same network that the Natus computer is connected via ethernet cable. Alternately, it is preferable to connect directly to the Natus computer via ethernet.&lt;br /&gt;
# Run a BCI2000 batch file that loads the NatusSignalSource&lt;br /&gt;
# Open the config window and navigate to the source tab. Source parameters will vary according to your needs, but some recommended settings can be found below&lt;br /&gt;
#* SampleBlockSize: 100 (at a sampling rate of 2048, this yields a sample block size of 48.83ms. Note that the ratio of SampleBlockSize/ServerBlockSize needs to be a whole number for best performance. SampleBlockSize less than 48.83ms is not recommended.)&lt;br /&gt;
#* SamplingRate: auto (inherited from the Natus system)&lt;br /&gt;
#* ServerBlockSize: 1 (server buffer size. Larger ServerBlockSize can lead to performance issues.)&lt;br /&gt;
#* DecimationFactor: 1 (you can decimate the incoming sampled data by the DecimationFactor. The BCI2000 sampling rate will reflect the decimated rate.)&lt;br /&gt;
#* ServerIP: Set the IP address to that of the Natus computer [[File:Natus8_BCI2000Parameters.jpg|center|600px|Natus BCI2000 parameters]]&lt;br /&gt;
# Press “Set Config.” Data should begin streaming. Open the System Log from the BCI2000 Operator window to confirm that the sampling rate and channel count were inherited correctly from the Natus stream&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
Parameters common to all source modules are described under [[User Reference:DataIOFilter]]. In addition, the following parameters are supported:&lt;br /&gt;
&lt;br /&gt;
=== SamplingRate ===&lt;br /&gt;
The rate at which the device samples the data. The default value is the device&#039;s default sampling rate. &lt;br /&gt;
&lt;br /&gt;
=== SampleBlockSize ===&lt;br /&gt;
The number of samples per block the output signal, created by the client application(NatusADC), should have. The default value is 20. Note that the ratio of SampleBlockSize/ServerBlockSize needs to be a whole number for best performance. SampleBlockSize less than 48.83ms is not recommended.&lt;br /&gt;
&lt;br /&gt;
=== ServerBlockSize ===&lt;br /&gt;
The number of samples sent by the server/device in a single UDP Packet. The default value is 1.&lt;br /&gt;
&lt;br /&gt;
=== DecimationFactor ===&lt;br /&gt;
The decimation factor. The factor by which to decimate/downsize the signal. The default value is 1. &#039;&#039;The SamplingRate is updated by dividing it by the DecimationFactor.&#039;&#039; &lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The SamplingRate should be an integral multiple of DecimationFactor.&lt;br /&gt;
&lt;br /&gt;
=== ServerIP ===&lt;br /&gt;
The IPv4 address of the server/device.&lt;br /&gt;
&lt;br /&gt;
=== Port ===&lt;br /&gt;
The port number of the server/device which on which TCP runs. UDP port number is assumed to be 1 + TCP port number.&lt;br /&gt;
&lt;br /&gt;
=== SourceCh ===&lt;br /&gt;
The number of channels to be acquired from the device. If this is set to auto, all the available channels from the device will be acquired.&lt;br /&gt;
&lt;br /&gt;
=== SourceChGain ===&lt;br /&gt;
SourceChGain should be left to auto. The default value is 0  for every channel.&lt;br /&gt;
&lt;br /&gt;
=== SourceChOffset ===&lt;br /&gt;
SourceChOffset should be left to auto. The default value is 1 microVolt for every channel.&lt;br /&gt;
&lt;br /&gt;
=== SourceChList ===&lt;br /&gt;
The list of channel numbers to be acquired from the device. The order of the numbers doesn&#039;t matter, i.e., &#039;1 2 3 4&#039; is same as &#039;3 2 4 1&#039;. Entering duplicate channels, eg. in &#039;1 2 3 2&#039; will result in an error. Entering an invalid channel number, i.e., a number greater than the maximum number of the channels will result in an error. If set to auto, all the device channels will be streamed.&lt;br /&gt;
&lt;br /&gt;
=== ChannelNames ===&lt;br /&gt;
The user-preferred channel names. If set to auto,  the channel names will be retrieved from the device. If the device doesn&#039;t have any specific channel names, the channel names will be set to 0 to SourceCh - 1. If set manually, names should be given for each channel in SourceChList&lt;br /&gt;
&lt;br /&gt;
== States ==&lt;br /&gt;
&lt;br /&gt;
=== Interpolated ===&lt;br /&gt;
Interpolated is represented by 1 bit. The device sends data in packets over UDP connection which is not a reliable connection and hence may result in loss of some packets. The lost packets between two packets received from the device are linearly interpolated from the aforementioned two packets.  The Interpolated state value is 1 if the packet is interpolated or 0 if the packet is received from the device.&lt;br /&gt;
&lt;br /&gt;
== Events ==&lt;br /&gt;
&lt;br /&gt;
=== NatusPackageCount ===&lt;br /&gt;
This event variable will be increased by 1 whenever a UDP packet is received by the signal source. Thus, longer periods of missing packets may be detected by observing the time course of the &amp;lt;tt&amp;gt;NatusPackageCount&amp;lt;/tt&amp;gt; event.&lt;br /&gt;
&lt;br /&gt;
== Additional Info ==&lt;br /&gt;
The module also contains a function called GetDecimationFactor to query the current Decimation Factor from the server/device. &amp;lt;br/&amp;gt;&lt;br /&gt;
More details from a programmer&#039;s perspective can be found here [[Programming_Reference:NatusADC]]&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a problem streaming the data, try force quitting the Natus export service by opening the task manager on the Natus computer, then right clicking on the XLDataExportSrv and choosing &#039;end task.&#039; Then start the data export service again.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[[User Reference:DataIOFilter]], [[Programming Reference:GenericADC Class]]&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11650</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11650"/>
		<updated>2024-10-23T19:36:07Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ __NOEDITSECTION__&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; class=&amp;quot;noprint&amp;quot; style=&amp;quot;float:right; margin-top:-2em;margin-bottom:-2.4em; text-align:right&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;border-radius: 4px; background-color:#efefef;padding: 0.4em 1em 0.4em 1em;word-spacing:1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;form&amp;quot; name=&amp;quot;sitesearch&amp;quot; action=&amp;quot;https://www.google.com/search&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; name=&amp;quot;q&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;40&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;submit&amp;quot; value=&amp;quot;Google site search of bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;sitesearch&amp;quot; value=&amp;quot;bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;ie&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;oe&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/htmltag&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:-10px; margin-right:10px; background-color:#ededed; padding:0 1em 1em 1em; align:right; border-radius: 10px; vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;Download BCI2000&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;1. [https://www.bci2000.org/useradmin/ Create a free user account!!] (Required to download BCI2000)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;2. Download the [https://bci2000.org/downloads/bin/BCI2000Setup.exe latest release], or download the source code ([[Programming Howto:Building and Customizing BCI2000 |Windows]], [[Programming Howto:Non:Building and Customizing BCI2000 on Non-Windows Platforms |Non-windows]])&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt; &lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; &amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;What is BCI2000?&amp;lt;/b&amp;gt;=&lt;br /&gt;
BCI2000 is an open-source, general-purpose software system for brain-computer interface (BCI) research that is free for non-commercial use.&lt;br /&gt;
BCI2000 includes software tools that can acquire and process data, present stimuli and feedback, and manage interaction with outside devices such as robotic arms. BCI2000 is a real-time system that can synchronize EEG and other signals with a wide variety of biosignals and input devices such as mice or eye-trackers. It has several modules to manage data importing and exporting in common file formats. BCI2000 operates on most Windows systems, and the source code can be compiled on most Windows machines. &lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000 New Schematic Extra Large.gif|center|800px|BCI2000 Schematic]]&lt;br /&gt;
&lt;br /&gt;
Above shows the main framework of BCI2000, with examples for each section. Navigate to the [[User Reference:Filters|Filters page]] to learn more about the framework, or view links below for tutorials and more reference pages.&lt;br /&gt;
&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Users==&lt;br /&gt;
&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* [[DownloadBCI2000|Download BCI2000]]&lt;br /&gt;
* Take the introductory [[User Tutorial:BCI2000 Tour|BCI2000 Tour]]&lt;br /&gt;
* Learn more through an &amp;lt;br /&amp;gt; [[Introduction_to_Adaptive_Neurotechnologies|Introduction to Adaptive Neurotechnologies]]&lt;br /&gt;
* Review the terminology in the [[BCI2000 Glossary]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Developers==&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* Download [[BCI2000 Binaries]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for windows using&amp;lt;br /&amp;gt; [[Programming_Howto:Building and Customizing BCI2000|Building and Customizing Howto]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for non-windows platforms using&amp;lt;br /&amp;gt;[[ Programming_Howto:Non:Building_and_Customizing_BCI2000_on_Non-Windows_Platforms|Building and Customizing Howto for Non-Windows]]&lt;br /&gt;
* Access to the [[Programming Howto:Building and Customizing BCI2000|BCI2000 Source Code]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px;  background-color:#e3f5fc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 References==&lt;br /&gt;
===BCI2000 Overview and Tools===&lt;br /&gt;
* The [[User Reference:Contents|User Reference Manual]] describes all details&amp;lt;br /&amp;gt;of system configuration and usage&lt;br /&gt;
===Technical References===&lt;br /&gt;
* The [[Technical Reference:Contents|Technical Reference Manual]] contains a discussion of its &amp;lt;br /&amp;gt;basic concepts, and a detailed specification of the BCI2000 standard.&lt;br /&gt;
===Programming References===&lt;br /&gt;
* The [[Programming Reference:Contents|Programming Reference]] provides background information &amp;lt;br /&amp;gt;which you need in order to understand, modify, or create code that &amp;lt;br /&amp;gt;depends on the BCI2000 framework.&lt;br /&gt;
===Contributions===&lt;br /&gt;
* [[Contributions:Contents|User-Contributed BCI2000 Components and Patches]]&lt;br /&gt;
===Categories===&lt;br /&gt;
*[[:Category:Data Acquisition | Data Acquisition]]&lt;br /&gt;
*[[:Category:Signal Processing | Signal Processing]]&lt;br /&gt;
*[[:Category:User Application | User Application]]&lt;br /&gt;
*[[:Category:External Interfaces | External Interfaces]]&lt;br /&gt;
*[[:Category:User Interface | User Interface]]&lt;br /&gt;
*[[:Category:Video | Video Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; background-color:#fff8dc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Tutorials==&lt;br /&gt;
===Setup Tutorials===&lt;br /&gt;
*[[Programming Howto:Install Prerequisites|Install Prerequisites]]&lt;br /&gt;
*[[Programming Howto:Register with BCI2000 Project|Register with the BCI2000 Project]]&lt;br /&gt;
*[[Programming Howto:Download the BCI2000 Sourcecode|Download the BCI2000 Sourcecode]]&lt;br /&gt;
*[[Programming Howto:Configure BCI2000 for Compilation|Configure BCI2000 for Compilation]]&lt;br /&gt;
*[[Programming Howto:Compile BCI2000|Compile BCI2000]]&lt;br /&gt;
===Experimental Tutorials===&lt;br /&gt;
*[[User Tutorial:Mu Rhythm BCI Tutorial|Mu Rhythm BCI Tutorial]]&lt;br /&gt;
*[[User Tutorial:P300 BCI Tutorial|P300 BCI Tutorial]]&lt;br /&gt;
===Programming Tutorials===&lt;br /&gt;
*[[Programming Tutorial:Implementing a Source Module|Implementing a Source Module]]&lt;br /&gt;
*[[Programming Howto:Create a custom Signal Processing Module|Implementing a Signal Processing Module]]&lt;br /&gt;
*[[Programming Tutorial:Implementing a Matlab-based Filter|Implementing a Matlab-based Filter]]&lt;br /&gt;
*[[Programming Tutorial:Implementing an Input Logger|Implementing an Input Logger]]&lt;br /&gt;
===Data Analysis Tutorials===&lt;br /&gt;
*[[User Tutorial:Data Analysis|Data Analysis with BCI2000]]&lt;br /&gt;
* Converting and Analyzing BCI2000 Data with  [[User Reference:Matlab MEX Files|Matlab MEX Files]]&lt;br /&gt;
* Analyze BCI2000 Data in Python with [https://github.com/neurotechcenter/BCI2kReader BCI2k Reader]&lt;br /&gt;
===All Tutorials: See a complete list of [[User Tutorial|BCI2000 tutorials]] here===&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==Supported Frameworks==&lt;br /&gt;
===BCI2000 Core Frameworks===&lt;br /&gt;
* [[User Reference:P3SpellerTask|P3 Speller]]&lt;br /&gt;
* [[User Reference:StimulusPresentationTask|Stimulus Presentation]] &lt;br /&gt;
* [[User Reference:CursorTask|Cursor Task]]&lt;br /&gt;
===[[Supported Frameworks|External Frameworks]]===&lt;br /&gt;
* [[User Tutorial:BCI2000Remote|BCI2000 Remote]] - includes Matlab, C++, and Python &lt;br /&gt;
* [[PsychoPy]]&lt;br /&gt;
* [[BCPy2000]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Additional Information==&lt;br /&gt;
* [[System Features|Features supported by BCI2000]]&lt;br /&gt;
* [https://github.com/neurotechcenter NCAN Github]&lt;br /&gt;
* [//{{SERVERNAME}}/phpbb BCI2000 Community Forum]&lt;br /&gt;
* [//{{SERVERNAME}}/tracproj/newticket Submit a Bug Report]  (make sure you log in)&lt;br /&gt;
* [[User FAQ|BCI2000 Frequently Asked Questions]]&lt;br /&gt;
* [[BCI2000 Glossary]]&amp;lt;br /&amp;gt;of terms specific to BCI2000&lt;br /&gt;
* [[BCI2000 Licensing|Licensing Information]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; background-color:white; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Publications==&lt;br /&gt;
* [https://{{SERVERNAME}}/downloads/doc/paper.pdf G. Schalk, D.J. McFarland, T. Hinterberger, N. Birbaumer, and J.R. Wolpaw: &#039;&#039;BCI2000: A General-Purpose Brain-Computer Interface (BCI) System&#039;&#039;, IEEE Trans Biomed Eng, 51(6), June 2004.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &#039;&#039;BCI2000: A General-Purpose Software Platform for BCI Research,&#039;&#039; In: G. Dornhege, J. del R. Millán, T. Hinterberger, D.J. McFarland, K.-R. Müller (eds.), &#039;&#039;Toward Brain-Computer Interfacing,&#039;&#039; MIT Press, 2007.&lt;br /&gt;
* [http://www.amazon.com/Practical-Guide-BrainComputer-Interfacing-BCI2000/dp/1849960917/ G. Schalk, J. Mellinger: &amp;quot;A Practical Guide to Brain-Computer Interfacing with BCI2000&amp;quot;, Springer, 2010.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &amp;quot;Using BCI2000 in BCI Research,&amp;quot; In: B. Graimann, B. Allison, G. Pfurtscheller (eds.), &amp;quot;Brain-Computer Interfaces: Revolutionizing Human-Computer Interaction&amp;quot;, Springer, 2010.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11649</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11649"/>
		<updated>2024-10-23T19:03:44Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ __NOEDITSECTION__&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; class=&amp;quot;noprint&amp;quot; style=&amp;quot;float:right; margin-top:-2em;margin-bottom:-2.4em; text-align:right&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;border-radius: 4px; background-color:#efefef;padding: 0.4em 1em 0.4em 1em;word-spacing:1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;form&amp;quot; name=&amp;quot;sitesearch&amp;quot; action=&amp;quot;https://www.google.com/search&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; name=&amp;quot;q&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;40&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;submit&amp;quot; value=&amp;quot;Google site search of bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;sitesearch&amp;quot; value=&amp;quot;bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;ie&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;oe&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/htmltag&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:-10px; margin-right:10px; background-color:#ededed; padding:0 1em 1em 1em; align:right; border-radius: 10px; vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;Download BCI2000&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;1. [https://www.bci2000.org/useradmin/ Create a free user account!!] (Required to download BCI2000)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;2. Download the [https://bci2000.org/downloads/bin/BCI2000Setup.exe latest release], or download the source code ([[Programming Howto:Building and Customizing BCI2000 |Windows]], [[Programming Howto:Non:Building and Customizing BCI2000 on Non-Windows Platforms |Non-windows]])&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt; &lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; &amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;What is BCI2000?&amp;lt;/b&amp;gt;=&lt;br /&gt;
BCI2000 is an open-source, general-purpose software system for brain-computer interface (BCI) research that is free for non-commercial use.&lt;br /&gt;
BCI2000 includes software tools that can acquire and process data, present stimuli and feedback, and manage interaction with outside devices such as robotic arms. BCI2000 is a real-time system that can synchronize EEG and other signals with a wide variety of biosignals and input devices such as mice or eye-trackers. It has several modules to manage data importing and exporting in common file formats. BCI2000 operates on most Windows systems, and the source code can be compiled on most Windows machines. &lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000 New Schematic Extra Large.gif|center|BCI2000 Schematic]]&lt;br /&gt;
&lt;br /&gt;
Above shows the main framework of BCI2000, with examples for each section. Navigate to the [[User Reference:Filters|Filters page]] to learn more about the framework, or view links below for tutorials and more reference pages.&lt;br /&gt;
&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Users==&lt;br /&gt;
&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* [[DownloadBCI2000|Download BCI2000]]&lt;br /&gt;
* Take the introductory [[User Tutorial:BCI2000 Tour|BCI2000 Tour]]&lt;br /&gt;
* Learn more through an &amp;lt;br /&amp;gt; [[Introduction_to_Adaptive_Neurotechnologies|Introduction to Adaptive Neurotechnologies]]&lt;br /&gt;
* Review the terminology in the [[BCI2000 Glossary]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Developers==&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* Download [[BCI2000 Binaries]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for windows using&amp;lt;br /&amp;gt; [[Programming_Howto:Building and Customizing BCI2000|Building and Customizing Howto]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for non-windows platforms using&amp;lt;br /&amp;gt;[[ Programming_Howto:Non:Building_and_Customizing_BCI2000_on_Non-Windows_Platforms|Building and Customizing Howto for Non-Windows]]&lt;br /&gt;
* Access to the [[Programming Howto:Building and Customizing BCI2000|BCI2000 Source Code]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px;  background-color:#e3f5fc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 References==&lt;br /&gt;
===BCI2000 Overview and Tools===&lt;br /&gt;
* The [[User Reference:Contents|User Reference Manual]] describes all details&amp;lt;br /&amp;gt;of system configuration and usage&lt;br /&gt;
===Technical References===&lt;br /&gt;
* The [[Technical Reference:Contents|Technical Reference Manual]] contains a discussion of its &amp;lt;br /&amp;gt;basic concepts, and a detailed specification of the BCI2000 standard.&lt;br /&gt;
===Programming References===&lt;br /&gt;
* The [[Programming Reference:Contents|Programming Reference]] provides background information &amp;lt;br /&amp;gt;which you need in order to understand, modify, or create code that &amp;lt;br /&amp;gt;depends on the BCI2000 framework.&lt;br /&gt;
===Contributions===&lt;br /&gt;
* [[Contributions:Contents|User-Contributed BCI2000 Components and Patches]]&lt;br /&gt;
===Categories===&lt;br /&gt;
*[[:Category:Data Acquisition | Data Acquisition]]&lt;br /&gt;
*[[:Category:Signal Processing | Signal Processing]]&lt;br /&gt;
*[[:Category:User Application | User Application]]&lt;br /&gt;
*[[:Category:External Interfaces | External Interfaces]]&lt;br /&gt;
*[[:Category:User Interface | User Interface]]&lt;br /&gt;
*[[:Category:Video | Video Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; background-color:#fff8dc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Tutorials==&lt;br /&gt;
===Setup Tutorials===&lt;br /&gt;
*[[Programming Howto:Install Prerequisites|Install Prerequisites]]&lt;br /&gt;
*[[Programming Howto:Register with BCI2000 Project|Register with the BCI2000 Project]]&lt;br /&gt;
*[[Programming Howto:Download the BCI2000 Sourcecode|Download the BCI2000 Sourcecode]]&lt;br /&gt;
*[[Programming Howto:Configure BCI2000 for Compilation|Configure BCI2000 for Compilation]]&lt;br /&gt;
*[[Programming Howto:Compile BCI2000|Compile BCI2000]]&lt;br /&gt;
===Experimental Tutorials===&lt;br /&gt;
*[[User Tutorial:Mu Rhythm BCI Tutorial|Mu Rhythm BCI Tutorial]]&lt;br /&gt;
*[[User Tutorial:P300 BCI Tutorial|P300 BCI Tutorial]]&lt;br /&gt;
===Programming Tutorials===&lt;br /&gt;
*[[Programming Tutorial:Implementing a Source Module|Implementing a Source Module]]&lt;br /&gt;
*[[Programming Howto:Create a custom Signal Processing Module|Implementing a Signal Processing Module]]&lt;br /&gt;
*[[Programming Tutorial:Implementing a Matlab-based Filter|Implementing a Matlab-based Filter]]&lt;br /&gt;
*[[Programming Tutorial:Implementing an Input Logger|Implementing an Input Logger]]&lt;br /&gt;
===Data Analysis Tutorials===&lt;br /&gt;
*[[User Tutorial:Data Analysis|Data Analysis with BCI2000]]&lt;br /&gt;
* Converting and Analyzing BCI2000 Data with  [[User Reference:Matlab MEX Files|Matlab MEX Files]]&lt;br /&gt;
* Analyze BCI2000 Data in Python with [https://github.com/neurotechcenter/BCI2kReader BCI2k Reader]&lt;br /&gt;
===All Tutorials: See a complete list of [[User Tutorial|BCI2000 tutorials]] here===&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==Supported Frameworks==&lt;br /&gt;
===BCI2000 Core Frameworks===&lt;br /&gt;
* [[User Reference:P3SpellerTask|P3 Speller]]&lt;br /&gt;
* [[User Reference:StimulusPresentationTask|Stimulus Presentation]] &lt;br /&gt;
* [[User Reference:CursorTask|Cursor Task]]&lt;br /&gt;
===[[Supported Frameworks|External Frameworks]]===&lt;br /&gt;
* [[User Tutorial:BCI2000Remote|BCI2000 Remote]] - includes Matlab, C++, and Python &lt;br /&gt;
* [[PsychoPy]]&lt;br /&gt;
* [[BCPy2000]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Additional Information==&lt;br /&gt;
* [[System Features|Features supported by BCI2000]]&lt;br /&gt;
* [https://github.com/neurotechcenter NCAN Github]&lt;br /&gt;
* [//{{SERVERNAME}}/phpbb BCI2000 Community Forum]&lt;br /&gt;
* [//{{SERVERNAME}}/tracproj/newticket Submit a Bug Report]  (make sure you log in)&lt;br /&gt;
* [[User FAQ|BCI2000 Frequently Asked Questions]]&lt;br /&gt;
* [[BCI2000 Glossary]]&amp;lt;br /&amp;gt;of terms specific to BCI2000&lt;br /&gt;
* [[BCI2000 Licensing|Licensing Information]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; background-color:white; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Publications==&lt;br /&gt;
* [https://{{SERVERNAME}}/downloads/doc/paper.pdf G. Schalk, D.J. McFarland, T. Hinterberger, N. Birbaumer, and J.R. Wolpaw: &#039;&#039;BCI2000: A General-Purpose Brain-Computer Interface (BCI) System&#039;&#039;, IEEE Trans Biomed Eng, 51(6), June 2004.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &#039;&#039;BCI2000: A General-Purpose Software Platform for BCI Research,&#039;&#039; In: G. Dornhege, J. del R. Millán, T. Hinterberger, D.J. McFarland, K.-R. Müller (eds.), &#039;&#039;Toward Brain-Computer Interfacing,&#039;&#039; MIT Press, 2007.&lt;br /&gt;
* [http://www.amazon.com/Practical-Guide-BrainComputer-Interfacing-BCI2000/dp/1849960917/ G. Schalk, J. Mellinger: &amp;quot;A Practical Guide to Brain-Computer Interfacing with BCI2000&amp;quot;, Springer, 2010.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &amp;quot;Using BCI2000 in BCI Research,&amp;quot; In: B. Graimann, B. Allison, G. Pfurtscheller (eds.), &amp;quot;Brain-Computer Interfaces: Revolutionizing Human-Computer Interaction&amp;quot;, Springer, 2010.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11648</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11648"/>
		<updated>2024-10-23T19:03:28Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ __NOEDITSECTION__&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; class=&amp;quot;noprint&amp;quot; style=&amp;quot;float:right; margin-top:-2em;margin-bottom:-2.4em; text-align:right&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;border-radius: 4px; background-color:#efefef;padding: 0.4em 1em 0.4em 1em;word-spacing:1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;form&amp;quot; name=&amp;quot;sitesearch&amp;quot; action=&amp;quot;https://www.google.com/search&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; name=&amp;quot;q&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;40&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;submit&amp;quot; value=&amp;quot;Google site search of bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;sitesearch&amp;quot; value=&amp;quot;bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;ie&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;oe&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/htmltag&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:-10px; margin-right:10px; background-color:#ededed; padding:0 1em 1em 1em; align:right; border-radius: 10px; vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;Download BCI2000&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;1. [https://www.bci2000.org/useradmin/ Create a free user account!!] (Required to download BCI2000)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;2. Download the [https://bci2000.org/downloads/bin/BCI2000Setup.exe latest release], or download the source code ([[Programming Howto:Building and Customizing BCI2000 |Windows]], [[Programming Howto:Non:Building and Customizing BCI2000 on Non-Windows Platforms |Non-windows]])&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt; &lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; &amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;What is BCI2000?&amp;lt;/b&amp;gt;=&lt;br /&gt;
BCI2000 is an open-source, general-purpose software system for brain-computer interface (BCI) research that is free for non-commercial use.&lt;br /&gt;
BCI2000 includes software tools that can acquire and process data, present stimuli and feedback, and manage interaction with outside devices such as robotic arms. BCI2000 is a real-time system that can synchronize EEG and other signals with a wide variety of biosignals and input devices such as mice or eye-trackers. It has several modules to manage data importing and exporting in common file formats. BCI2000 operates on most Windows systems, and the source code can be compiled on most Windows machines. &lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000 New Schematic Extra Large.gif|center|800px|BCI2000 Schematic]]&lt;br /&gt;
&lt;br /&gt;
Above shows the main framework of BCI2000, with examples for each section. Navigate to the [[User Reference:Filters|Filters page]] to learn more about the framework, or view links below for tutorials and more reference pages.&lt;br /&gt;
&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Users==&lt;br /&gt;
&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* [[DownloadBCI2000|Download BCI2000]]&lt;br /&gt;
* Take the introductory [[User Tutorial:BCI2000 Tour|BCI2000 Tour]]&lt;br /&gt;
* Learn more through an &amp;lt;br /&amp;gt; [[Introduction_to_Adaptive_Neurotechnologies|Introduction to Adaptive Neurotechnologies]]&lt;br /&gt;
* Review the terminology in the [[BCI2000 Glossary]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Developers==&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* Download [[BCI2000 Binaries]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for windows using&amp;lt;br /&amp;gt; [[Programming_Howto:Building and Customizing BCI2000|Building and Customizing Howto]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for non-windows platforms using&amp;lt;br /&amp;gt;[[ Programming_Howto:Non:Building_and_Customizing_BCI2000_on_Non-Windows_Platforms|Building and Customizing Howto for Non-Windows]]&lt;br /&gt;
* Access to the [[Programming Howto:Building and Customizing BCI2000|BCI2000 Source Code]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px;  background-color:#e3f5fc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 References==&lt;br /&gt;
===BCI2000 Overview and Tools===&lt;br /&gt;
* The [[User Reference:Contents|User Reference Manual]] describes all details&amp;lt;br /&amp;gt;of system configuration and usage&lt;br /&gt;
===Technical References===&lt;br /&gt;
* The [[Technical Reference:Contents|Technical Reference Manual]] contains a discussion of its &amp;lt;br /&amp;gt;basic concepts, and a detailed specification of the BCI2000 standard.&lt;br /&gt;
===Programming References===&lt;br /&gt;
* The [[Programming Reference:Contents|Programming Reference]] provides background information &amp;lt;br /&amp;gt;which you need in order to understand, modify, or create code that &amp;lt;br /&amp;gt;depends on the BCI2000 framework.&lt;br /&gt;
===Contributions===&lt;br /&gt;
* [[Contributions:Contents|User-Contributed BCI2000 Components and Patches]]&lt;br /&gt;
===Categories===&lt;br /&gt;
*[[:Category:Data Acquisition | Data Acquisition]]&lt;br /&gt;
*[[:Category:Signal Processing | Signal Processing]]&lt;br /&gt;
*[[:Category:User Application | User Application]]&lt;br /&gt;
*[[:Category:External Interfaces | External Interfaces]]&lt;br /&gt;
*[[:Category:User Interface | User Interface]]&lt;br /&gt;
*[[:Category:Video | Video Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; background-color:#fff8dc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Tutorials==&lt;br /&gt;
===Setup Tutorials===&lt;br /&gt;
*[[Programming Howto:Install Prerequisites|Install Prerequisites]]&lt;br /&gt;
*[[Programming Howto:Register with BCI2000 Project|Register with the BCI2000 Project]]&lt;br /&gt;
*[[Programming Howto:Download the BCI2000 Sourcecode|Download the BCI2000 Sourcecode]]&lt;br /&gt;
*[[Programming Howto:Configure BCI2000 for Compilation|Configure BCI2000 for Compilation]]&lt;br /&gt;
*[[Programming Howto:Compile BCI2000|Compile BCI2000]]&lt;br /&gt;
===Experimental Tutorials===&lt;br /&gt;
*[[User Tutorial:Mu Rhythm BCI Tutorial|Mu Rhythm BCI Tutorial]]&lt;br /&gt;
*[[User Tutorial:P300 BCI Tutorial|P300 BCI Tutorial]]&lt;br /&gt;
===Programming Tutorials===&lt;br /&gt;
*[[Programming Tutorial:Implementing a Source Module|Implementing a Source Module]]&lt;br /&gt;
*[[Programming Howto:Create a custom Signal Processing Module|Implementing a Signal Processing Module]]&lt;br /&gt;
*[[Programming Tutorial:Implementing a Matlab-based Filter|Implementing a Matlab-based Filter]]&lt;br /&gt;
*[[Programming Tutorial:Implementing an Input Logger|Implementing an Input Logger]]&lt;br /&gt;
===Data Analysis Tutorials===&lt;br /&gt;
*[[User Tutorial:Data Analysis|Data Analysis with BCI2000]]&lt;br /&gt;
* Converting and Analyzing BCI2000 Data with  [[User Reference:Matlab MEX Files|Matlab MEX Files]]&lt;br /&gt;
* Analyze BCI2000 Data in Python with [https://github.com/neurotechcenter/BCI2kReader BCI2k Reader]&lt;br /&gt;
===All Tutorials: See a complete list of [[User Tutorial|BCI2000 tutorials]] here===&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==Supported Frameworks==&lt;br /&gt;
===BCI2000 Core Frameworks===&lt;br /&gt;
* [[User Reference:P3SpellerTask|P3 Speller]]&lt;br /&gt;
* [[User Reference:StimulusPresentationTask|Stimulus Presentation]] &lt;br /&gt;
* [[User Reference:CursorTask|Cursor Task]]&lt;br /&gt;
===[[Supported Frameworks|External Frameworks]]===&lt;br /&gt;
* [[User Tutorial:BCI2000Remote|BCI2000 Remote]] - includes Matlab, C++, and Python &lt;br /&gt;
* [[PsychoPy]]&lt;br /&gt;
* [[BCPy2000]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Additional Information==&lt;br /&gt;
* [[System Features|Features supported by BCI2000]]&lt;br /&gt;
* [https://github.com/neurotechcenter NCAN Github]&lt;br /&gt;
* [//{{SERVERNAME}}/phpbb BCI2000 Community Forum]&lt;br /&gt;
* [//{{SERVERNAME}}/tracproj/newticket Submit a Bug Report]  (make sure you log in)&lt;br /&gt;
* [[User FAQ|BCI2000 Frequently Asked Questions]]&lt;br /&gt;
* [[BCI2000 Glossary]]&amp;lt;br /&amp;gt;of terms specific to BCI2000&lt;br /&gt;
* [[BCI2000 Licensing|Licensing Information]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; background-color:white; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Publications==&lt;br /&gt;
* [https://{{SERVERNAME}}/downloads/doc/paper.pdf G. Schalk, D.J. McFarland, T. Hinterberger, N. Birbaumer, and J.R. Wolpaw: &#039;&#039;BCI2000: A General-Purpose Brain-Computer Interface (BCI) System&#039;&#039;, IEEE Trans Biomed Eng, 51(6), June 2004.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &#039;&#039;BCI2000: A General-Purpose Software Platform for BCI Research,&#039;&#039; In: G. Dornhege, J. del R. Millán, T. Hinterberger, D.J. McFarland, K.-R. Müller (eds.), &#039;&#039;Toward Brain-Computer Interfacing,&#039;&#039; MIT Press, 2007.&lt;br /&gt;
* [http://www.amazon.com/Practical-Guide-BrainComputer-Interfacing-BCI2000/dp/1849960917/ G. Schalk, J. Mellinger: &amp;quot;A Practical Guide to Brain-Computer Interfacing with BCI2000&amp;quot;, Springer, 2010.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &amp;quot;Using BCI2000 in BCI Research,&amp;quot; In: B. Graimann, B. Allison, G. Pfurtscheller (eds.), &amp;quot;Brain-Computer Interfaces: Revolutionizing Human-Computer Interaction&amp;quot;, Springer, 2010.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11647</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11647"/>
		<updated>2024-10-23T18:59:52Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ __NOEDITSECTION__&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; class=&amp;quot;noprint&amp;quot; style=&amp;quot;float:right; margin-top:-2em;margin-bottom:-2.4em; text-align:right&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;border-radius: 4px; background-color:#efefef;padding: 0.4em 1em 0.4em 1em;word-spacing:1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;form&amp;quot; name=&amp;quot;sitesearch&amp;quot; action=&amp;quot;https://www.google.com/search&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; name=&amp;quot;q&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;40&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;submit&amp;quot; value=&amp;quot;Google site search of bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;sitesearch&amp;quot; value=&amp;quot;bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;ie&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;oe&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/htmltag&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:-10px; margin-right:10px; background-color:#ededed; padding:0 1em 1em 1em; align:right; border-radius: 10px; vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;Download BCI2000&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;1. [https://www.bci2000.org/useradmin/ Create a free user account!!] (Required to download BCI2000)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;2. Download the [https://bci2000.org/downloads/bin/BCI2000Setup.exe latest release], or download the source code ([[Programming Howto:Building and Customizing BCI2000 |Windows]], [[Programming Howto:Non:Building and Customizing BCI2000 on Non-Windows Platforms |Non-windows]])&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt; &lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; &amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;What is BCI2000?&amp;lt;/b&amp;gt;=&lt;br /&gt;
BCI2000 is an open-source, general-purpose software system for brain-computer interface (BCI) research that is free for non-commercial use.&lt;br /&gt;
BCI2000 includes software tools that can acquire and process data, present stimuli and feedback, and manage interaction with outside devices such as robotic arms. BCI2000 is a real-time system that can synchronize EEG and other signals with a wide variety of biosignals and input devices such as mice or eye-trackers. It has several modules to manage data importing and exporting in common file formats. BCI2000 operates on most Windows systems, and the source code can be compiled on most Windows machines. &lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000 New Schematic Extra Large.gif|center|BCI2000 Schematic]]&lt;br /&gt;
&lt;br /&gt;
Above shows the main framework of BCI2000, with examples for each section. Navigate to the [[User Reference:Filters|Filters page]] to learn more about the framework, or view links below for tutorials and more reference pages.&lt;br /&gt;
&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Users==&lt;br /&gt;
&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* [[DownloadBCI2000|Download BCI2000]]&lt;br /&gt;
* Take the introductory [[User Tutorial:BCI2000 Tour|BCI2000 Tour]]&lt;br /&gt;
* Learn more through an &amp;lt;br /&amp;gt; [[Introduction_to_Adaptive_Neurotechnologies|Introduction to Adaptive Neurotechnologies]]&lt;br /&gt;
* Review the terminology in the [[BCI2000 Glossary]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Developers==&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* Download [[BCI2000 Binaries]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for windows using&amp;lt;br /&amp;gt; [[Programming_Howto:Building and Customizing BCI2000|Building and Customizing Howto]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for non-windows platforms using&amp;lt;br /&amp;gt;[[ Programming_Howto:Non:Building_and_Customizing_BCI2000_on_Non-Windows_Platforms|Building and Customizing Howto for Non-Windows]]&lt;br /&gt;
* Access to the [[Programming Howto:Building and Customizing BCI2000|BCI2000 Source Code]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px;  background-color:#e3f5fc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 References==&lt;br /&gt;
===BCI2000 Overview and Tools===&lt;br /&gt;
* The [[User Reference:Contents|User Reference Manual]] describes all details&amp;lt;br /&amp;gt;of system configuration and usage&lt;br /&gt;
===Technical References===&lt;br /&gt;
* The [[Technical Reference:Contents|Technical Reference Manual]] contains a discussion of its &amp;lt;br /&amp;gt;basic concepts, and a detailed specification of the BCI2000 standard.&lt;br /&gt;
===Programming References===&lt;br /&gt;
* The [[Programming Reference:Contents|Programming Reference]] provides background information &amp;lt;br /&amp;gt;which you need in order to understand, modify, or create code that &amp;lt;br /&amp;gt;depends on the BCI2000 framework.&lt;br /&gt;
===Contributions===&lt;br /&gt;
* [[Contributions:Contents|User-Contributed BCI2000 Components and Patches]]&lt;br /&gt;
===Categories===&lt;br /&gt;
*[[:Category:Data Acquisition | Data Acquisition]]&lt;br /&gt;
*[[:Category:Signal Processing | Signal Processing]]&lt;br /&gt;
*[[:Category:User Application | User Application]]&lt;br /&gt;
*[[:Category:External Interfaces | External Interfaces]]&lt;br /&gt;
*[[:Category:User Interface | User Interface]]&lt;br /&gt;
*[[:Category:Video | Video Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; background-color:#fff8dc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Tutorials==&lt;br /&gt;
===Setup Tutorials===&lt;br /&gt;
*[[Programming Howto:Install Prerequisites|Install Prerequisites]]&lt;br /&gt;
*[[Programming Howto:Register with BCI2000 Project|Register with the BCI2000 Project]]&lt;br /&gt;
*[[Programming Howto:Download the BCI2000 Sourcecode|Download the BCI2000 Sourcecode]]&lt;br /&gt;
*[[Programming Howto:Configure BCI2000 for Compilation|Configure BCI2000 for Compilation]]&lt;br /&gt;
*[[Programming Howto:Compile BCI2000|Compile BCI2000]]&lt;br /&gt;
===Experimental Tutorials===&lt;br /&gt;
*[[User Tutorial:Mu Rhythm BCI Tutorial|Mu Rhythm BCI Tutorial]]&lt;br /&gt;
*[[User Tutorial:P300 BCI Tutorial|P300 BCI Tutorial]]&lt;br /&gt;
===Programming Tutorials===&lt;br /&gt;
*[[Programming Tutorial:Implementing a Source Module|Implementing a Source Module]]&lt;br /&gt;
*[[Programming Howto:Create a custom Signal Processing Module|Implementing a Signal Processing Module]]&lt;br /&gt;
*[[Programming Tutorial:Implementing a Matlab-based Filter|Implementing a Matlab-based Filter]]&lt;br /&gt;
*[[Programming Tutorial:Implementing an Input Logger|Implementing an Input Logger]]&lt;br /&gt;
===Data Analysis Tutorials===&lt;br /&gt;
*[[User Tutorial:Data Analysis|Data Analysis with BCI2000]]&lt;br /&gt;
* Converting and Analyzing BCI2000 Data with  [[User Reference:Matlab MEX Files|Matlab MEX Files]]&lt;br /&gt;
* Analyze BCI2000 Data in Python with [https://github.com/neurotechcenter/BCI2kReader BCI2k Reader]&lt;br /&gt;
===All Tutorials: See a complete list of [[User Tutorial|BCI2000 tutorials]] here===&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==Supported Frameworks==&lt;br /&gt;
===BCI2000 Core Frameworks===&lt;br /&gt;
* [[User Reference:P3SpellerTask|P3 Speller]]&lt;br /&gt;
* [[User Reference:StimulusPresentationTask|Stimulus Presentation]] &lt;br /&gt;
* [[User Reference:CursorTask|Cursor Task]]&lt;br /&gt;
===[[Supported Frameworks|External Frameworks]]===&lt;br /&gt;
* [[User Tutorial:BCI2000Remote|BCI2000 Remote]] - includes Matlab, C++, and Python &lt;br /&gt;
* [[PsychoPy]]&lt;br /&gt;
* [[BCPy2000]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Additional Information==&lt;br /&gt;
* [[System Features|Features supported by BCI2000]]&lt;br /&gt;
* [https://github.com/neurotechcenter NCAN Github]&lt;br /&gt;
* [//{{SERVERNAME}}/phpbb BCI2000 Community Forum]&lt;br /&gt;
* [//{{SERVERNAME}}/tracproj/newticket Submit a Bug Report]  (make sure you log in)&lt;br /&gt;
* [[User FAQ|BCI2000 Frequently Asked Questions]]&lt;br /&gt;
* [[BCI2000 Glossary]]&amp;lt;br /&amp;gt;of terms specific to BCI2000&lt;br /&gt;
* [[BCI2000 Licensing|Licensing Information]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; background-color:white; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Publications==&lt;br /&gt;
* [https://{{SERVERNAME}}/downloads/doc/paper.pdf G. Schalk, D.J. McFarland, T. Hinterberger, N. Birbaumer, and J.R. Wolpaw: &#039;&#039;BCI2000: A General-Purpose Brain-Computer Interface (BCI) System&#039;&#039;, IEEE Trans Biomed Eng, 51(6), June 2004.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &#039;&#039;BCI2000: A General-Purpose Software Platform for BCI Research,&#039;&#039; In: G. Dornhege, J. del R. Millán, T. Hinterberger, D.J. McFarland, K.-R. Müller (eds.), &#039;&#039;Toward Brain-Computer Interfacing,&#039;&#039; MIT Press, 2007.&lt;br /&gt;
* [http://www.amazon.com/Practical-Guide-BrainComputer-Interfacing-BCI2000/dp/1849960917/ G. Schalk, J. Mellinger: &amp;quot;A Practical Guide to Brain-Computer Interfacing with BCI2000&amp;quot;, Springer, 2010.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &amp;quot;Using BCI2000 in BCI Research,&amp;quot; In: B. Graimann, B. Allison, G. Pfurtscheller (eds.), &amp;quot;Brain-Computer Interfaces: Revolutionizing Human-Computer Interaction&amp;quot;, Springer, 2010.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11646</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Main_Page&amp;diff=11646"/>
		<updated>2024-10-23T18:56:06Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ __NOEDITSECTION__&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; class=&amp;quot;noprint&amp;quot; style=&amp;quot;float:right; margin-top:-2em;margin-bottom:-2.4em; text-align:right&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;border-radius: 4px; background-color:#efefef;padding: 0.4em 1em 0.4em 1em;word-spacing:1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;form&amp;quot; name=&amp;quot;sitesearch&amp;quot; action=&amp;quot;https://www.google.com/search&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; name=&amp;quot;q&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;40&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;submit&amp;quot; value=&amp;quot;Google site search of bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;sitesearch&amp;quot; value=&amp;quot;bci2000.org&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;ie&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;htmltag tagname=&amp;quot;input&amp;quot; type=&amp;quot;hidden&amp;quot; name=&amp;quot;oe&amp;quot; value=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/htmltag&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:-10px; margin-right:10px; background-color:#ededed; padding:0 1em 1em 1em; align:right; border-radius: 10px; vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;Download BCI2000&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;1. [https://www.bci2000.org/useradmin/ Create a free user account!!] (Required to download BCI2000)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:130%&amp;quot;&amp;gt;2. Download the [https://bci2000.org/downloads/bin/BCI2000Setup.exe latest release], or download the source code ([[Programming Howto:Building and Customizing BCI2000 |Windows]], [[Programming Howto:Non:Building and Customizing BCI2000 on Non-Windows Platforms |Non-windows]])&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt; &lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; &amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
=&amp;lt;b&amp;gt;What is BCI2000?&amp;lt;/b&amp;gt;=&lt;br /&gt;
BCI2000 is an open-source, general-purpose software system for brain-computer interface (BCI) research that is free for non-commercial use.&lt;br /&gt;
BCI2000 includes software tools that can acquire and process data, present stimuli and feedback, and manage interaction with outside devices such as robotic arms. BCI2000 is a real-time system that can synchronize EEG and other signals with a wide variety of biosignals and input devices such as mice or eye-trackers. It has several modules to manage data importing and exporting in common file formats. BCI2000 operates on most Windows systems, and the source code can be compiled on most Windows machines. &lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000 New Schematic Extra Large.gif|center|800px|BCI2000 Schematic]]&lt;br /&gt;
&lt;br /&gt;
Above shows the main framework of BCI2000, with examples for each section. Navigate to the [[User Reference:Filters|Filters page]] to learn more about the framework, or view links below for tutorials and more reference pages.&lt;br /&gt;
&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;margin-top:-10px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Users==&lt;br /&gt;
&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* [[DownloadBCI2000|Download BCI2000]]&lt;br /&gt;
* Take the introductory [[User Tutorial:BCI2000 Tour|BCI2000 Tour]]&lt;br /&gt;
* Learn more through an &amp;lt;br /&amp;gt; [[Introduction_to_Adaptive_Neurotechnologies|Introduction to Adaptive Neurotechnologies]]&lt;br /&gt;
* Review the terminology in the [[BCI2000 Glossary]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 for Developers==&lt;br /&gt;
* [//{{SERVERNAME}}/useradmin Create or modify a User Account]&lt;br /&gt;
* Download [[BCI2000 Binaries]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for windows using&amp;lt;br /&amp;gt; [[Programming_Howto:Building and Customizing BCI2000|Building and Customizing Howto]]&lt;br /&gt;
* Download, build, and customize the BCI2000 toolchain for non-windows platforms using&amp;lt;br /&amp;gt;[[ Programming_Howto:Non:Building_and_Customizing_BCI2000_on_Non-Windows_Platforms|Building and Customizing Howto for Non-Windows]]&lt;br /&gt;
* Access to the [[Programming Howto:Building and Customizing BCI2000|BCI2000 Source Code]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px;  background-color:#e3f5fc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 References==&lt;br /&gt;
===BCI2000 Overview and Tools===&lt;br /&gt;
* The [[User Reference:Contents|User Reference Manual]] describes all details&amp;lt;br /&amp;gt;of system configuration and usage&lt;br /&gt;
===Technical References===&lt;br /&gt;
* The [[Technical Reference:Contents|Technical Reference Manual]] contains a discussion of its &amp;lt;br /&amp;gt;basic concepts, and a detailed specification of the BCI2000 standard.&lt;br /&gt;
===Programming References===&lt;br /&gt;
* The [[Programming Reference:Contents|Programming Reference]] provides background information &amp;lt;br /&amp;gt;which you need in order to understand, modify, or create code that &amp;lt;br /&amp;gt;depends on the BCI2000 framework.&lt;br /&gt;
===Contributions===&lt;br /&gt;
* [[Contributions:Contents|User-Contributed BCI2000 Components and Patches]]&lt;br /&gt;
===Categories===&lt;br /&gt;
*[[:Category:Data Acquisition | Data Acquisition]]&lt;br /&gt;
*[[:Category:Signal Processing | Signal Processing]]&lt;br /&gt;
*[[:Category:User Application | User Application]]&lt;br /&gt;
*[[:Category:External Interfaces | External Interfaces]]&lt;br /&gt;
*[[:Category:User Interface | User Interface]]&lt;br /&gt;
*[[:Category:Video | Video Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; background-color:#fff8dc; padding:0 1em 1em 1em; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Tutorials==&lt;br /&gt;
===Setup Tutorials===&lt;br /&gt;
*[[Programming Howto:Install Prerequisites|Install Prerequisites]]&lt;br /&gt;
*[[Programming Howto:Register with BCI2000 Project|Register with the BCI2000 Project]]&lt;br /&gt;
*[[Programming Howto:Download the BCI2000 Sourcecode|Download the BCI2000 Sourcecode]]&lt;br /&gt;
*[[Programming Howto:Configure BCI2000 for Compilation|Configure BCI2000 for Compilation]]&lt;br /&gt;
*[[Programming Howto:Compile BCI2000|Compile BCI2000]]&lt;br /&gt;
===Experimental Tutorials===&lt;br /&gt;
*[[User Tutorial:Mu Rhythm BCI Tutorial|Mu Rhythm BCI Tutorial]]&lt;br /&gt;
*[[User Tutorial:P300 BCI Tutorial|P300 BCI Tutorial]]&lt;br /&gt;
===Programming Tutorials===&lt;br /&gt;
*[[Programming Tutorial:Implementing a Source Module|Implementing a Source Module]]&lt;br /&gt;
*[[Programming Howto:Create a custom Signal Processing Module|Implementing a Signal Processing Module]]&lt;br /&gt;
*[[Programming Tutorial:Implementing a Matlab-based Filter|Implementing a Matlab-based Filter]]&lt;br /&gt;
*[[Programming Tutorial:Implementing an Input Logger|Implementing an Input Logger]]&lt;br /&gt;
===Data Analysis Tutorials===&lt;br /&gt;
*[[User Tutorial:Data Analysis|Data Analysis with BCI2000]]&lt;br /&gt;
* Converting and Analyzing BCI2000 Data with  [[User Reference:Matlab MEX Files|Matlab MEX Files]]&lt;br /&gt;
* Analyze BCI2000 Data in Python with [https://github.com/neurotechcenter/BCI2kReader BCI2k Reader]&lt;br /&gt;
===All Tutorials: See a complete list of [[User Tutorial|BCI2000 tutorials]] here===&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#fff8dc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==Supported Frameworks==&lt;br /&gt;
===BCI2000 Core Frameworks===&lt;br /&gt;
* [[User Reference:P3SpellerTask|P3 Speller]]&lt;br /&gt;
* [[User Reference:StimulusPresentationTask|Stimulus Presentation]] &lt;br /&gt;
* [[User Reference:CursorTask|Cursor Task]]&lt;br /&gt;
===[[Supported Frameworks|External Frameworks]]===&lt;br /&gt;
* [[User Tutorial:BCI2000Remote|BCI2000 Remote]] - includes Matlab, C++, and Python &lt;br /&gt;
* [[PsychoPy]]&lt;br /&gt;
* [[BCPy2000]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; padding:0 1em 1em 1em; background-color:#e3f5fc; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Additional Information==&lt;br /&gt;
* [[System Features|Features supported by BCI2000]]&lt;br /&gt;
* [https://github.com/neurotechcenter NCAN Github]&lt;br /&gt;
* [//{{SERVERNAME}}/phpbb BCI2000 Community Forum]&lt;br /&gt;
* [//{{SERVERNAME}}/tracproj/newticket Submit a Bug Report]  (make sure you log in)&lt;br /&gt;
* [[User FAQ|BCI2000 Frequently Asked Questions]]&lt;br /&gt;
* [[BCI2000 Glossary]]&amp;lt;br /&amp;gt;of terms specific to BCI2000&lt;br /&gt;
* [[BCI2000 Licensing|Licensing Information]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table cellspacing=&amp;quot;10&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;margin:0; margin-top:10px; margin-right:10px; border-radius: 10px; border:0.5px solid #a2a2a2; padding:0 1em 1em 1em; background-color:white; align:right;vertical-align:top;&amp;quot;&amp;gt;&lt;br /&gt;
==BCI2000 Publications==&lt;br /&gt;
* [https://{{SERVERNAME}}/downloads/doc/paper.pdf G. Schalk, D.J. McFarland, T. Hinterberger, N. Birbaumer, and J.R. Wolpaw: &#039;&#039;BCI2000: A General-Purpose Brain-Computer Interface (BCI) System&#039;&#039;, IEEE Trans Biomed Eng, 51(6), June 2004.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &#039;&#039;BCI2000: A General-Purpose Software Platform for BCI Research,&#039;&#039; In: G. Dornhege, J. del R. Millán, T. Hinterberger, D.J. McFarland, K.-R. Müller (eds.), &#039;&#039;Toward Brain-Computer Interfacing,&#039;&#039; MIT Press, 2007.&lt;br /&gt;
* [http://www.amazon.com/Practical-Guide-BrainComputer-Interfacing-BCI2000/dp/1849960917/ G. Schalk, J. Mellinger: &amp;quot;A Practical Guide to Brain-Computer Interfacing with BCI2000&amp;quot;, Springer, 2010.]&lt;br /&gt;
* J. Mellinger, G. Schalk: &amp;quot;Using BCI2000 in BCI Research,&amp;quot; In: B. Graimann, B. Allison, G. Pfurtscheller (eds.), &amp;quot;Brain-Computer Interfaces: Revolutionizing Human-Computer Interaction&amp;quot;, Springer, 2010.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11586</id>
		<title>User Tutorial:BCI2000Remote</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11586"/>
		<updated>2024-09-05T18:44:16Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Python Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends Operator Scripting commands to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the BCI2000RemoteLib library exist, such as Python, or MATLAB.&lt;br /&gt;
==Note==&lt;br /&gt;
BCI2000Remote is a means of interfacing with the BCI2000 Operator module meaning that there are potentially hundreds of ways we leverage this tool to have a meaningful interface with BCI2000. Because of this we will illustrate a few different integrations using different languages. This &amp;quot;How-to&amp;quot; will be separated into three separate sections: Python, C++, and Matlab.&lt;br /&gt;
==Python Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Find your Python folder. If you have an existing Python environment with your code find it using the Sys Library like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
locate_python = sys.exec_prefix&lt;br /&gt;
print(locate_python)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Locate your BCI2000Remote.py file which should have compiled into your prog folder. &lt;br /&gt;
Find where in your Python code you wish to integrate BCI2000. In this example I will show the minimum requirements for integration with BCI2000:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append(&#039;C:\\BCI2000.x64\\prog&#039;)&lt;br /&gt;
import BCI2000Remote&lt;br /&gt;
bci = BCI2000Remote.BCI2000Remote()&lt;br /&gt;
print(&#039;Operator path:&#039;, bci.OperatorPath)&lt;br /&gt;
bci.WindowVisible = True&lt;br /&gt;
bci.WindowTitle = &#039;Python controlled&#039;&lt;br /&gt;
bci.SubjectID = &#039;pysub&#039;&lt;br /&gt;
bci.Connect()&lt;br /&gt;
bci.Execute(&#039;cd ${BCI2000LAUNCHDIR}&#039;)&lt;br /&gt;
bci.Execute(&#039;ADD EVENT score 16 0&#039;)&lt;br /&gt;
bci.StartupModules((&#039;SignalGenerator&#039;, &#039;DummySignalprocessing&#039;, &#039;DummyApplication&#039;))&lt;br /&gt;
bci.Execute(&#039;Wait for Connected&#039;)&lt;br /&gt;
bci.LoadParametersRemote(&#039;../parms/fragments/amplifiers/SignalGenerator.prm&#039;)&lt;br /&gt;
bci.SetConfig()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is how you import BCI2000Remote:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote1.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you instantiate the operator object:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote 2.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how to customize the operator and connect to it:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCI2000Remote2.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you add your states:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_4.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to specify your signal source, signal processing, and application modules:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_5.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to load a parameter file(you can learn more about parameters [[Technical_Reference:Parameter_File|here]]):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_55.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to connect and issue commands to BCI2000:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_6.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And finally, how to tell BCI2000 to set states to a value during runtime:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:BCIRemote_6.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is run your code. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:BCIRemote_7.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C++ Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the C++ file or solution you would like to integrate with BCI2000 in Visual Studio, and find where it is located on your computer.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to the program&#039;s properties, and make the following changes:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; General, add the following folders from BCI2000 (64-bit)&#039;s src folder: &amp;lt;i&amp;gt; \core\Operator\BCI2000Remote, \shared\utils\Lib, \shared\config. &amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to Configuration Properties -&amp;gt; Linker -&amp;gt; Input, and add &amp;lt;i&amp;gt; ws2_32.lib &amp;lt;/i&amp;gt; to Additional Dependencies.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; Advanced, add &amp;lt;i&amp;gt;4996&amp;lt;/i&amp;gt; to the Disable Specific Warnings section.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add your Operator executable and the BCI2000RemoteLib dynamic library to the same directory as the program you intend to integrate. This can be found in the prog folder.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Also, add the following files to the directory with your program and &amp;lt;i&amp;gt;Operator.exe&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Make sure that you include all of your dependencies including BCI2000Remote.h &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Next, instantiate the BCI2000Remote object&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Specify your startup modules and any flags you wish to start them with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Load any parameter files and set subject information&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And here we just have BCI2000 send us back a feedback signal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is compile and run it. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; Be sure to compile this in your prog folder. This can be done by navigating again to Configuration Properties -&amp;gt; General, and changing the Output Directory to the path of the BCI2000 prog folder.&lt;br /&gt;
[[File:BCIRemote_7.jpg]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Load a parameter file, and set subject information&lt;br /&gt;
  bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Print feedback signal&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==MatlabTutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the Matlab file you would like to integrate with BCI2000.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Locate the BCI2000RemoteLib file in the BCI2000 prog folder, and BCI2000RemoteLib.h in src\core\Operator\BCI2000Remote, and load these into the Matlab file. Modify the file paths in &amp;lt;i&amp;gt;loadlibrary(...)&amp;lt;/i&amp;gt; as needed. &lt;br /&gt;
Note that BCI2000RemoteLib&#039;s file name has a &amp;quot;64&amp;quot; appended when it was built in 64 bit mode, and a &amp;quot;32&amp;quot; if built iin 32 bit mode.&lt;br /&gt;
In this tutorial, we will be using the 64 bit version.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%% c library load, initial part&lt;br /&gt;
BCI2000root = &#039;C:\bci2000.x64&#039;;&lt;br /&gt;
if not(libisloaded(&#039;bci&#039;))&lt;br /&gt;
    loadlibrary(fullfile(BCI2000root,&#039;prog&#039;,&#039;BCI2000RemoteLib64&#039;),...&lt;br /&gt;
        fullfile(BCI2000root,&#039;src&#039;,&#039;core&#039;,&#039;Operator&#039;,&#039;BCI2000Remote&#039;,&#039;BCI2000RemoteLib.h&#039;), &#039;alias&#039;, &#039;bci&#039;)&lt;br /&gt;
end &lt;br /&gt;
libfunctions(&#039;bci&#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Locate Operator.exe in the prog folder. Recover the memory, change the directory, and make the window visible in BCI2000. Again, modify the file path if it differs. &lt;br /&gt;
&amp;lt;pre&amp;gt;%need to call BCI2000Remote_Delete to recover the memory&lt;br /&gt;
bciHandle = calllib(&#039;bci&#039;, &#039;BCI2000Remote_New&#039;);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetOperatorPath&#039;, bciHandle, fullfile(BCI2000root,&#039;prog&#039;,&#039;Operator&#039;));&lt;br /&gt;
&lt;br /&gt;
% if we fail cto establish a connection to BCI2000Remote&lt;br /&gt;
if calllib(&#039;bci&#039;, &#039;BCI2000Remote_Connect&#039;, bciHandle) ~= 1&lt;br /&gt;
    fprintf(&#039;bci connect fail!&#039;)&lt;br /&gt;
    calllib(&#039;bci&#039;, &#039;BCI2000Remote_Delete&#039;, bciHandle); % call BCI2000Remote_Delete to recovery the memory&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
% Startup BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Change directory $BCI2000LAUNCHDIR&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Show window; Set title ${Extract file base $0}&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Reset system&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Add new states, events, or parameters before starting up the system. Note that it is greatly preferred to use events instead of states because of timing precision.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Create new parameter (must be done before startup)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Add Parameter Application:TestParameterField string TestParameter= FirstNewParameter % % %&#039;, 0); &lt;br /&gt;
&lt;br /&gt;
% Define events&lt;br /&gt;
% Define new event with 2 bytes of information (2 colors)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;add event Square 1 0&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add in the proper modules (Signal Generator, Signal Processor, and Application). Refer to the documentation [[Technical_Reference:BCI2000Remote_Library]] for more information on BCI2000 remote functions. Also refer to the example Matlab code under [[Programming_Reference:BCI2000Remote_Class#Matlab_Example]].&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Startup system localhost&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Startup system localhost&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Establish connection to three modules&lt;br /&gt;
SourceModule = &#039;SignalGenerator&#039;;&lt;br /&gt;
modules      = libpointer(&#039;stringPtrPtr&#039;, {[SourceModule &#039; --local --LogKeyboard=1&#039;], &#039;DummySignalProcessing&#039;, &#039;DummyApplication&#039;});&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_StartupModules2&#039;, bciHandle, modules, 3);&lt;br /&gt;
&lt;br /&gt;
% Wait for connected before loading parameters!&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Connected&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Load parameter files, modify parameters directly, and add watches after BCI2000 is connected. It can also be helpful to wait for bci2000 to start running (collecting data) before proceeding.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Load parameter files&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_LoadParametersRemote&#039;, bciHandle, fullfile(BCI2000root,&#039;parms&#039;,&#039;fragments&#039;,&#039;amplifiers&#039;,&#039;SignalGenerator.prm&#039;));&lt;br /&gt;
&lt;br /&gt;
% Set parameter values&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetDataDirectory&#039;, bciHandle, fullfile(BCI2000root,&#039;data&#039;,&#039;BJH&#039;));&lt;br /&gt;
&lt;br /&gt;
%Set watches to appear automatically&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;visualize watch Square&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Wait for BCI2000 to start running before starting application&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; While BCI2000 is running you can also get and set event and state values, and also get parameter values. Note that you cannot modify parameter values while BCI2000 is running. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Get parameter value&lt;br /&gt;
SamplingRate = calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetParameter&#039;, bciHandle, &#039;SamplingRate&#039;);&lt;br /&gt;
fprintf([&#039;\nSamplingRate: &#039; num2str(SamplingRate) &#039;Hz\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Get event value&lt;br /&gt;
[~,~,~,Square]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetEventVariable&#039;, bciHandle, &#039;Square&#039;, 0.0);&lt;br /&gt;
&lt;br /&gt;
% BCI2000 set white rectangle to 1 (true)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Set event Square 1&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Get state value&lt;br /&gt;
% Immediately after data block has been acquired from hardware, the &lt;br /&gt;
% DataIOFilter writes a 16-bit millisecond-resolution time stamp into the &lt;br /&gt;
% SourceTime state. Block duration is measured as the difference between&lt;br /&gt;
% two consecutive time stamps.&lt;br /&gt;
[~,~,~,SourceTime]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetStateVariable&#039;, bciHandle, &#039;SourceTime&#039;, 0.0);&lt;br /&gt;
fprintf([&#039;\nSourceTime: &#039;, num2str(SourceTime), &#039;\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Stop running BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetStateVariable&#039;, bciHandle, &#039;Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=ZwLcovHZabw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]][[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:Psychopy&amp;diff=11585</id>
		<title>User Tutorial:Psychopy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:Psychopy&amp;diff=11585"/>
		<updated>2024-09-05T18:38:00Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. The video first describes the two components that are developed to remotely start BCI2000 from PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes on to an example.&lt;br /&gt;
&lt;br /&gt;
==Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy1.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
File:Psychopy2.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open PsychoPy and then open your experiment file (StroopExtended is what we use in the demo)&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy3.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the part of the experiment where you want to start BCI2000 (in this case the &#039;&#039;instruct&#039;&#039; tab) and look under the custom section of the components for the &#039;&#039;&#039;BCI Connect&#039;&#039;&#039; and &#039;&#039;&#039;BCI Update State&#039;&#039;&#039; components&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy4.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the BCI2000 Start Component by clicking on it. &lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Enter the path to the prog folder in the BCI2000 directory where your BCI2000Remote.py file exists&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy5.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the states that you want to record separated by commas (the first value will always be the default value and the second value will always be the maximum value)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy6.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the BCIUpdateState component to where you want to update state values. You can either choose to simply pass a variable through BCIUpdateState, or you can specify that it execute a specific Python script by choosing the &amp;quot;Use Expression&amp;quot; ticker&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy7.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy8.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy9.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy10.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=yPacLewE3Xo&amp;amp;list=PL6LrR5Nj3cAxOxKHNsnqyKfLDGikpi8Qi&amp;amp;index=4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]][[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11584</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11584"/>
		<updated>2024-09-05T18:37:20Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateStart Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039; and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11583</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=11583"/>
		<updated>2024-09-05T18:00:32Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Integrating BCI2000 into PyschoPy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. [1] This wiki page first describes the two components that remotely start BCI2000 from PsychoPy. The next section describes the steps to add the new components in the PsychoPy application. The final section goes over two tutorial examples.&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://youtu.be/yPacLewE3Xo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
For this project, you will need two things: [https://www.bci2000.org/mediawiki/index.php/Programming_Howto:Building_and_Customizing_BCI2000 BCI2000] compiled for your system and the newest version of [https://www.psychopy.org/download.html PsychoPy].&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
This component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI2000 &#039;&#039;prog&#039;&#039; directory, which contains the &#039;&#039;BCI2000Remote.py&#039;&#039; file.&lt;br /&gt;
; States : List of new states to add to BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue.&#039; Eg: lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; You can specify the modules with which you want to run the experiment with the &#039;&#039;BCI.StartupModules&#039;&#039; command in the Init.py file previously copied into your PsychoPy environment. You can also specify which parameters to use for the experiment and specify other command-line arguments with the &#039;&#039;BCI.LoadParameterRemote&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000Start.png|alt=&amp;quot;BCI2000 start component image showing its parameters&amp;quot;|BCIStart Component]]&lt;br /&gt;
&lt;br /&gt;
=== BCI2000UpdateState ===&lt;br /&gt;
This component defines which state to update and when. It takes the following parameters:&lt;br /&gt;
; State Name : The name of the state in BCI2000 to update.&lt;br /&gt;
; Response Component Variable : The variable to which the state is to be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variable is written as &#039;&#039;$VariableName&#039;&#039;. &lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame and the variable specified in the Response Component Variable is not used to update the state.&lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases where the Response Component Variable is not available and the user wants more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands such as &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See [[Programming Reference:BCI2000Remote Class]] and [[User Reference:Operator Module Scripting]] for more details.&lt;br /&gt;
&lt;br /&gt;
[[File:BCI2000UpdateState.png|alt=&amp;quot;BCI2000 update state component image showing its parameters&amp;quot;|BCIUpdateStart Component]]&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Clone PsychoPy from the [https://github.com/psychopy/psychopy PyschoPy] repository. You can also download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
Below is a picture of PsychoPy before integrating BCI2000. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=500px heights=500px&amp;gt;&lt;br /&gt;
File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Standalone version ===&lt;br /&gt;
For Windows, Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=== Developer version ===&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open the terminal and navigate to the PsychoPy home directory where &#039;&#039;setup.py&#039;&#039; resides.&lt;br /&gt;
Run the following command in the terminal: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;pip install -e .&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Start PsychoPy application by running &amp;quot;python \psychopy\app\psychopyApp.py&amp;quot; from wherever you cloned your PsychoPy repository. If you downloaded the standalone version installer, you can simply press the Windows key and search for PsychoPy. Once you&#039;re under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in the rightmost column), you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039; and &#039;&#039;BCI2000UpdateState&#039;&#039; as shown in the figure below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen if you are using a single screen.&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, two examples are presented to help the user understand the use of BCI2000 within PsychoPy. The examples modify the demo stroopExtended (already provided by PsychoPy once you have unpacked the demos) and integrates BCI2000 within it. The stroopExtended demo asks user to press certain keys depending on the color shown on the screen and records the response time.&lt;br /&gt;
&lt;br /&gt;
=== Using Response Component Variable Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;correctKey&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will be changed to 1 if the key pressed by user is correct, otherwise 0.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like this. &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo]] &lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;correctKey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;correctKey&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;1&#039;&#039;&#039; is the maximum value the state can take in any case. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:PsychoPyBciStart1.png|alt=&amp;quot;PsychoPy - Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000]] &lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the fields &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (the BCI2000 state we want to update; &#039;$&#039; is used to indicate to PsychoPy to treat it as a variable) and &#039;&#039;Response Component Variable&#039;&#039; with &#039;&#039;&#039;$resp.corr&#039;&#039;&#039; (&#039;resp&#039; is the name of the keyboard that takes the input and &#039;corr&#039; is its property that stores whether the key pressed is correct or not. you can see this variable being used in the program when you compile it to script) as shown in the image. This will essentially update the state &#039;correctKey&#039; with the value of &#039;resp.corr&#039;.  &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:PsychoPyBciUpdateState1.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000]]&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, then click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:PsychoPyBciDemoRun1.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 1&amp;quot;|PsychoPy Stroop Extended Demo Run 1]] &lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using Use Expression Option ===&lt;br /&gt;
In this tutorial, we will add a new state called &#039;&#039;&#039;responseTime&#039;&#039;&#039; in BCI2000 using PsychoPy. This state will represent the time the user takes to press the correct key in seconds (with no decimals).&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the stroopExtended demo in PsychoPy. It should look like the image below. &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:PsychoPyDemoStart.png|alt=&amp;quot;PsychoPy Stroop Extended Demo&amp;quot;|PsychoPy Stroop Extended Demo]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - Navigate to the &#039;&#039;&#039;instruct&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039;. Enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in the &#039;&#039;Path&#039;&#039; field and &amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt; in the &#039;&#039;States&#039;&#039; field as shown in the image. &#039;&#039;&#039;responseTime&#039;&#039;&#039; is the name we want the new state to have in BCI2000, &#039;&#039;&#039;0&#039;&#039;&#039; is the default value the state should have and &#039;&#039;&#039;600&#039;&#039;&#039; is the maximum value the state can take in any case, i.e, the maximum response time could be 10 minutes.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:PsychoPyBciStart2.png|alt=&amp;quot;PsychoPy- Add State into BCI2000&amp;quot;|PsychoPy - Add State into BCI2000]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - Navigate to the &#039;&#039;&#039;trial&#039;&#039;&#039; tab and click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Check on the &#039;&#039;&#039;Use Expression&#039;&#039;&#039; option to run the expression that is written in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of python code in the &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines first set the &#039;RUNNING&#039; state of BCI2000 to 1 to make sure that BCI2000 is running. It then checks if the type of the &#039;resp.rt&#039; is float. If yes, that means &#039;resp.rt&#039; stores the response time and sets the state &#039;responseTime&#039; to the rounded value of &#039;resp.rt&#039; (&#039;resp&#039; is the name of the keyboard which takes the input and &#039;rt&#039; is its property that stores the time it took user to press the key; you can see this variable being used in the program when you compile it to script) using the bci.Execute and SET STATE commands.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNING 1&#039;) &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; bci.Execute(&#039;SET STATE responseTime %d&#039; % round(resp.rt))&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:PsychoPyBciUpdateState2.png|alt=&amp;quot;PsychoPy - Update State in BCI2000&amp;quot;|PsychoPy - Update State in BCI2000]]&lt;br /&gt;
&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment. BCI2000 will start. Add the newly created state to watch (in the BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch. Click Ok on the States and Events screen) and proceed with your PsychoPy experiment. The output of this experiment would be similar to the image shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments in full screen mode if you are using a single screen. &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:PsychoPyBciDemoRun2.png|alt=&amp;quot;PsychoPy Stroop Extended Demo Run 2&amp;quot;|PsychoPy Stroop Extended Demo Run 2]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. [https://www.psychopy.org/ PsychoPy site]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:Psychopy&amp;diff=11582</id>
		<title>User Tutorial:Psychopy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:Psychopy&amp;diff=11582"/>
		<updated>2024-09-05T17:57:29Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
PsychoPy is an open-source application used to perform a large number of neuroscience, psychology, and psychophysics experiments. The video first describes the two components that are developed to remotely start BCI2000 from PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes on to an example.&lt;br /&gt;
&lt;br /&gt;
==Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Download the PsychoPy standalone version from the PsychoPy [https://www.psychopy.org/download.html downloads page].&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy1.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from the &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy2.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open PsychoPy and then open your experiment file (StroopExtended is what we use in the demo)&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy3.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the part of the experiment where you want to start BCI2000 (in this case the &#039;&#039;instruct&#039;&#039; tab) and look under the custom section of the components for the &#039;&#039;&#039;BCI Connect&#039;&#039;&#039; and &#039;&#039;&#039;BCI Update State&#039;&#039;&#039; components&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy4.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the BCI2000 Start Component by clicking on it. &lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Enter the path to the prog folder in the BCI2000 directory where your BCI2000Remote.py file exists&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy5.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the states that you want to record separated by commas (the first value will always be the default value and the second value will always be the maximum value)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy6.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add the BCIUpdateState component to where you want to update state values. You can either choose to simply pass a variable through BCIUpdateState, or you can specify that it execute a specific Python script by choosing the &amp;quot;Use Expression&amp;quot; ticker&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy7.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy8.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Run the experiment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy9.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=400px heights=400px&amp;gt;&lt;br /&gt;
File:Psychopy10.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=yPacLewE3Xo&amp;amp;list=PL6LrR5Nj3cAxOxKHNsnqyKfLDGikpi8Qi&amp;amp;index=4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]][[Category:Video]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11525</id>
		<title>User Tutorial:BCI2000Remote</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11525"/>
		<updated>2024-08-15T22:28:45Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* Python Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends Operator Scripting commands to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the BCI2000RemoteLib library exist, such as Python, or MATLAB.&lt;br /&gt;
==Note==&lt;br /&gt;
BCI2000Remote is a means of interfacing with the BCI2000 Operator module meaning that there are potentially hundreds of ways we leverage this tool to have a meaningful interface with BCI2000. Because of this we will illustrate a few different integrations using different languages. This &amp;quot;How-to&amp;quot; will be separated into three separate sections: Python, C++, and Matlab.&lt;br /&gt;
==Python Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Find your Python folder. If you have an existing Python environment with your code find it using the Sys Library like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
locate_python = sys.exec_prefix&lt;br /&gt;
print(locate_python)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Locate your BCI2000Remote.py file which should have compiled into your prog folder. &lt;br /&gt;
Find where in your Python code you wish to integrate BCI2000. In this example I will show the minimum requirements for integration with BCI2000:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append(&#039;C:\\BCI2000.x64\\prog&#039;)&lt;br /&gt;
import BCI2000Remote&lt;br /&gt;
bci = BCI2000Remote.BCI2000Remote()&lt;br /&gt;
print(&#039;Operator path:&#039;, bci.OperatorPath)&lt;br /&gt;
bci.WindowVisible = True&lt;br /&gt;
bci.WindowTitle = &#039;Python controlled&#039;&lt;br /&gt;
bci.SubjectID = &#039;pysub&#039;&lt;br /&gt;
bci.Connect()&lt;br /&gt;
bci.Execute(&#039;cd ${BCI2000LAUNCHDIR}&#039;)&lt;br /&gt;
bci.Execute(&#039;ADD EVENT score 16 0&#039;)&lt;br /&gt;
bci.StartupModules((&#039;SignalGenerator&#039;, &#039;DummySignalprocessing&#039;, &#039;DummyApplication&#039;))&lt;br /&gt;
bci.Execute(&#039;Wait for Connected&#039;)&lt;br /&gt;
bci.LoadParametersRemote(&#039;../parms/fragments/amplifiers/SignalGenerator.prm&#039;)&lt;br /&gt;
bci.SetConfig()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is how you import BCI2000Remote:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you instantiate the operator object:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote 2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how to customize the operator and connect to it:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCI2000Remote2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you add your states:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_4.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to specify your signal source, signal processing, and application modules:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_5.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to load a parameter file(you can learn more about parameters [[Technical_Reference:Parameter_File|here]]):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_55.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to connect and issue commands to BCI2000:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And finally, how to tell BCI2000 to set states to a value during runtime:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is run your code. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
[[File:BCIRemote_7.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C++ Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the C++ file or solution you would like to integrate with BCI2000 in Visual Studio, and find where it is located on your computer.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to the program&#039;s properties, and make the following changes:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; General, add the following folders from BCI2000 (64-bit)&#039;s src folder: &amp;lt;i&amp;gt; \core\Operator\BCI2000Remote, \shared\utils\Lib, \shared\config. &amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to Configuration Properties -&amp;gt; Linker -&amp;gt; Input, and add &amp;lt;i&amp;gt; ws2_32.lib &amp;lt;/i&amp;gt; to Additional Dependencies.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; Advanced, add &amp;lt;i&amp;gt;4996&amp;lt;/i&amp;gt; to the Disable Specific Warnings section.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add your Operator executable and the BCI2000RemoteLib dynamic library to the same directory as the program you intend to integrate. This can be found in the prog folder.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Also, add the following files to the directory with your program and &amp;lt;i&amp;gt;Operator.exe&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Make sure that you include all of your dependencies including BCI2000Remote.h &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Next, instantiate the BCI2000Remote object&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Specify your startup modules and any flags you wish to start them with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Load any parameter files and set subject information&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And here we just have BCI2000 send us back a feedback signal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is compile and run it. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; Be sure to compile this in your prog folder. This can be done by navigating again to Configuration Properties -&amp;gt; General, and changing the Output Directory to the path of the BCI2000 prog folder.&lt;br /&gt;
[[File:BCIRemote_7.jpg]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Load a parameter file, and set subject information&lt;br /&gt;
  bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Print feedback signal&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==MatlabTutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the Matlab file you would like to integrate with BCI2000.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Locate the BCI2000RemoteLib file in the BCI2000 prog folder, and BCI2000RemoteLib.h in src\core\Operator\BCI2000Remote, and load these into the Matlab file. Modify the file paths in &amp;lt;i&amp;gt;loadlibrary(...)&amp;lt;/i&amp;gt; as needed. &lt;br /&gt;
Note that BCI2000RemoteLib&#039;s file name has a &amp;quot;64&amp;quot; appended when it was built in 64 bit mode, and a &amp;quot;32&amp;quot; if built iin 32 bit mode.&lt;br /&gt;
In this tutorial, we will be using the 64 bit version.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%% c library load, initial part&lt;br /&gt;
BCI2000root = &#039;C:\bci2000.x64&#039;;&lt;br /&gt;
if not(libisloaded(&#039;bci&#039;))&lt;br /&gt;
    loadlibrary(fullfile(BCI2000root,&#039;prog&#039;,&#039;BCI2000RemoteLib64&#039;),...&lt;br /&gt;
        fullfile(BCI2000root,&#039;src&#039;,&#039;core&#039;,&#039;Operator&#039;,&#039;BCI2000Remote&#039;,&#039;BCI2000RemoteLib.h&#039;), &#039;alias&#039;, &#039;bci&#039;)&lt;br /&gt;
end &lt;br /&gt;
libfunctions(&#039;bci&#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Locate Operator.exe in the prog folder. Recover the memory, change the directory, and make the window visible in BCI2000. Again, modify the file path if it differs. &lt;br /&gt;
&amp;lt;pre&amp;gt;%need to call BCI2000Remote_Delete to recover the memory&lt;br /&gt;
bciHandle = calllib(&#039;bci&#039;, &#039;BCI2000Remote_New&#039;);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetOperatorPath&#039;, bciHandle, fullfile(BCI2000root,&#039;prog&#039;,&#039;Operator&#039;));&lt;br /&gt;
&lt;br /&gt;
% if we fail cto establish a connection to BCI2000Remote&lt;br /&gt;
if calllib(&#039;bci&#039;, &#039;BCI2000Remote_Connect&#039;, bciHandle) ~= 1&lt;br /&gt;
    fprintf(&#039;bci connect fail!&#039;)&lt;br /&gt;
    calllib(&#039;bci&#039;, &#039;BCI2000Remote_Delete&#039;, bciHandle); % call BCI2000Remote_Delete to recovery the memory&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
% Startup BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Change directory $BCI2000LAUNCHDIR&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Show window; Set title ${Extract file base $0}&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Reset system&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Add new states, events, or parameters before starting up the system. Note that it is greatly preferred to use events instead of states because of timing precision.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Create new parameter (must be done before startup)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Add Parameter Application:TestParameterField string TestParameter= FirstNewParameter % % %&#039;, 0); &lt;br /&gt;
&lt;br /&gt;
% Define events&lt;br /&gt;
% Define new event with 2 bytes of information (2 colors)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;add event Square 1 0&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add in the proper modules (Signal Generator, Signal Processor, and Application). Refer to the documentation [[Technical_Reference:BCI2000Remote_Library]] for more information on BCI2000 remote functions. Also refer to the example Matlab code under [[Programming_Reference:BCI2000Remote_Class#Matlab_Example]].&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Startup system localhost&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Startup system localhost&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Establish connection to three modules&lt;br /&gt;
SourceModule = &#039;SignalGenerator&#039;;&lt;br /&gt;
modules      = libpointer(&#039;stringPtrPtr&#039;, {[SourceModule &#039; --local --LogKeyboard=1&#039;], &#039;DummySignalProcessing&#039;, &#039;DummyApplication&#039;});&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_StartupModules2&#039;, bciHandle, modules, 3);&lt;br /&gt;
&lt;br /&gt;
% Wait for connected before loading parameters!&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Connected&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Load parameter files, modify parameters directly, and add watches after BCI2000 is connected. It can also be helpful to wait for bci2000 to start running (collecting data) before proceeding.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Load parameter files&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_LoadParametersRemote&#039;, bciHandle, fullfile(BCI2000root,&#039;parms&#039;,&#039;fragments&#039;,&#039;amplifiers&#039;,&#039;SignalGenerator.prm&#039;));&lt;br /&gt;
&lt;br /&gt;
% Set parameter values&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetDataDirectory&#039;, bciHandle, fullfile(BCI2000root,&#039;data&#039;,&#039;BJH&#039;));&lt;br /&gt;
&lt;br /&gt;
%Set watches to appear automatically&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;visualize watch Square&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Wait for BCI2000 to start running before starting application&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; While BCI2000 is running you can also get and set event and state values, and also get parameter values. Note that you cannot modify parameter values while BCI2000 is running. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Get parameter value&lt;br /&gt;
SamplingRate = calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetParameter&#039;, bciHandle, &#039;SamplingRate&#039;);&lt;br /&gt;
fprintf([&#039;\nSamplingRate: &#039; num2str(SamplingRate) &#039;Hz\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Get event value&lt;br /&gt;
[~,~,~,Square]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetEventVariable&#039;, bciHandle, &#039;Square&#039;, 0.0);&lt;br /&gt;
&lt;br /&gt;
% BCI2000 set white rectangle to 1 (true)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Set event Square 1&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Get state value&lt;br /&gt;
% Immediately after data block has been acquired from hardware, the &lt;br /&gt;
% DataIOFilter writes a 16-bit millisecond-resolution time stamp into the &lt;br /&gt;
% SourceTime state. Block duration is measured as the difference between&lt;br /&gt;
% two consecutive time stamps.&lt;br /&gt;
[~,~,~,SourceTime]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetStateVariable&#039;, bciHandle, &#039;SourceTime&#039;, 0.0);&lt;br /&gt;
fprintf([&#039;\nSourceTime: &#039;, num2str(SourceTime), &#039;\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Stop running BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetStateVariable&#039;, bciHandle, &#039;Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=ZwLcovHZabw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11524</id>
		<title>User Tutorial:BCI2000Remote</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11524"/>
		<updated>2024-08-15T22:12:16Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* MatlabTutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends Operator Scripting commands to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the BCI2000RemoteLib library exist, such as Python, or MATLAB.&lt;br /&gt;
==Note==&lt;br /&gt;
BCI2000Remote is a means of interfacing with the BCI2000 Operator module meaning that there are potentially hundreds of ways we leverage this tool to have a meaningful interface with BCI2000. Because of this we will illustrate a few different integrations using different languages. This &amp;quot;How-to&amp;quot; will be separated into three separate sections: Python, C++, and Matlab.&lt;br /&gt;
==Python Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Find your Python folder. If you have an existing Python environment with your code find it using the Sys Library like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
locate_python = sys.exec_prefix&lt;br /&gt;
print(locate_python)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Locate your BCI2000Remote.py file which should have compiled into your prog folder. &lt;br /&gt;
Find where in your Python code you wish to integrate BCI2000. In this example I will show the minimum requirements for integration with BCI2000:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append(&#039;C:\\BCI2000.x64\\prog&#039;)&lt;br /&gt;
import BCI2000Remote&lt;br /&gt;
bci = BCI2000Remote.BCI2000Remote()&lt;br /&gt;
print(&#039;Operator path:&#039;, bci.OperatorPath)&lt;br /&gt;
bci.WindowVisible = True&lt;br /&gt;
bci.WindowTitle = &#039;Python controlled&#039;&lt;br /&gt;
bci.SubjectID = &#039;pysub&#039;&lt;br /&gt;
bci.Connect()&lt;br /&gt;
bci.Execute(&#039;cd ${BCI2000LAUNCHDIR}&#039;)&lt;br /&gt;
bci.Execute(&#039;ADD STATE score 16 0&#039;)&lt;br /&gt;
bci.StartupModules((&#039;SignalGenerator&#039;, &#039;DummySignalprocessing&#039;, &#039;DummyApplication&#039;))&lt;br /&gt;
bci.Execute(&#039;Wait for Connected&#039;)&lt;br /&gt;
bci.LoadParametersRemote(&#039;../parms/fragments/amplifiers/amplifier.prm&#039;)&lt;br /&gt;
bci.SetConfig()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is how you import BCI2000Remote:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you instantiate the operator object:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote 2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how to customize the operator and connect to it:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCI2000Remote2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you add your states:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_4.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to specify your signal source, signal processing, and application modules:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_5.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to load a parameter file(you can learn more about parameters [[Technical_Reference:Parameter_File|here]]):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_55.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to connect and issue commands to BCI2000:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And finally, how to tell BCI2000 to set states to a value during runtime:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is run your code. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
[[File:BCIRemote_7.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C++ Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the C++ file or solution you would like to integrate with BCI2000 in Visual Studio, and find where it is located on your computer.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to the program&#039;s properties, and make the following changes:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; General, add the following folders from BCI2000 (64-bit)&#039;s src folder: &amp;lt;i&amp;gt; \core\Operator\BCI2000Remote, \shared\utils\Lib, \shared\config. &amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to Configuration Properties -&amp;gt; Linker -&amp;gt; Input, and add &amp;lt;i&amp;gt; ws2_32.lib &amp;lt;/i&amp;gt; to Additional Dependencies.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; Advanced, add &amp;lt;i&amp;gt;4996&amp;lt;/i&amp;gt; to the Disable Specific Warnings section.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add your Operator executable and the BCI2000RemoteLib dynamic library to the same directory as the program you intend to integrate. This can be found in the prog folder.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Also, add the following files to the directory with your program and &amp;lt;i&amp;gt;Operator.exe&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Make sure that you include all of your dependencies including BCI2000Remote.h &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Next, instantiate the BCI2000Remote object&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Specify your startup modules and any flags you wish to start them with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Load any parameter files and set subject information&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And here we just have BCI2000 send us back a feedback signal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is compile and run it. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; Be sure to compile this in your prog folder. This can be done by navigating again to Configuration Properties -&amp;gt; General, and changing the Output Directory to the path of the BCI2000 prog folder.&lt;br /&gt;
[[File:BCIRemote_7.jpg]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Load a parameter file, and set subject information&lt;br /&gt;
  bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Print feedback signal&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==MatlabTutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the Matlab file you would like to integrate with BCI2000.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Locate the BCI2000RemoteLib file in the BCI2000 prog folder, and BCI2000RemoteLib.h in src\core\Operator\BCI2000Remote, and load these into the Matlab file. Modify the file paths in &amp;lt;i&amp;gt;loadlibrary(...)&amp;lt;/i&amp;gt; as needed. &lt;br /&gt;
Note that BCI2000RemoteLib&#039;s file name has a &amp;quot;64&amp;quot; appended when it was built in 64 bit mode, and a &amp;quot;32&amp;quot; if built iin 32 bit mode.&lt;br /&gt;
In this tutorial, we will be using the 64 bit version.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%% c library load, initial part&lt;br /&gt;
BCI2000root = &#039;C:\bci2000.x64&#039;;&lt;br /&gt;
if not(libisloaded(&#039;bci&#039;))&lt;br /&gt;
    loadlibrary(fullfile(BCI2000root,&#039;prog&#039;,&#039;BCI2000RemoteLib64&#039;),...&lt;br /&gt;
        fullfile(BCI2000root,&#039;src&#039;,&#039;core&#039;,&#039;Operator&#039;,&#039;BCI2000Remote&#039;,&#039;BCI2000RemoteLib.h&#039;), &#039;alias&#039;, &#039;bci&#039;)&lt;br /&gt;
end &lt;br /&gt;
libfunctions(&#039;bci&#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Locate Operator.exe in the prog folder. Recover the memory, change the directory, and make the window visible in BCI2000. Again, modify the file path if it differs. &lt;br /&gt;
&amp;lt;pre&amp;gt;%need to call BCI2000Remote_Delete to recover the memory&lt;br /&gt;
bciHandle = calllib(&#039;bci&#039;, &#039;BCI2000Remote_New&#039;);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetOperatorPath&#039;, bciHandle, fullfile(BCI2000root,&#039;prog&#039;,&#039;Operator&#039;));&lt;br /&gt;
&lt;br /&gt;
% if we fail cto establish a connection to BCI2000Remote&lt;br /&gt;
if calllib(&#039;bci&#039;, &#039;BCI2000Remote_Connect&#039;, bciHandle) ~= 1&lt;br /&gt;
    fprintf(&#039;bci connect fail!&#039;)&lt;br /&gt;
    calllib(&#039;bci&#039;, &#039;BCI2000Remote_Delete&#039;, bciHandle); % call BCI2000Remote_Delete to recovery the memory&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
% Startup BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Change directory $BCI2000LAUNCHDIR&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Show window; Set title ${Extract file base $0}&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Reset system&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Add new states, events, or parameters before starting up the system. Note that it is greatly preferred to use events instead of states because of timing precision.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Create new parameter (must be done before startup)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Add Parameter Application:TestParameterField string TestParameter= FirstNewParameter % % %&#039;, 0); &lt;br /&gt;
&lt;br /&gt;
% Define events&lt;br /&gt;
% Define new event with 2 bytes of information (2 colors)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;add event Square 1 0&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add in the proper modules (Signal Generator, Signal Processor, and Application). Refer to the documentation [[Technical_Reference:BCI2000Remote_Library]] for more information on BCI2000 remote functions. Also refer to the example Matlab code under [[Programming_Reference:BCI2000Remote_Class#Matlab_Example]].&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Startup system localhost&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Startup system localhost&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Establish connection to three modules&lt;br /&gt;
SourceModule = &#039;SignalGenerator&#039;;&lt;br /&gt;
modules      = libpointer(&#039;stringPtrPtr&#039;, {[SourceModule &#039; --local --LogKeyboard=1&#039;], &#039;DummySignalProcessing&#039;, &#039;DummyApplication&#039;});&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_StartupModules2&#039;, bciHandle, modules, 3);&lt;br /&gt;
&lt;br /&gt;
% Wait for connected before loading parameters!&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Connected&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Load parameter files, modify parameters directly, and add watches after BCI2000 is connected. It can also be helpful to wait for bci2000 to start running (collecting data) before proceeding.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Load parameter files&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_LoadParametersRemote&#039;, bciHandle, fullfile(BCI2000root,&#039;parms&#039;,&#039;fragments&#039;,&#039;amplifiers&#039;,&#039;SignalGenerator.prm&#039;));&lt;br /&gt;
&lt;br /&gt;
% Set parameter values&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetDataDirectory&#039;, bciHandle, fullfile(BCI2000root,&#039;data&#039;,&#039;BJH&#039;));&lt;br /&gt;
&lt;br /&gt;
%Set watches to appear automatically&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;visualize watch Square&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Wait for BCI2000 to start running before starting application&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; While BCI2000 is running you can also get and set event and state values, and also get parameter values. Note that you cannot modify parameter values while BCI2000 is running. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Get parameter value&lt;br /&gt;
SamplingRate = calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetParameter&#039;, bciHandle, &#039;SamplingRate&#039;);&lt;br /&gt;
fprintf([&#039;\nSamplingRate: &#039; num2str(SamplingRate) &#039;Hz\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Get event value&lt;br /&gt;
[~,~,~,Square]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetEventVariable&#039;, bciHandle, &#039;Square&#039;, 0.0);&lt;br /&gt;
&lt;br /&gt;
% BCI2000 set white rectangle to 1 (true)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Set event Square 1&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Get state value&lt;br /&gt;
% Immediately after data block has been acquired from hardware, the &lt;br /&gt;
% DataIOFilter writes a 16-bit millisecond-resolution time stamp into the &lt;br /&gt;
% SourceTime state. Block duration is measured as the difference between&lt;br /&gt;
% two consecutive time stamps.&lt;br /&gt;
[~,~,~,SourceTime]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetStateVariable&#039;, bciHandle, &#039;SourceTime&#039;, 0.0);&lt;br /&gt;
fprintf([&#039;\nSourceTime: &#039;, num2str(SourceTime), &#039;\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Stop running BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetStateVariable&#039;, bciHandle, &#039;Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=ZwLcovHZabw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11523</id>
		<title>User Tutorial:BCI2000Remote</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11523"/>
		<updated>2024-08-15T22:05:46Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* MatlabTutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends Operator Scripting commands to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the BCI2000RemoteLib library exist, such as Python, or MATLAB.&lt;br /&gt;
==Note==&lt;br /&gt;
BCI2000Remote is a means of interfacing with the BCI2000 Operator module meaning that there are potentially hundreds of ways we leverage this tool to have a meaningful interface with BCI2000. Because of this we will illustrate a few different integrations using different languages. This &amp;quot;How-to&amp;quot; will be separated into three separate sections: Python, C++, and Matlab.&lt;br /&gt;
==Python Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Find your Python folder. If you have an existing Python environment with your code find it using the Sys Library like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
locate_python = sys.exec_prefix&lt;br /&gt;
print(locate_python)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Locate your BCI2000Remote.py file which should have compiled into your prog folder. &lt;br /&gt;
Find where in your Python code you wish to integrate BCI2000. In this example I will show the minimum requirements for integration with BCI2000:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append(&#039;C:\\BCI2000.x64\\prog&#039;)&lt;br /&gt;
import BCI2000Remote&lt;br /&gt;
bci = BCI2000Remote.BCI2000Remote()&lt;br /&gt;
print(&#039;Operator path:&#039;, bci.OperatorPath)&lt;br /&gt;
bci.WindowVisible = True&lt;br /&gt;
bci.WindowTitle = &#039;Python controlled&#039;&lt;br /&gt;
bci.SubjectID = &#039;pysub&#039;&lt;br /&gt;
bci.Connect()&lt;br /&gt;
bci.Execute(&#039;cd ${BCI2000LAUNCHDIR}&#039;)&lt;br /&gt;
bci.Execute(&#039;ADD STATE score 16 0&#039;)&lt;br /&gt;
bci.StartupModules((&#039;SignalGenerator&#039;, &#039;DummySignalprocessing&#039;, &#039;DummyApplication&#039;))&lt;br /&gt;
bci.Execute(&#039;Wait for Connected&#039;)&lt;br /&gt;
bci.LoadParametersRemote(&#039;../parms/fragments/amplifiers/amplifier.prm&#039;)&lt;br /&gt;
bci.SetConfig()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is how you import BCI2000Remote:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you instantiate the operator object:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote 2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how to customize the operator and connect to it:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCI2000Remote2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you add your states:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_4.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to specify your signal source, signal processing, and application modules:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_5.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to load a parameter file(you can learn more about parameters [[Technical_Reference:Parameter_File|here]]):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_55.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to connect and issue commands to BCI2000:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And finally, how to tell BCI2000 to set states to a value during runtime:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is run your code. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
[[File:BCIRemote_7.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C++ Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the C++ file or solution you would like to integrate with BCI2000 in Visual Studio, and find where it is located on your computer.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to the program&#039;s properties, and make the following changes:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; General, add the following folders from BCI2000 (64-bit)&#039;s src folder: &amp;lt;i&amp;gt; \core\Operator\BCI2000Remote, \shared\utils\Lib, \shared\config. &amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to Configuration Properties -&amp;gt; Linker -&amp;gt; Input, and add &amp;lt;i&amp;gt; ws2_32.lib &amp;lt;/i&amp;gt; to Additional Dependencies.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; Advanced, add &amp;lt;i&amp;gt;4996&amp;lt;/i&amp;gt; to the Disable Specific Warnings section.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add your Operator executable and the BCI2000RemoteLib dynamic library to the same directory as the program you intend to integrate. This can be found in the prog folder.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Also, add the following files to the directory with your program and &amp;lt;i&amp;gt;Operator.exe&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Make sure that you include all of your dependencies including BCI2000Remote.h &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Next, instantiate the BCI2000Remote object&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Specify your startup modules and any flags you wish to start them with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Load any parameter files and set subject information&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And here we just have BCI2000 send us back a feedback signal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is compile and run it. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; Be sure to compile this in your prog folder. This can be done by navigating again to Configuration Properties -&amp;gt; General, and changing the Output Directory to the path of the BCI2000 prog folder.&lt;br /&gt;
[[File:BCIRemote_7.jpg]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Load a parameter file, and set subject information&lt;br /&gt;
  bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Print feedback signal&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==MatlabTutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the Matlab file you would like to integrate with BCI2000.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Locate the BCI2000RemoteLib file in the BCI2000 prog folder, and BCI2000RemoteLib.h in src\core\Operator\BCI2000Remote, and load these into the Matlab file. Modify the file paths in &amp;lt;i&amp;gt;loadlibrary(...)&amp;lt;/i&amp;gt; as needed. &lt;br /&gt;
Note that BCI2000RemoteLib&#039;s file name has a &amp;quot;64&amp;quot; appended when it was built in 64 bit mode, and a &amp;quot;32&amp;quot; if built iin 32 bit mode.&lt;br /&gt;
In this tutorial, we will be using the 64 bit version.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%% c library load, initial part&lt;br /&gt;
BCI2000root = &#039;C:\bci2000.x64&#039;;&lt;br /&gt;
if not(libisloaded(&#039;bci&#039;))&lt;br /&gt;
    loadlibrary(fullfile(BCI2000root,&#039;prog&#039;,&#039;BCI2000RemoteLib64&#039;),...&lt;br /&gt;
        fullfile(BCI2000root,&#039;src&#039;,&#039;core&#039;,&#039;Operator&#039;,&#039;BCI2000Remote&#039;,&#039;BCI2000RemoteLib.h&#039;), &#039;alias&#039;, &#039;bci&#039;)&lt;br /&gt;
end &lt;br /&gt;
libfunctions(&#039;bci&#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Locate Operator.exe in the prog folder. Recover the memory, change the directory, and make the window visible in BCI2000. Again, modify the file path if it differs. &lt;br /&gt;
&amp;lt;pre&amp;gt;%need to call BCI2000Remote_Delete to recover the memory&lt;br /&gt;
bciHandle = calllib(&#039;bci&#039;, &#039;BCI2000Remote_New&#039;);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetOperatorPath&#039;, bciHandle, fullfile(BCI2000root,&#039;prog&#039;,&#039;Operator&#039;));&lt;br /&gt;
&lt;br /&gt;
% if we fail cto establish a connection to BCI2000Remote&lt;br /&gt;
if calllib(&#039;bci&#039;, &#039;BCI2000Remote_Connect&#039;, bciHandle) ~= 1&lt;br /&gt;
    fprintf(&#039;bci connect fail!&#039;)&lt;br /&gt;
    calllib(&#039;bci&#039;, &#039;BCI2000Remote_Delete&#039;, bciHandle); % call BCI2000Remote_Delete to recovery the memory&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
% Startup BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Change directory $BCI2000LAUNCHDIR&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Show window; Set title ${Extract file base $0}&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Reset system&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Add new states, events, or parameters before starting up the system. Note that it is greatly preferred to use events instead of states because of timing precision.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Create new parameter (must be done before startup)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Add Parameter Application:TestParameterField string TestParameter= FirstNewParameter % % %&#039;, 0); &lt;br /&gt;
&lt;br /&gt;
% Define events&lt;br /&gt;
% Define new event with 2 bytes of information (2 colors)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;add event Square 1 0&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add in the proper modules (Signal Generator, Signal Processor, and Application). Refer to the documentation [[Technical_Reference:BCI2000Remote_Library]] for more information on BCI2000 remote functions. Also refer to the example Matlab code under [[Programming_Reference:BCI2000Remote_Class#Matlab_Example]].&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Startup system localhost&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Startup system localhost&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Establish connection to three modules&lt;br /&gt;
SourceModule = &#039;SignalGenerator&#039;;&lt;br /&gt;
modules      = libpointer(&#039;stringPtrPtr&#039;, {[SourceModule &#039; --local --LogKeyboard=1&#039;], &#039;DummySignalProcessing&#039;, &#039;DummyApplication&#039;});&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_StartupModules2&#039;, bciHandle, modules, 3);&lt;br /&gt;
&lt;br /&gt;
% Wait for connected before loading parameters!&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Connected&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Load parameter files, modify parameters directly, and add watches after BCI2000 is connected. It can also be helpful to wait for bci2000 to start running (collecting data) before proceeding.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Load parameter files&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_LoadParametersRemote&#039;, bciHandle, fullfile(BCI2000root,&#039;parms&#039;,&#039;fragments&#039;,&#039;amplifiers&#039;,&#039;SignalGenerator.prm&#039;));&lt;br /&gt;
&lt;br /&gt;
% Set parameter values&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetDataDirectory&#039;, bciHandle, fullfile(BCI2000root,&#039;data&#039;,&#039;BJH&#039;));&lt;br /&gt;
&lt;br /&gt;
%Set watches to appear automatically&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;visualize watch Square&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Wait for BCI2000 to start running before starting application&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; While BCI2000 is running you can also get and set event and state values, and also get parameter values. Note that you cannot modify parameter values while BCI2000 is running. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Get parameter value&lt;br /&gt;
SamplingRate = calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetParameter&#039;, bciHandle, &#039;SamplingRate&#039;);&lt;br /&gt;
fprintf([&#039;\nSamplingRate: &#039; num2str(SamplingRate) &#039;Hz\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Get event value&lt;br /&gt;
[~,~,~,KeyDown]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetEventVariable&#039;, bciHandle, &#039;KeyDown&#039;, passKeyDown);&lt;br /&gt;
&lt;br /&gt;
% BCI2000 set white rectangle to 1 (true)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Set event Square 1&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Get state value&lt;br /&gt;
% Immediately after data block has been acquired from hardware, the &lt;br /&gt;
% DataIOFilter writes a 16-bit millisecond-resolution time stamp into the &lt;br /&gt;
% SourceTime state. Block duration is measured as the difference between&lt;br /&gt;
% two consecutive time stamps.&lt;br /&gt;
[~,~,~,SourceTime]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetStateVariable&#039;, bciHandle, &#039;SourceTime&#039;, passSourceTime);&lt;br /&gt;
fprintf([&#039;\nSourceTime: &#039;, num2str(SourceTime), &#039;\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Stop running BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetStateVariable&#039;, bciHandle, &#039;Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=ZwLcovHZabw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11522</id>
		<title>User Tutorial:BCI2000Remote</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11522"/>
		<updated>2024-08-15T21:58:55Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* MatlabTutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends Operator Scripting commands to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the BCI2000RemoteLib library exist, such as Python, or MATLAB.&lt;br /&gt;
==Note==&lt;br /&gt;
BCI2000Remote is a means of interfacing with the BCI2000 Operator module meaning that there are potentially hundreds of ways we leverage this tool to have a meaningful interface with BCI2000. Because of this we will illustrate a few different integrations using different languages. This &amp;quot;How-to&amp;quot; will be separated into three separate sections: Python, C++, and Matlab.&lt;br /&gt;
==Python Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Find your Python folder. If you have an existing Python environment with your code find it using the Sys Library like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
locate_python = sys.exec_prefix&lt;br /&gt;
print(locate_python)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Locate your BCI2000Remote.py file which should have compiled into your prog folder. &lt;br /&gt;
Find where in your Python code you wish to integrate BCI2000. In this example I will show the minimum requirements for integration with BCI2000:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append(&#039;C:\\BCI2000.x64\\prog&#039;)&lt;br /&gt;
import BCI2000Remote&lt;br /&gt;
bci = BCI2000Remote.BCI2000Remote()&lt;br /&gt;
print(&#039;Operator path:&#039;, bci.OperatorPath)&lt;br /&gt;
bci.WindowVisible = True&lt;br /&gt;
bci.WindowTitle = &#039;Python controlled&#039;&lt;br /&gt;
bci.SubjectID = &#039;pysub&#039;&lt;br /&gt;
bci.Connect()&lt;br /&gt;
bci.Execute(&#039;cd ${BCI2000LAUNCHDIR}&#039;)&lt;br /&gt;
bci.Execute(&#039;ADD STATE score 16 0&#039;)&lt;br /&gt;
bci.StartupModules((&#039;SignalGenerator&#039;, &#039;DummySignalprocessing&#039;, &#039;DummyApplication&#039;))&lt;br /&gt;
bci.Execute(&#039;Wait for Connected&#039;)&lt;br /&gt;
bci.LoadParametersRemote(&#039;../parms/fragments/amplifiers/amplifier.prm&#039;)&lt;br /&gt;
bci.SetConfig()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is how you import BCI2000Remote:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you instantiate the operator object:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote 2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how to customize the operator and connect to it:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCI2000Remote2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you add your states:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_4.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to specify your signal source, signal processing, and application modules:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_5.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to load a parameter file(you can learn more about parameters [[Technical_Reference:Parameter_File|here]]):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_55.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to connect and issue commands to BCI2000:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And finally, how to tell BCI2000 to set states to a value during runtime:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is run your code. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
[[File:BCIRemote_7.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C++ Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the C++ file or solution you would like to integrate with BCI2000 in Visual Studio, and find where it is located on your computer.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to the program&#039;s properties, and make the following changes:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; General, add the following folders from BCI2000 (64-bit)&#039;s src folder: &amp;lt;i&amp;gt; \core\Operator\BCI2000Remote, \shared\utils\Lib, \shared\config. &amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to Configuration Properties -&amp;gt; Linker -&amp;gt; Input, and add &amp;lt;i&amp;gt; ws2_32.lib &amp;lt;/i&amp;gt; to Additional Dependencies.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; Advanced, add &amp;lt;i&amp;gt;4996&amp;lt;/i&amp;gt; to the Disable Specific Warnings section.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add your Operator executable and the BCI2000RemoteLib dynamic library to the same directory as the program you intend to integrate. This can be found in the prog folder.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Also, add the following files to the directory with your program and &amp;lt;i&amp;gt;Operator.exe&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Make sure that you include all of your dependencies including BCI2000Remote.h &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Next, instantiate the BCI2000Remote object&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Specify your startup modules and any flags you wish to start them with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Load any parameter files and set subject information&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And here we just have BCI2000 send us back a feedback signal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is compile and run it. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; Be sure to compile this in your prog folder. This can be done by navigating again to Configuration Properties -&amp;gt; General, and changing the Output Directory to the path of the BCI2000 prog folder.&lt;br /&gt;
[[File:BCIRemote_7.jpg]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Load a parameter file, and set subject information&lt;br /&gt;
  bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Print feedback signal&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==MatlabTutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the Matlab file you would like to integrate with BCI2000.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Locate the BCI2000RemoteLib file in the BCI2000 prog folder, and BCI2000RemoteLib.h in src\core\Operator\BCI2000Remote, and load these into the Matlab file. Modify the file paths in &amp;lt;i&amp;gt;loadlibrary(...)&amp;lt;/i&amp;gt; as needed. &lt;br /&gt;
Note that BCI2000RemoteLib&#039;s file name has a &amp;quot;64&amp;quot; appended when it was built in 64 bit mode, and a &amp;quot;32&amp;quot; if built iin 32 bit mode.&lt;br /&gt;
In this tutorial, we will be using the 64 bit version.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%% c library load, initial part&lt;br /&gt;
BCI2000root = &#039;C:\bci2000.x64&#039;;&lt;br /&gt;
if not(libisloaded(&#039;bci&#039;))&lt;br /&gt;
    loadlibrary(fullfile(BCI2000root,&#039;prog&#039;,&#039;BCI2000RemoteLib64&#039;),...&lt;br /&gt;
        fullfile(BCI2000root,&#039;src&#039;,&#039;core&#039;,&#039;Operator&#039;,&#039;BCI2000Remote&#039;,&#039;BCI2000RemoteLib.h&#039;), &#039;alias&#039;, &#039;bci&#039;)&lt;br /&gt;
end &lt;br /&gt;
libfunctions(&#039;bci&#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Locate Operator.exe in the prog folder. Recover the memory, change the directory, and make the window visible in BCI2000. Again, modify the file path if it differs. &lt;br /&gt;
&amp;lt;pre&amp;gt;%need to call BCI2000Remote_Delete to recover the memory&lt;br /&gt;
bciHandle = calllib(&#039;bci&#039;, &#039;BCI2000Remote_New&#039;);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetOperatorPath&#039;, bciHandle, fullfile(BCI2000root,&#039;prog&#039;,&#039;Operator&#039;));&lt;br /&gt;
&lt;br /&gt;
% if we fail cto establish a connection to BCI2000Remote&lt;br /&gt;
if calllib(&#039;bci&#039;, &#039;BCI2000Remote_Connect&#039;, bciHandle) ~= 1&lt;br /&gt;
    fprintf(&#039;bci connect fail!&#039;)&lt;br /&gt;
    calllib(&#039;bci&#039;, &#039;BCI2000Remote_Delete&#039;, bciHandle); % call BCI2000Remote_Delete to recovery the memory&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
% Startup BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Change directory $BCI2000LAUNCHDIR&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Show window; Set title ${Extract file base $0}&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Reset system&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Add new states, events, or parameters before starting up the system. Note that it is greatly preferred to use events instead of states because of timing precision.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Create new parameter (must be done before startup)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Add Parameter Application:TestParameterField string TestParameter= FirstNewParameter % % %&#039;, 0); &lt;br /&gt;
&lt;br /&gt;
% Define events&lt;br /&gt;
% Define new event with 2 bytes of information (2 colors)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;add event Square 1 0&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add in the proper modules (Signal Generator, Signal Processor, and Application). Refer to the documentation [[Technical_Reference:BCI2000Remote_Library]] for more information on BCI2000 remote functions. Also refer to the example Matlab code under [[Programming_Reference:BCI2000Remote_Class#Matlab_Example]].&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Startup system localhost&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Startup system localhost&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Establish connection to three modules&lt;br /&gt;
SourceModule = &#039;SignalGenerator&#039;;&lt;br /&gt;
modules      = libpointer(&#039;stringPtrPtr&#039;, {[SourceModule &#039; --local --LogKeyboard=1&#039;], &#039;DummySignalProcessing&#039;, &#039;DummyApplication&#039;});&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_StartupModules2&#039;, bciHandle, modules, 3);&lt;br /&gt;
&lt;br /&gt;
% Wait for connected before loading parameters!&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Connected&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Load parameter files, modify parameters directly, and add watches after BCI2000 is connected. It can also be helpful to wait for bci2000 to start running (collecting data) before proceeding.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Load parameter files&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_LoadParametersRemote&#039;, bciHandle, fullfile(BCI2000root,&#039;parms&#039;,&#039;fragments&#039;,&#039;amplifiers&#039;,&#039;SignalGenerator.prm&#039;));&lt;br /&gt;
&lt;br /&gt;
% Set parameter values&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetDataDirectory&#039;, bciHandle, fullfile(BCI2000root,&#039;data&#039;,&#039;BJH&#039;));&lt;br /&gt;
&lt;br /&gt;
%Set watches to appear automatically&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;visualize watch Square&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Wait for BCI2000 to start running before starting application&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; While BCI2000 is running you can also get and set event and state values, and also get parameter values. Note that you cannot modify parameter values while BCI2000 is running. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Get parameter value&lt;br /&gt;
SamplingRate = calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetParameter&#039;, bciHandle, &#039;SamplingRate&#039;);&lt;br /&gt;
fprintf([&#039;\nSamplingRate: &#039; num2str(SamplingRate) &#039;Hz\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Get event value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
% BCI2000 set white rectangle to 1 (true)&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Set event Square 1&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Get state value&lt;br /&gt;
% Immediately after data block has been acquired from hardware, the &lt;br /&gt;
% DataIOFilter writes a 16-bit millisecond-resolution time stamp into the &lt;br /&gt;
% SourceTime state. Block duration is measured as the difference between&lt;br /&gt;
% two consecutive time stamps.&lt;br /&gt;
[~,~,~,SourceTime]=calllib(&#039;bci&#039;, &#039;BCI2000Remote_GetStateVariable&#039;, bciHandle, &#039;SourceTime&#039;, passSourceTime);&lt;br /&gt;
fprintf([&#039;\nSourceTime: &#039;, num2str(SourceTime), &#039;\n&#039;])&lt;br /&gt;
&lt;br /&gt;
% Stop running BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetStateVariable&#039;, bciHandle, &#039;Running&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=ZwLcovHZabw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11521</id>
		<title>User Tutorial:BCI2000Remote</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Tutorial:BCI2000Remote&amp;diff=11521"/>
		<updated>2024-08-15T21:44:46Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* MatlabTutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends Operator Scripting commands to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the BCI2000RemoteLib library exist, such as Python, or MATLAB.&lt;br /&gt;
==Note==&lt;br /&gt;
BCI2000Remote is a means of interfacing with the BCI2000 Operator module meaning that there are potentially hundreds of ways we leverage this tool to have a meaningful interface with BCI2000. Because of this we will illustrate a few different integrations using different languages. This &amp;quot;How-to&amp;quot; will be separated into three separate sections: Python, C++, and Matlab.&lt;br /&gt;
==Python Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Find your Python folder. If you have an existing Python environment with your code find it using the Sys Library like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
locate_python = sys.exec_prefix&lt;br /&gt;
print(locate_python)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Locate your BCI2000Remote.py file which should have compiled into your prog folder. &lt;br /&gt;
Find where in your Python code you wish to integrate BCI2000. In this example I will show the minimum requirements for integration with BCI2000:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append(&#039;C:\\BCI2000.x64\\prog&#039;)&lt;br /&gt;
import BCI2000Remote&lt;br /&gt;
bci = BCI2000Remote.BCI2000Remote()&lt;br /&gt;
print(&#039;Operator path:&#039;, bci.OperatorPath)&lt;br /&gt;
bci.WindowVisible = True&lt;br /&gt;
bci.WindowTitle = &#039;Python controlled&#039;&lt;br /&gt;
bci.SubjectID = &#039;pysub&#039;&lt;br /&gt;
bci.Connect()&lt;br /&gt;
bci.Execute(&#039;cd ${BCI2000LAUNCHDIR}&#039;)&lt;br /&gt;
bci.Execute(&#039;ADD STATE score 16 0&#039;)&lt;br /&gt;
bci.StartupModules((&#039;SignalGenerator&#039;, &#039;DummySignalprocessing&#039;, &#039;DummyApplication&#039;))&lt;br /&gt;
bci.Execute(&#039;Wait for Connected&#039;)&lt;br /&gt;
bci.LoadParametersRemote(&#039;../parms/fragments/amplifiers/amplifier.prm&#039;)&lt;br /&gt;
bci.SetConfig()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is how you import BCI2000Remote:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you instantiate the operator object:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote 2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how to customize the operator and connect to it:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCI2000Remote2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is how you add your states:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_4.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to specify your signal source, signal processing, and application modules:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_5.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to load a parameter file(you can learn more about parameters [[Technical_Reference:Parameter_File|here]]):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_55.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
How to connect and issue commands to BCI2000:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And finally, how to tell BCI2000 to set states to a value during runtime:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:BCIRemote_6.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is run your code. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
[[File:BCIRemote_7.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C++ Tutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Open the C++ file or solution you would like to integrate with BCI2000 in Visual Studio, and find where it is located on your computer.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to the program&#039;s properties, and make the following changes:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; General, add the following folders from BCI2000 (64-bit)&#039;s src folder: &amp;lt;i&amp;gt; \core\Operator\BCI2000Remote, \shared\utils\Lib, \shared\config. &amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Navigate to Configuration Properties -&amp;gt; Linker -&amp;gt; Input, and add &amp;lt;i&amp;gt; ws2_32.lib &amp;lt;/i&amp;gt; to Additional Dependencies.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Under Configuration Properties -&amp;gt; C++ -&amp;gt; Advanced, add &amp;lt;i&amp;gt;4996&amp;lt;/i&amp;gt; to the Disable Specific Warnings section.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Add your Operator executable and the BCI2000RemoteLib dynamic library to the same directory as the program you intend to integrate. This can be found in the prog folder.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Also, add the following files to the directory with your program and &amp;lt;i&amp;gt;Operator.exe&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Connection.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000Remote.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
BCI2000RemoteLib.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
SelfPipe.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.cpp&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
sockstream.h&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Make sure that you include all of your dependencies including BCI2000Remote.h &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Next, instantiate the BCI2000Remote object&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Specify your startup modules and any flags you wish to start them with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Load any parameter files and set subject information&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
And here we just have BCI2000 send us back a feedback signal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Now that you&#039;ve added those components to your code all you have to do is compile and run it. You should see the BCI2000 operator along with the system log, source watcher, and the timing window.&lt;br /&gt;
&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; Be sure to compile this in your prog folder. This can be done by navigating again to Configuration Properties -&amp;gt; General, and changing the Output Directory to the path of the BCI2000 prog folder.&lt;br /&gt;
[[File:BCIRemote_7.jpg]]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;BCI2000Remote.h&amp;quot;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
  // Instantiate a BCI2000Remote object&lt;br /&gt;
  BCI2000Remote bci;&lt;br /&gt;
  // Assume that Operator executable resides in the same directory as this program.&lt;br /&gt;
  std::string path = ( argc &amp;gt; 0 ) ? argv[0] : &amp;quot;&amp;quot;;&lt;br /&gt;
  size_t pos = path.find_last_of( &amp;quot;\\/&amp;quot; );&lt;br /&gt;
  path = ( pos != std::string::npos ) ? path.substr( 0, pos + 1 ) : &amp;quot;&amp;quot;;&lt;br /&gt;
  // Start the Operator module, and connect&lt;br /&gt;
  bci.OperatorPath( path + &amp;quot;Operator&amp;quot; );&lt;br /&gt;
  if( !bci.Connect() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Startup modules&lt;br /&gt;
  const char* modules[] = { &amp;quot;SignalGenerator --LogMouse=1&amp;quot;, &amp;quot;ARSignalProcessing&amp;quot;, &amp;quot;CursorTask&amp;quot; };&lt;br /&gt;
  std::vector&amp;lt;std::string&amp;gt; vModules( &amp;amp;modules[0], &amp;amp;modules[0] + sizeof( modules ) / sizeof( *modules ) );&lt;br /&gt;
  if( !bci.StartupModules( vModules ) )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Load a parameter file, and set subject information&lt;br /&gt;
  bci.LoadParametersRemote( &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot; );&lt;br /&gt;
  bci.SubjectID( &amp;quot;SUB&amp;quot; );&lt;br /&gt;
  // Start a run&lt;br /&gt;
  if( !bci.Start() )&lt;br /&gt;
  {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; bci.Result();&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  // Print feedback signal&lt;br /&gt;
  std::string state;&lt;br /&gt;
  while( bci.GetSystemState( state ) &amp;amp;&amp;amp; state == &amp;quot;Running&amp;quot; )&lt;br /&gt;
  {&lt;br /&gt;
    double value = 0;&lt;br /&gt;
    bci.GetControlSignal( 1, 1, value );&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Control signal: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; &amp;quot;, press Enter to proceed&amp;quot; &amp;lt;&amp;lt; std::flush;&lt;br /&gt;
    std::string line;&lt;br /&gt;
    std::getline( std::cin, line );&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==MatlabTutorial==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Open the Matlab file you would like to integrate with BCI2000.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Locate the BCI2000RemoteLib file in the BCI2000 prog folder, and BCI2000RemoteLib.h in src\core\Operator\BCI2000Remote, and load these into the Matlab file. Modify the file paths in &amp;lt;i&amp;gt;loadlibrary(...)&amp;lt;/i&amp;gt; as needed. &lt;br /&gt;
Note that BCI2000RemoteLib&#039;s file name has a &amp;quot;64&amp;quot; appended when it was built in 64 bit mode, and a &amp;quot;32&amp;quot; if built iin 32 bit mode.&lt;br /&gt;
In this tutorial, we will be using the 64 bit version.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%% c library load, initial part&lt;br /&gt;
BCI2000root = &#039;C:\bci2000.x64&#039;;&lt;br /&gt;
if not(libisloaded(&#039;bci&#039;))&lt;br /&gt;
    loadlibrary(fullfile(BCI2000root,&#039;prog&#039;,&#039;BCI2000RemoteLib64&#039;),...&lt;br /&gt;
        fullfile(BCI2000root,&#039;src&#039;,&#039;core&#039;,&#039;Operator&#039;,&#039;BCI2000Remote&#039;,&#039;BCI2000RemoteLib.h&#039;), &#039;alias&#039;, &#039;bci&#039;)&lt;br /&gt;
end &lt;br /&gt;
libfunctions(&#039;bci&#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Locate Operator.exe in the prog folder. Recover the memory, change the directory, and make the window visible in BCI2000. Again, modify the file path if it differs. &lt;br /&gt;
&amp;lt;pre&amp;gt;%need to call BCI2000Remote_Delete to recover the memory&lt;br /&gt;
bciHandle = calllib(&#039;bci&#039;, &#039;BCI2000Remote_New&#039;);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_SetOperatorPath&#039;, bciHandle, fullfile(BCI2000root,&#039;prog&#039;,&#039;Operator&#039;));&lt;br /&gt;
&lt;br /&gt;
% if we fail cto establish a connection to BCI2000Remote&lt;br /&gt;
if calllib(&#039;bci&#039;, &#039;BCI2000Remote_Connect&#039;, bciHandle) ~= 1&lt;br /&gt;
    fprintf(&#039;bci connect fail!&#039;)&lt;br /&gt;
    calllib(&#039;bci&#039;, &#039;BCI2000Remote_Delete&#039;, bciHandle); % call BCI2000Remote_Delete to recovery the memory&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
% Startup BCI2000&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Change directory $BCI2000LAUNCHDIR&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Show window; Set title ${Extract file base $0}&#039;, 0);&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Reset system&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add in the proper modules (Signal Generator, Signal Processor, and Application). Also, load in BCI2000 parameters, add/set state variables, and include any desired functionality. Refer to the documentation [[Technical_Reference:BCI2000Remote_Library]] for more information on BCI2000 remote functions. Also refer to the example Matlab code under [[Programming_Reference:BCI2000Remote_Class#Matlab_Example]].&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% Startup system localhost&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle,&#039;Startup system localhost&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
% Establish connection to three modules&lt;br /&gt;
SourceModule = &#039;SignalGenerator&#039;;&lt;br /&gt;
modules      = libpointer(&#039;stringPtrPtr&#039;, {[SourceModule &#039; --local --LogKeyboard=1&#039;], &#039;DummySignalProcessing&#039;, &#039;DummyApplication&#039;});&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_StartupModules2&#039;, bciHandle, modules, 3);&lt;br /&gt;
&lt;br /&gt;
% Wait for connected before loading parameters!&lt;br /&gt;
calllib(&#039;bci&#039;, &#039;BCI2000Remote_Execute&#039;, bciHandle, &#039;Wait for Connected&#039;, 0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&amp;lt;youtube alignment=&amp;quot;center&amp;quot;&amp;gt;https://www.youtube.com/watch?v=ZwLcovHZabw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also see the [https://bci2000.org/mediawiki/index.php/PsychoPy PsychoPy] page for more details on the installation process, APIs, and hooks.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Programming Reference:BCI2000Remote Class]]&lt;br /&gt;
* [[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:NatusADC&amp;diff=11323</id>
		<title>Contributions:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:NatusADC&amp;diff=11323"/>
		<updated>2024-05-10T17:31:35Z</updated>

		<summary type="html">&lt;p&gt;Swiftj: /* On the BCI2000 Computer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Function  ==&lt;br /&gt;
The NatusADC filter acquires raw data in real-time from Natus Headboxes over UDP connection for signal processing and visualizations. The overview of the NatusADC working is shown in the image below.&lt;br /&gt;
[[File:Prog_Ref_NatusADC_NatusWorking.png|center|800px|Overview of NatusADC working]]&lt;br /&gt;
&lt;br /&gt;
NatusDataServer processes and sends signal from the device to the client application. A project named XLDataExportClient reads signals from the device and calls the NatusDataServer&#039;s functions to send the signal to the client. NatusClient is the client application within the BCI2000 that receives the signals and does the initial processing. NatusPackageInterface contains the implementation of data transfer protocol between server/device and client and is used by NatusClient and NatusDataServer to communicate with each other over TCP and UDP. NatusDataServer and NatusPackageInterface are independent of BCI2000, whereas NatusClient relies on BCI2000. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The below image explains the context in which packet, blocks, samples and channels are used in this project. A packet may have one or block, a block may have one or more samples and a sample contains values for all the channels.&lt;br /&gt;
[[File:NatusPacketImage.png|center|600px|Packet, block and samples relationship]]  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: 5900&lt;br /&gt;
*Tested under: 7381&lt;br /&gt;
*Known to compile under:7381&lt;br /&gt;
*Broken since: --&lt;br /&gt;
*Natus software version: 9.2.1 Build 6524&lt;br /&gt;
*Natus Data Export Version: 9.4&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
* The NatusADC source module requires a proprietary SDK protected by an NDA with Natus. Please contact Natus for this NDA and for access to the XLDataExportClient SDK before attempting to use the NatusADC source module.&lt;br /&gt;
* It is also helpful to have an ethernet port available for the Natus computer. If your system does not have an ethernet port, consider using a USB ethernet dongle.&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
In theory, the module should work fine with all of the following Natus Headboxes. &lt;br /&gt;
# EEG32&lt;br /&gt;
# EEG128, EEG128FS&lt;br /&gt;
# Mobee32, Mobee32-02&lt;br /&gt;
# Mobee-24&lt;br /&gt;
# Connex/ Brain Monitor&lt;br /&gt;
# Trex&lt;br /&gt;
# EMU40&lt;br /&gt;
# EEG32u&lt;br /&gt;
# Quantum&lt;br /&gt;
# NeuroLink IP&lt;br /&gt;
# Bio-logic NetLink&lt;br /&gt;
# Bio-logic Traveler&lt;br /&gt;
&lt;br /&gt;
==== Drivers ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Connecting Natus to BCI2000 ==&lt;br /&gt;
The figure below should serve as a supplement to the instructions for connecting the Natus computer to the BCI2000 computer&lt;br /&gt;
[[File:NW_SDK_for_BCI2000.png|center|1000px|Neuroworks SDK for BCI2000]]&lt;br /&gt;
&lt;br /&gt;
=== On the Natus Computer ===&lt;br /&gt;
# Connect the BCI2000 computer to the Natus computer via ethernet (this may require a usb-to-ethernet adapter)&lt;br /&gt;
# Change the IP address of this port on the Natus computer to something on its own subnet, like 192.168.10.10. You can follow a tutorial like [https://nordvpn.com/blog/how-to-change-your-ip-address/ this one] to change the IP address. The easiest way to confirm that you are changing the IP address of the correct port is to unplug the ethernet cable. The unplugged option will disappear.&lt;br /&gt;
# When starting a new study, set the sampling rate of the acquisition system by opening &amp;quot;Wave&amp;quot; and going to edit -&amp;gt; settings -&amp;gt; acquisition while a study is NOT running&lt;br /&gt;
#* Be sure that the Natus computer is set to acquire data over Ethernet and not USB if you intend to acquire data over 4kHz [[File:Natus1_StudySettings.jpg|center|600px|Set Natus Sampling Rate]]&lt;br /&gt;
# Start an EEG study in Neuroworks using the New EEG button. [[File:Natus2_StartStudy.jpg|center|1000px|Start a new Natus study]] You will need to enter the study information. [[File:Natus3_StudyInformation.jpg|center|600px|Enter the study information]] Note that you do not need to start the recording for the signal to stream to BCI2000. [[File:Natus4_StudyRunning.jpg|center|1000px|Study is running]]&lt;br /&gt;
&lt;br /&gt;
=== On the BCI2000 Computer ===&lt;br /&gt;
# Compile the NatusSignalSource source module after you have gotten access to the Natus data export service on the BCI2000 svn&lt;br /&gt;
# Change the IP address of the BCI2000 computer ethernet port to something on the same subnet, like 192.168.10.9, following the same steps as above.&lt;br /&gt;
# Open the command line on the BCI2000 computer and type &amp;quot;ping 192.168.10.10&amp;quot; to ensure you have a connection.&lt;br /&gt;
#* Note that if this does not work you may need to turn off firewalls on one or both machines&lt;br /&gt;
# Locate the included registry editing tool found in bci2000/src/private/SignalSource/NatusSignalSource/&lt;br /&gt;
# Edit the _SetSdkAcquisitionStationIp.reg registry editing tool (right-click, edit) to add the IP of the Natus computer to the BCI2000 computer&#039;s registry (i.e., 192.168.10.10)&lt;br /&gt;
# Run RegXLDataExportService.bat found in bci2000/src/private/SignalSource/NatusSignalSource/DataExport_9.4/XLDataExportService to register the DLL of the data export service. (This may not be necessary with the newest version?)&lt;br /&gt;
# Start the data export service executable XLDataExportSrv.exe found in bci2000/src/private/SignalSource/NatusSignalSource/DataExport_9.4/XLDataExportService&lt;br /&gt;
#* Note that this can be started before an EEG study has been started, or after an EEG study is already running&lt;br /&gt;
#* A small horizontal window should appear, indicating study data is streaming&lt;br /&gt;
# Create a BCI2000 batch file to start up the NatusSignalSource source module (An example batch file should be in the same NatusSignalSource folder after BCI2000 has been compiled)&lt;br /&gt;
# Launch BCI2000 using this batch file&lt;br /&gt;
# Open the config window and navigate to the source tab. Source parameters will vary according to your needs, but some recommended settings can be found below&lt;br /&gt;
#* SampleBlockSize: 100 (at a sampling rate of 2048, this yields a sample block size of 48.83ms. Note that the ratio of SampleBlockSize/ServerBlockSize needs to be a whole number for best performance. SampleBlockSize less than 48.83ms is not recommended.)&lt;br /&gt;
#* SamplingRate: auto (inherited from the Natus system)&lt;br /&gt;
#* ServerBlockSize: 1 (server buffer size. Larger ServerBlockSize can lead to performance issues.)&lt;br /&gt;
#* DecimationFactor: 1 (you can decimate the incoming sampled data by the DecimationFactor. The BCI2000 sampling rate will reflect the decimated rate.)&lt;br /&gt;
#* ServerIP: Set the IP address to localhost or 127.0.0.1&lt;br /&gt;
# Press “Set Config.” Data should begin streaming. Open the System Log from the BCI2000 Operator window to confirm that the sampling rate and channel count were inherited correctly from the Natus stream&lt;br /&gt;
&lt;br /&gt;
== Legacy Instructions for Connecting Natus to BCI2000 ==&lt;br /&gt;
=== On the Natus Computer ===&lt;br /&gt;
# If you have previously registered the XLDataExportClient.dll for an older version of the data export tool, you must first deregister this dll. Launch a command window as an administrator and type regsvr /u XLDataExportClient.dll&lt;br /&gt;
# Connect to the network via ethernet cable. Alternately, it is preferable to connect directly to the BCI2000 computer via ethernet.&lt;br /&gt;
# Copy the Export Service folder found in src\private\SignalSource\NatusSignalSource\DataExport_9.4\XLDataExportService to the hard drive of the computer running Natus Neuroworks or to a USB drive&lt;br /&gt;
# Note the IP address of the Natus computer (run “ipconfig” in the Command Prompt on the Natus computer). If the computers are directly connected with an ethernet cable, the IP address should be under &amp;quot;ethernet adapter ethernet&amp;quot; [[File:Natus7_IPaddress.jpg|center|600px|Run ipconfig on the Natus computer and note the IP address]]&lt;br /&gt;
# When starting a new study, set the sampling rate of the acquisition system by opening &amp;quot;Wave&amp;quot; and going to edit -&amp;gt; settings -&amp;gt; acquisition while a study is NOT running&lt;br /&gt;
#* Be sure that the Natus computer is set to acquire data over Ethernet and not USB if you intend to acquire data over 4kHz [[File:Natus1_StudySettings.jpg|center|600px|Set Natus Sampling Rate]]&lt;br /&gt;
# Start an EEG study in Neuroworks using the New EEG button. [[File:Natus2_StartStudy.jpg|center|1000px|Start a new Natus study]] You will need to enter the study information. [[File:Natus3_StudyInformation.jpg|center|600px|Enter the study information]] Note that you do not need to start the recording for the signal to stream to BCI2000. [[File:Natus4_StudyRunning.jpg|center|1000px|Study is running]]&lt;br /&gt;
# Run the executable XLDataExportSrv.exe found in the XLDataExportService folder that was copied to the Natus computer [[File:Natus5_DataExportServiceFolder.jpg|center|600px|Run the executable XLDataExportSrv.exe from the XLDataExportService folder]]&lt;br /&gt;
#* Note that this can be started before an EEG study has been started, or after an EEG study is already running&lt;br /&gt;
#* A small horizontal window should appear, indicating study data is streaming [[File:Natus6_DataExportServiceRunning.jpg|center|1000px|Natus Data Export Service Running]]&lt;br /&gt;
&lt;br /&gt;
=== On the BCI2000 Computer ===&lt;br /&gt;
# Connect to the same network that the Natus computer is connected via ethernet cable. Alternately, it is preferable to connect directly to the Natus computer via ethernet.&lt;br /&gt;
# Run a BCI2000 batch file that loads the NatusSignalSource&lt;br /&gt;
# Open the config window and navigate to the source tab. Source parameters will vary according to your needs, but some recommended settings can be found below&lt;br /&gt;
#* SampleBlockSize: 100 (at a sampling rate of 2048, this yields a sample block size of 48.83ms. Note that the ratio of SampleBlockSize/ServerBlockSize needs to be a whole number for best performance. SampleBlockSize less than 48.83ms is not recommended.)&lt;br /&gt;
#* SamplingRate: auto (inherited from the Natus system)&lt;br /&gt;
#* ServerBlockSize: 1 (server buffer size. Larger ServerBlockSize can lead to performance issues.)&lt;br /&gt;
#* DecimationFactor: 1 (you can decimate the incoming sampled data by the DecimationFactor. The BCI2000 sampling rate will reflect the decimated rate.)&lt;br /&gt;
#* ServerIP: Set the IP address to that of the Natus computer [[File:Natus8_BCI2000Parameters.jpg|center|600px|Natus BCI2000 parameters]]&lt;br /&gt;
# Press “Set Config.” Data should begin streaming. Open the System Log from the BCI2000 Operator window to confirm that the sampling rate and channel count were inherited correctly from the Natus stream&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
Parameters common to all source modules are described under [[User Reference:DataIOFilter]]. In addition, the following parameters are supported:&lt;br /&gt;
&lt;br /&gt;
=== SamplingRate ===&lt;br /&gt;
The rate at which the device samples the data. The default value is the device&#039;s default sampling rate. &lt;br /&gt;
&lt;br /&gt;
=== SampleBlockSize ===&lt;br /&gt;
The number of samples per block the output signal, created by the client application(NatusADC), should have. The default value is 20. Note that the ratio of SampleBlockSize/ServerBlockSize needs to be a whole number for best performance. SampleBlockSize less than 48.83ms is not recommended.&lt;br /&gt;
&lt;br /&gt;
=== ServerBlockSize ===&lt;br /&gt;
The number of samples sent by the server/device in a single UDP Packet. The default value is 1.&lt;br /&gt;
&lt;br /&gt;
=== DecimationFactor ===&lt;br /&gt;
The decimation factor. The factor by which to decimate/downsize the signal. The default value is 1. &#039;&#039;The SamplingRate is updated by dividing it by the DecimationFactor.&#039;&#039; &lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The SamplingRate should be an integral multiple of DecimationFactor.&lt;br /&gt;
&lt;br /&gt;
=== ServerIP ===&lt;br /&gt;
The IPv4 address of the server/device.&lt;br /&gt;
&lt;br /&gt;
=== Port ===&lt;br /&gt;
The port number of the server/device which on which TCP runs. UDP port number is assumed to be 1 + TCP port number.&lt;br /&gt;
&lt;br /&gt;
=== SourceCh ===&lt;br /&gt;
The number of channels to be acquired from the device. If this is set to auto, all the available channels from the device will be acquired.&lt;br /&gt;
&lt;br /&gt;
=== SourceChGain ===&lt;br /&gt;
SourceChGain should be left to auto. The default value is 0  for every channel.&lt;br /&gt;
&lt;br /&gt;
=== SourceChOffset ===&lt;br /&gt;
SourceChOffset should be left to auto. The default value is 1 microVolt for every channel.&lt;br /&gt;
&lt;br /&gt;
=== SourceChList ===&lt;br /&gt;
The list of channel numbers to be acquired from the device. The order of the numbers doesn&#039;t matter, i.e., &#039;1 2 3 4&#039; is same as &#039;3 2 4 1&#039;. Entering duplicate channels, eg. in &#039;1 2 3 2&#039; will result in an error. Entering an invalid channel number, i.e., a number greater than the maximum number of the channels will result in an error. If set to auto, all the device channels will be streamed.&lt;br /&gt;
&lt;br /&gt;
=== ChannelNames ===&lt;br /&gt;
The user-preferred channel names. If set to auto,  the channel names will be retrieved from the device. If the device doesn&#039;t have any specific channel names, the channel names will be set to 0 to SourceCh - 1. If set manually, names should be given for each channel in SourceChList&lt;br /&gt;
&lt;br /&gt;
== States ==&lt;br /&gt;
&lt;br /&gt;
=== Interpolated ===&lt;br /&gt;
Interpolated is represented by 1 bit. The device sends data in packets over UDP connection which is not a reliable connection and hence may result in loss of some packets. The lost packets between two packets received from the device are linearly interpolated from the aforementioned two packets.  The Interpolated state value is 1 if the packet is interpolated or 0 if the packet is received from the device. &lt;br /&gt;
&lt;br /&gt;
== Additional Info ==&lt;br /&gt;
The module also contains a function called GetDecimationFactor to query the current Decimation Factor from the server/device. &amp;lt;br/&amp;gt;&lt;br /&gt;
More details from a programmer&#039;s perspective can be found here [[Programming_Reference:NatusADC]]&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a problem streaming the data, try force quitting the Natus export service by opening the task manager on the Natus computer, then right clicking on the XLDataExportSrv and choosing &#039;end task.&#039; Then start the data export service again.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[[User Reference:DataIOFilter]], [[Programming Reference:GenericADC Class]]&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Swiftj</name></author>
	</entry>
</feed>