<?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=Dashmeetkaur</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=Dashmeetkaur"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php/Special:Contributions/Dashmeetkaur"/>
	<updated>2026-06-30T08:40:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8452</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8452"/>
		<updated>2019-07-31T17:45:58Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
The documentation first describes the two components that are developed to remotely start BCI2000 from the PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes over two tutorial examples.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
The 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 the 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;
&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;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Here is a picture of how PsychoPy looks before integrating BCI2000 in it. 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;
[[File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components]]&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, 2 examples are presented to help the user understand the working of the BCI2000 within PsychoPy. The examples modifies the demo stroopExtended (already provided by PsychoPy) 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. This is it should looks. &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 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;correctkey 0 1&#039;&#039;&#039; 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;
&amp;lt;code&amp;gt;correctkey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&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;/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 - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the field &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (BCI2000 state we want to update; &#039;$&#039; is used to indicate 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 which takes the input and &#039;corr&#039; is its property that stores the 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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen 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;
&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. This is it should looks. &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 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;responseTime 0 600&#039;&#039;&#039; 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;
&amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&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;/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 - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, 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 &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of code in python language in &#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 command.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNUNG 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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen 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;
&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8451</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8451"/>
		<updated>2019-07-31T17:40:50Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
The documentation first describes the two components that are developed to remotely start BCI2000 from the PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes over two tutorial examples.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
The 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 the 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;
&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;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Here is a picture of how PsychoPy looks before integrating BCI2000 in it. 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;
[[File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components]]&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, 2 examples are presented to help the user understand the working of the BCI2000 within PsychoPy. The examples modifies the demo stroopExtended (already provided by PsychoPy) 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. This is it should looks. &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 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;correctkey 0 1&#039;&#039;&#039; 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;
&amp;lt;code&amp;gt;correctkey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&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;/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 - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the field &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (BCI2000 state we want to update; &#039;$&#039; is used to indicate 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 which takes the input and &#039;corr&#039; is its property that stores the 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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen 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;
&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. This is it should looks. &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 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;responseTime 0 600&#039;&#039;&#039; 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;
&amp;lt;code&amp;gt;responseTime 0 600&amp;lt;/code&amp;gt;&amp;lt;br/&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;/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 - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, 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 &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of code in python language in &#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 command.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNUNG 1&#039; &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float): &amp;lt;br/&amp;gt;&lt;br /&gt;
    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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen 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;
&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8450</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8450"/>
		<updated>2019-07-31T17:39:34Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
The documentation first describes the two components that are developed to remotely start BCI2000 from the PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes over two tutorial examples.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
The 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 the 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;
&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;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Here is a picture of how PsychoPy looks before integrating BCI2000 in it. 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;
[[File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components]]&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, 2 examples are presented to help the user understand the working of the BCI2000 within PsychoPy. The examples modifies the demo stroopExtended (already provided by PsychoPy) 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. This is it should looks. &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 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;correctkey 0 1&#039;&#039;&#039; 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;
&amp;lt;code&amp;gt;correctkey 0 1&amp;lt;/code&amp;gt; &amp;lt;br/&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;/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 - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the field &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (BCI2000 state we want to update; &#039;$&#039; is used to indicate 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 which takes the input and &#039;corr&#039; is its property that stores the 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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen 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;
&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. This is it should looks. &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 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;responseTime 0 600&#039;&#039;&#039; 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;
[[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 - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, 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 &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of code in python language in &#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 command.  &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bci.Execute(&#039;SET STATE RUNNUNG 1&#039; &amp;lt;br/&amp;gt;&lt;br /&gt;
if(type(resp.rt) == float):&lt;br /&gt;
    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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen 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;
&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8449</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8449"/>
		<updated>2019-07-31T15:04:52Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
The documentation first describes the two components that are developed to remotely start BCI2000 from the PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes over two tutorial examples.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
The 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 the 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;
&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;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Here is a picture of how PsychoPy looks before integrating BCI2000 in it. 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;
[[File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components]]&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, 2 examples are presented to help the user understand the working of the BCI2000 within PsychoPy. The examples modifies the demo stroopExtended (already provided by PsychoPy) 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. This is it should looks. &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 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;correctkey 0 1&#039;&#039;&#039; 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;
[[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 - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the field &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (BCI2000 state we want to update; &#039;$&#039; is used to indicate 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 which takes the input and &#039;corr&#039; is its property that stores the 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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen 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;
&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. This is it should looks. &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 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;responseTime 0 600&#039;&#039;&#039; 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;
[[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 - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, 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 &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of code in python language in &#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 command.  &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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen 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;
&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciUpdateState2.png&amp;diff=8448</id>
		<title>File:PsychoPyBciUpdateState2.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciUpdateState2.png&amp;diff=8448"/>
		<updated>2019-07-31T14:47:35Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: PsychoPy-Bci Strop Extended Update State with Use Expression Option&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy-Bci Strop Extended Update State with Use Expression Option&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciUpdateState1.png&amp;diff=8447</id>
		<title>File:PsychoPyBciUpdateState1.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciUpdateState1.png&amp;diff=8447"/>
		<updated>2019-07-31T14:46:53Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: PsychoPy-Bci Update State with Response Component Variable Option&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy-Bci Update State with Response Component Variable Option&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciStart2.png&amp;diff=8446</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=8446"/>
		<updated>2019-07-31T14:46:07Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: PsychoPy-Bci Stroop Extended Start with Use Expression Option&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy-Bci Stroop Extended Start with Use Expression Option&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciStart1.png&amp;diff=8445</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=8445"/>
		<updated>2019-07-31T14:45:21Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: PsychoPy-Bci Stroop Extended Start with Response Component Variable Option&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>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciDemoRun2.png&amp;diff=8444</id>
		<title>File:PsychoPyBciDemoRun2.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciDemoRun2.png&amp;diff=8444"/>
		<updated>2019-07-31T14:43:37Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: PsychoPy-Bci Stroop Extended Demo Run with Use Expression Option&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy-Bci Stroop Extended Demo Run with Use Expression Option&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciDemoRun1.png&amp;diff=8443</id>
		<title>File:PsychoPyBciDemoRun1.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyBciDemoRun1.png&amp;diff=8443"/>
		<updated>2019-07-31T14:42:53Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: PsychoPy-Bci Stroop Extended Demo Run with Response Component Variable Option&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy-Bci Stroop Extended Demo Run with Response Component Variable Option&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyDemoStart.png&amp;diff=8442</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=8442"/>
		<updated>2019-07-31T14:41:29Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: PsychoPy Stroop Extended Demo Start&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy Stroop Extended Demo Start&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8441</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8441"/>
		<updated>2019-07-31T14:40:55Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
The documentation first describes the two components that are developed to remotely start BCI2000 from the PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes over two tutorial examples.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
The 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 the 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;
&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;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Here is a picture of how PsychoPy looks before integrating BCI2000 in it. 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;
[[File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components]]&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, 2 examples are presented to help the user understand the working of the BCI2000 within PsychoPy. The examples modifies the demo stroopExtended (already provided by PsychoPy) 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. This is it should looks.&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;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;correctkey 0 1&#039;&#039;&#039; 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.&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;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the field &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (BCI2000 state we want to update; &#039;$&#039; is used to indicate 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 which takes the input and &#039;corr&#039; is its property that stores the 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;.  &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;/li&amp;gt; &lt;br /&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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen.&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;/li&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. This is it should looks.&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;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;responseTime 0 600&#039;&#039;&#039; 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.&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;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, 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 &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of code in python language in &#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.SetState command.  &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;/li&amp;gt; &lt;br /&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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on responseTime and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen.&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;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8440</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8440"/>
		<updated>2019-07-30T20:37:17Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
The documentation first describes the two components that are developed to remotely start BCI2000 from the PsychoPy, then lists the steps to follow to add the new components in the PsychoPy application and finally goes over two tutorial examples.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCI2000Start ===&lt;br /&gt;
The 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 the 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;
&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;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Here is a picture of how PsychoPy looks before integrating BCI2000 in it. 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;
[[File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components]]&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
In this section, 2 examples are presented to help the user understand the working of the BCI2000 within PsychoPy. The examples modifies the demo stroopExtended (already provided by PsychoPy) 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. This is it should looks.&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;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;correctkey 0 1&#039;&#039;&#039; 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.&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;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000UpdateState&#039;&#039;&#039;. Fill in the field &#039;&#039;State Name&#039;&#039; with &#039;&#039;&#039;$correctKey&#039;&#039;&#039; (BCI2000 state we want to update; &#039;$&#039; is used to indicate 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 which takes the input and &#039;corr&#039; is its property that stores the 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;.  &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;/li&amp;gt; &lt;br /&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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen.&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;/li&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 a 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. This is it should looks.&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;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Start BCI2000 - With &#039;&#039;&#039;instruct&#039;&#039;&#039; routine on the screen, click on &#039;&#039;&#039;BCI2000Start&#039;&#039;&#039; and enter the path to the &#039;&#039;&#039;prog&#039;&#039;&#039; directory of BCI2000 (within which BCI2000Remote.py exists) in &#039;&#039;Path&#039;&#039; field and &#039;&#039;&#039;responseTime 0 600&#039;&#039;&#039; 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.&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;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Update BCI2000 State - With &#039;&#039;&#039;trial&#039;&#039;&#039; routine on the screen, 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 &#039;&#039;&#039;Expression&#039;&#039;&#039; field. Write the lines of code in python language in &#039;&#039;&#039;Expression&#039;&#039;&#039; field as shown in the image. These lines set the state &#039;responseTime&#039; to the integer 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.SetState command.  &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;/li&amp;gt; &lt;br /&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 (on BCI2000 operator, click on View -&amp;gt; States and Events.., right click on correctKey and add to watch, click Ok on States and Events screen) and proceed as with your PsychoPy experiment. The output of this experiment would be similar to as shown below. &#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen.&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;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8439</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8439"/>
		<updated>2019-07-30T15:58:09Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCIStart ===&lt;br /&gt;
The 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 the 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;
&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;
=== BCIUpdateState ===&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Here is a picture of how PsychoPy looks before integrating BCI2000 in it. 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;
[[File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components]]&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8438</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8438"/>
		<updated>2019-07-30T15:54:43Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCIStart ===&lt;br /&gt;
The 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 the 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;
&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;
=== BCIUpdateState ===&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&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 &#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;
Here is a picture of how PsychoPy looks before integrating BCI2000 in it. Notice that in the rightmost column, under &#039;&#039;&#039;Custom&#039;&#039;&#039; Components, there is no BCI2000 component.&lt;br /&gt;
[[File:PsychoPyWithoutBCI.png|alt=&amp;quot;PsychoPy Homepage without BCI2000 Components&amp;quot;|PsychoPy Homepage without BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the &#039;&#039;&#039;Custom&#039;&#039;&#039; Components (in 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPyWithoutBCI.png&amp;diff=8437</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=8437"/>
		<updated>2019-07-30T15:51:41Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: PsychoPy without BCI&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy without BCI&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:TBSIStimulator&amp;diff=8433</id>
		<title>Contributions:TBSIStimulator</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:TBSIStimulator&amp;diff=8433"/>
		<updated>2019-07-30T14:47:30Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The &#039;&#039;TBSIStimulatorFilter&#039;&#039; interacts with TBSI&#039;s USB-SPI wireless stimulator and dongle. The TBSI stimulator and dongle work in conjunction to administer pulses to different output channels on the stimulator. The type of pulses and interval at which these pulses are administered is customizable via the filter&#039;s parameters.&lt;br /&gt;
&lt;br /&gt;
To use this filter, a TBSI dongle must be connected to the computer via USB and the stimulator must be within range and charged.&lt;br /&gt;
&lt;br /&gt;
Tested with StimWare V1.7.22B67, dongle V0.25.0, and stimulator UID: FD, Type: E, Version: V0.40.10. Custom &#039;&#039;PI1&#039;&#039; and &#039;&#039;PD1&#039;&#039; parameters reverse engineered to work with these resources.&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
http://{{SERVERNAME}}/svn/trunk/src/private/SignalProcessing/TBSIStimulator&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Alex Belsten, Yichuan Wang&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: 5799&lt;br /&gt;
*Tested under: 5800&lt;br /&gt;
*Known to compile under: 5802&lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
==Known Issues==&lt;br /&gt;
Connection to the dongle will sometimes stall during startup or the first few commands. Effort has been done to minimize this issue, but it&#039;s not completely solved. In case of a program stall, replug the dongle and rerun the program.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===StimPattern===&lt;br /&gt;
An encoded string that represents the type of pulse that is going to be administered. Currently, encoded strings obtained from TBSI&#039;s StimWare software are the only way to edit the pulse. To set a custom pulse,&lt;br /&gt;
&lt;br /&gt;
1. Install TBSI Stimware (install LabView if needed)&lt;br /&gt;
&lt;br /&gt;
2. Go to Stimware installation directory and search for &amp;quot;Dongle.ini&amp;quot;&lt;br /&gt;
&lt;br /&gt;
3. Open &amp;quot;Dongle.ini&amp;quot;, change the value &amp;quot;Verbosity&amp;quot; from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
4. Play with various button and observe the SPI command exchange happening in the bottom window. &lt;br /&gt;
&lt;br /&gt;
5. Copy the exact SPI message from the Stimware&#039;s bottom window into &#039;&#039;TBSIStimulator StimPattern&#039;&#039; parameter if you want to perform that exact same action.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The default string is represented by the following settings in StimWare:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Mux SubCh&lt;br /&gt;
! ID&lt;br /&gt;
! PI1&lt;br /&gt;
! PD1&lt;br /&gt;
! PI2&lt;br /&gt;
! PD2&lt;br /&gt;
! Invert&lt;br /&gt;
! Train (Multiple Pulses)&lt;br /&gt;
! Stimulus (Multiple Trains)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 50 μs&lt;br /&gt;
| 500 μA&lt;br /&gt;
| 2,000 μs&lt;br /&gt;
| 100 μA&lt;br /&gt;
| 10,000 μs&lt;br /&gt;
| Off&lt;br /&gt;
| Off&lt;br /&gt;
| Off&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===PI1===&lt;br /&gt;
Custom initial stimulation value in μA.&lt;br /&gt;
&lt;br /&gt;
===PD1===&lt;br /&gt;
Custom &#039;&#039;PI1&#039;&#039; duration in μs.&lt;br /&gt;
&lt;br /&gt;
===EditStimPattern===&lt;br /&gt;
Allows for the editing of &#039;&#039;StimPattern&#039;&#039; based on the provided &#039;&#039;PI1&#039;&#039; and &#039;&#039;PD1&#039;&#039; values. If disabled, &#039;&#039;StimPattern&#039;&#039; will not be changed.&lt;br /&gt;
===StimInterval===&lt;br /&gt;
The interval in time in which the stimulus is administered. Reliability of connection with dongle and stimulator is compromised at values less than 3 seconds.  &lt;br /&gt;
&lt;br /&gt;
===ExternalHWTrigger===&lt;br /&gt;
Option to enable or disable external hardware triggers on TBSI dongle. Only enable if using external hardware triggers.&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
===StimState===&lt;br /&gt;
Binary state that is set to 1 when a trigger command is sent. Otherwise, the state takes the value of 0. Useful for measuring the latency of software trigger commands. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]][[Category:Filters]]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8432</id>
		<title>Programming Reference:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8432"/>
		<updated>2019-07-29T20:59:21Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: /* NatusClient */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NatusADC module has 3 main classes - NatusPackageInterface, NatusDataServer and NatusClient. 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 serve/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 the BCI2000 where as 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;
== NatusPackageInterface ==&lt;br /&gt;
This class handles the communication between the server/device and the client. It should be included with both - NatusDataServer and NatusClient Class. The class performs the following functions -constructing TCP and UDP packets, calculating the CRC of a packet and checking the CRC on the receiving side, sending the packets over TCP/UDP port, receiving packets over TCP/UDP Port, reconstructing the data from the packets and listening for connections on device/server-side. &#039;&#039;Note - The file limits the maximum number of channels for a device (stored in MAX_NUM_CHANNELS in NatusPackageInterface.h) to 100.&#039;&#039;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The format of the packets constructed along with each field size is as follows:&lt;br /&gt;
[[File:Prog_Ref_NatusADC_Packet_format.png|center|600px|Packet format]]&lt;br /&gt;
&lt;br /&gt;
=== TCP Commands ===&lt;br /&gt;
The commands through which the NatusDataServer and NatusClient communicate are as follows:&lt;br /&gt;
; CMD_Ping : To check if the connection is successful and data can be sent and received.&lt;br /&gt;
* Command Number: 0x01&lt;br /&gt;
* Parameters/Payload: 0xff&lt;br /&gt;
* Return Value: returns payload &lt;br /&gt;
&lt;br /&gt;
; CMD_GetInformation : To send the device information such as the number of channels and sampling rate to the client application.&lt;br /&gt;
* Command Number: 0x02&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusDeviceInformation which contains the number of channels, sampling rate, and device identifier.&lt;br /&gt;
&lt;br /&gt;
; CMD_GetChannelNames : To send the channel names as set by the device to the client  application. If no channel names are set, NULL is sent.&lt;br /&gt;
* Command Number: 0x03&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusChannelInformation which contains all the channels and stream names.&lt;br /&gt;
&lt;br /&gt;
; CMD_StartStream : To start sending channel data over UDP port.&lt;br /&gt;
* Command Number: 0x10&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_StopStream : To stop sending channel data&lt;br /&gt;
* Command Number: 0x1F&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SelectChannels : To send data only for the channels numbers mentioned in the payload. It corresponds to the SourceChList parameter.&lt;br /&gt;
* Command Number: 0x20&lt;br /&gt;
* Parameters/Payload: a list of channel numbers separated by space and stored in a string &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetBlockSize : To set the number of blocks to send per packet. It corresponds to the SeverBlockSize parameter.&lt;br /&gt;
* Command Number: 0x21&lt;br /&gt;
* Parameters/Payload: number of blocks to send per packet stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_GetDecimationFactor : To get the current decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x22&lt;br /&gt;
* Parameters/Payload: decimation factor stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetDecimationFactor : To set the decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x23&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: decimation factor stored in uint32_t datatype but casted into uint8_t datatype for transmission over TCP.&lt;br /&gt;
&lt;br /&gt;
; CMD_ERR : The command is sent if there is any type of error.&lt;br /&gt;
* Command Number: 0xFF&lt;br /&gt;
* Parameters/Payload: command which caused the error and the payload generated by the function handling the command.&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&amp;lt;u&amp;gt;Note:&amp;lt;/u&amp;gt; The packet format for this command is as follows: &lt;br /&gt;
[[File:Prog_Ref_NatusADC_CMD_ERR.png|center|Command CMD_ERR packet format.]]&lt;br /&gt;
&lt;br /&gt;
=== UDP Commands ===&lt;br /&gt;
; CMD_StreamPackage: The command is sent from the server/device to the client  application when only 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x11&lt;br /&gt;
* Parameters/Payload: Channel data of 1 block&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_VariableSizeStreamPackage: The command is sent from the server/device to the client application when more than 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x12&lt;br /&gt;
* Parameters/Payload: Channel data of more than 1 block (number of blocks as set by the CMD_SetBlockSize command)&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Poll ()&#039;&#039;&#039; - The function runs on server/device and continuously waits for any command from the NatusClient over the TCP protocol.&lt;br /&gt;
* &#039;&#039;&#039;void send_data (uint8_t cmd, uint8_t* payload, uint32_t len_payload, bool isError=false, PackageType t = Control)&#039;&#039;&#039; - The function creates a packet using cmd (the command) and the payload. The default values for isError is false (i.e., no error) and PackageType is Control (TCP prototcol). The channel data is sent over Stream PackageType (i.e., UDP Protocol).&lt;br /&gt;
* &#039;&#039;&#039;virtual void data_received (CmdStruct * payload) = 0&#039;&#039;&#039; - The function should be implemented in the child classes to ensure proper processing, in respect ot the child class, of the data recieved via TCP or UDP protocol is done.&lt;br /&gt;
* &#039;&#039;&#039;void printMessage (std::string)&#039;&#039;&#039; - Print the string parameter on the warning window. &lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextPackage ()&#039;&#039;&#039; - The function gets a TCP packet (from the server or from the Client, as the case may be) and store in struct CmdStruct. Definietion of CmdStruct can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextUDPPackage ()&#039;&#039;&#039; - The function is same as CmdStruct* getNextPackage(), except that it received packet over UDP protocol.  &lt;br /&gt;
* &#039;&#039;&#039;void delete_cmdstruct (CmdStruct* )&#039;&#039;&#039; - The function frees the memory occupied by a CmdStruct pointer.&lt;br /&gt;
* &#039;&#039;&#039;void initWSA ()&#039;&#039;&#039; - The function initializes the Winsock. &lt;br /&gt;
* &#039;&#039;&#039;SOCKET connection&#039;&#039;&#039; - It stores the TCP socket connection, i.e, in server/device - the connection to the client and in client - the connection to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;SOCKET udpSocket&#039;&#039;&#039; - It stores the UDP socket connection.&lt;br /&gt;
* &#039;&#039;&#039;sockaddr_in _udpReceiver&#039;&#039;&#039; - It stores the socket address for IPv4.&lt;br /&gt;
&lt;br /&gt;
== NatusDataServer ==&lt;br /&gt;
This class handles the server-side processing. It performs the following functions - starts-up the TCP and UDP server, check for new connections, gracefully disconnects from the client, registers various callbacks on client connection and deregister the callbacks when the client disconnects and responds to the commands (described in the NatusPackageInterface section) from the client via TCP protocol.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Startup (std::uint16_t port)&#039;&#039;&#039; - The function starts up the server and listens for a TCP connection on the port number specified by &#039;&#039;port&#039;&#039; and a UDP connection on the port number &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void CheckForConnection ()&#039;&#039;&#039; - The function checks for a client connection request and accept it if there is one.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterDataStreamCallback (NatusDataStreamRequest, void*)&#039;&#039;&#039; - The function registers the callbacks to start &amp;amp; stop streams.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterInformationCallback (NatusInformationRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device information.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterChannelInformationCallback (NatusChannelInfoRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device&#039;s channels&#039; names.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterErrorCallback (NatusResponse, void*)&#039;&#039;&#039; - The function registers the callback to call incase of any error.&lt;br /&gt;
* &#039;&#039;&#039;void UnregisterCallbacks ()&#039;&#039;&#039; - The function deregisters all the callbacks. It is called before closing the connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;void SendStreamData (float* data, uint32_t numdata)&#039;&#039;&#039; - The function accepts the channel &#039;&#039;data&#039;&#039; and the number of channels &#039;&#039;numdata&#039;&#039; and prepares the data by decimating it (if decimation factor is set) and by making packets with required number of blocks which are then sent to the client. &lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the UDP and TCP connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;bool HasClient ()&#039;&#039;&#039; - The function checks if there is a client connected to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; -  It stores the channel numbers which are to be streamed. The end of the array is defined by storing the last element as -1.&lt;br /&gt;
* &#039;&#039;&#039;int _numberOfChannelsToStream&#039;&#039;&#039; - It stores the number of channels to stream.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks for the command received from the client and calls the appropriate function to fulfill the client&#039;s request.&lt;br /&gt;
* &#039;&#039;&#039;void start_UDP_sever (std::uint16_t port)&#039;&#039;&#039; - The function opens up a UDP connection at the &#039;&#039;port&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== NatusClient ==&lt;br /&gt;
This class handles the client-side processing. It connects with the server/device, gets data from the operator module of the NatusADC and sends it to the server/device. It uses various commands as described in the NatusDataServer to set different parameters. Another important function of this class &#039;interpolateMissingBlocks&#039; linearly interpolates the missing UDP packets which contain the channel data values. Eg. &amp;lt;br/&amp;gt; &lt;br /&gt;
Consider the scenario where for a single channel with 1 sample per block, 1 block per packet is sent with decimation factor is 1. Suppose we received packet 1 and 3, packet 2 was lost. Data for packet 2 is interpolated as follows: &lt;br /&gt;
&amp;lt;br/&amp;gt; Interpolation formula&lt;br /&gt;
&#039;&#039;Interpolated Value = ((Current Packet value – Previous Packet value) / (Current Packet Number – Previous Packet Number)) * (Interpolated Packet Number – Previous Packet Number) + Previous Packet Value&#039;&#039;&lt;br /&gt;
[[File:Programming_Reference_NatusADC_Interpolation.png|center|500px|Linear Interpolation example]]&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;NatusDeviceInformation GetInformation ()&#039;&#039;&#039; - The function sends a CMD_GetInformation command to the server/device over TCP to query the sampling rate and number of channels of the device. It stores the received information in the &#039;&#039;NatusDeviceInformation&#039;&#039; struct type variable.&lt;br /&gt;
* &#039;&#039;&#039;void Connect (std::string server_name, int port)&#039;&#039;&#039; - The function establishes a TCP connection with the &#039;&#039;server_name&#039;&#039; server at port number &#039;&#039;port&#039;&#039; and calls the &#039;&#039;init_udp&#039;&#039; function to establish a UDP connection at port &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;bool TryConnect (std::string server_name, int port)&#039;&#039;&#039; - The function tries to establish a TCP and UDP connection again with the &#039;&#039;server_name&#039;&#039; if the connection is lost and returns &#039;&#039;true&#039;&#039; if the connection is successful otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the TCP and UDP connection with the server/device.&lt;br /&gt;
* &#039;&#039;&#039;void StartStream ()&#039;&#039;&#039; - The function sends the CMD_StartStream command to the server/device to request the channel stream data, which the server/device sends over the UDP.&lt;br /&gt;
* &#039;&#039;&#039;void StopStream ()&#039;&#039;&#039; -  The function sends the CMD_StopStream command to the server/device. &lt;br /&gt;
* &#039;&#039;&#039;uint8_t Ping (uint8_t ping)&#039;&#039;&#039; - The function sends a CMD_PING command to the sever/device with data stored in &#039;&#039;ping&#039;&#039; as payload.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* ReadStream ()&#039;&#039;&#039; - The function gets channel data blocks from the server/device through a UDP protocol, calls the &#039;&#039;interpolateMissingBlocks&#039;&#039; if there is any missing blocks, adds the block to the &#039;&#039;_receivequeue&#039;&#039; and returns the first block from the &#039;&#039;_receivequeue&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* create_natus_sampleblock (uint8_t* payload)&#039;&#039;&#039; - The function creates and returns a NatusSampleBlock structure variable from the payload passes. NatusSampleBlock contains block number, number of samples, samples and a boolean specifying whether the block was recieved from the server/device or was interpolated.&lt;br /&gt;
* &#039;&#039;&#039;void DeleteSampleBlock (NatusSampleBlock*)&#039;&#039;&#039; - The function free the space occupied by the NatusSampleBlock variable passed to it.&lt;br /&gt;
* &#039;&#039;&#039;void SetSampleBlockSize (uint32_t blocksize)&#039;&#039;&#039; - The function sends CMD_SetBlockSize command to the server/device to set number of blocks to be sent in a packet as &#039;&#039;blocksize&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void SetDecimationFactor (uint32_t decimationFactor)&#039;&#039;&#039; - The function sends CMD_SetDecimationFactor command to the server/device to set the decimation factor as &#039;&#039;decimationFactor&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation GetChannelInfo ()&#039;&#039;&#039; - The function sends CMD_GetChannelNames command to the server/device to query the channel and stream names of the device and stores them in a NatusChannelInformation structure.&lt;br /&gt;
* &#039;&#039;&#039;int GetDecimationFactor ()&#039;&#039;&#039; - The function queries from the server/device over TCP, the current decimation factor and returns it.&lt;br /&gt;
* &#039;&#039;&#039;int SelectChannelsToStream (std::string channels)&#039;&#039;&#039; -  The function sends CMD_SelectChannels command to the server/device along with the channels to stream stored in a space separated &#039;&#039;channels&#039;&#039; string.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; - It stores the channel numbers which are to be streamed.  &lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation channelInfo&#039;&#039;&#039; - The structure stores the channel and stream names of the device.  The NatusChannelInformation structure definition can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks if the data received from the server/device does not contain a CMD_ERR code.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* blockForPackage(uint32_t timeout)&#039;&#039;&#039; - The function waits to receive a TCP packet from server/device for the time specified by the &#039;&#039;timeout&#039;&#039; variable.&lt;br /&gt;
* &#039;&#039;&#039;std::queue&amp;lt;NatusSampleBlock*&amp;gt; _receivequeue&#039;&#039;&#039; - The queue stores the blocks received for processing.&lt;br /&gt;
* &#039;&#039;&#039;bool init_udp (int port)&#039;&#039;&#039; - The function creates and binds a UDP socket. If completed successfully, it returns &#039;&#039;true&#039;&#039;, otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock _prevblock&#039;&#039;&#039; - It stores the last data block received from the server/device and is used to check if any block is lost in between, when the client receives a new data block. &lt;br /&gt;
* &#039;&#039;&#039;void interpolateMissingBlocks (NatusSampleBlock*)&#039;&#039;&#039; - The function linearly interpolates any number of missing blocks between the current received data block and the last recieved data block.&lt;br /&gt;
* &#039;&#039;&#039;void emptyReceiveQueue ()&#039;&#039;&#039; - The function frees the memory occupied by the queue &#039;&#039;_receivequeue&#039;&#039; whenever the connection is closed or restarted.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[[Contributions:NatusADC]], [[User Reference:DataIOFilter]], [[Programming Reference:GenericADC Class]]&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:NatusADC&amp;diff=8431</id>
		<title>Contributions:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:NatusADC&amp;diff=8431"/>
		<updated>2019-07-29T20:57:15Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &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 serve/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 the BCI2000 where as 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;
=== 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;
== 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&lt;br /&gt;
 &lt;br /&gt;
=== ServerBlockSize ===&lt;br /&gt;
The number of blocks 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;
== 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>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8430</id>
		<title>Programming Reference:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8430"/>
		<updated>2019-07-29T20:56:38Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NatusADC module has 3 main classes - NatusPackageInterface, NatusDataServer and NatusClient. 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 serve/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 the BCI2000 where as 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;
== NatusPackageInterface ==&lt;br /&gt;
This class handles the communication between the server/device and the client. It should be included with both - NatusDataServer and NatusClient Class. The class performs the following functions -constructing TCP and UDP packets, calculating the CRC of a packet and checking the CRC on the receiving side, sending the packets over TCP/UDP port, receiving packets over TCP/UDP Port, reconstructing the data from the packets and listening for connections on device/server-side. &#039;&#039;Note - The file limits the maximum number of channels for a device (stored in MAX_NUM_CHANNELS in NatusPackageInterface.h) to 100.&#039;&#039;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The format of the packets constructed along with each field size is as follows:&lt;br /&gt;
[[File:Prog_Ref_NatusADC_Packet_format.png|center|600px|Packet format]]&lt;br /&gt;
&lt;br /&gt;
=== TCP Commands ===&lt;br /&gt;
The commands through which the NatusDataServer and NatusClient communicate are as follows:&lt;br /&gt;
; CMD_Ping : To check if the connection is successful and data can be sent and received.&lt;br /&gt;
* Command Number: 0x01&lt;br /&gt;
* Parameters/Payload: 0xff&lt;br /&gt;
* Return Value: returns payload &lt;br /&gt;
&lt;br /&gt;
; CMD_GetInformation : To send the device information such as the number of channels and sampling rate to the client application.&lt;br /&gt;
* Command Number: 0x02&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusDeviceInformation which contains the number of channels, sampling rate, and device identifier.&lt;br /&gt;
&lt;br /&gt;
; CMD_GetChannelNames : To send the channel names as set by the device to the client  application. If no channel names are set, NULL is sent.&lt;br /&gt;
* Command Number: 0x03&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusChannelInformation which contains all the channels and stream names.&lt;br /&gt;
&lt;br /&gt;
; CMD_StartStream : To start sending channel data over UDP port.&lt;br /&gt;
* Command Number: 0x10&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_StopStream : To stop sending channel data&lt;br /&gt;
* Command Number: 0x1F&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SelectChannels : To send data only for the channels numbers mentioned in the payload. It corresponds to the SourceChList parameter.&lt;br /&gt;
* Command Number: 0x20&lt;br /&gt;
* Parameters/Payload: a list of channel numbers separated by space and stored in a string &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetBlockSize : To set the number of blocks to send per packet. It corresponds to the SeverBlockSize parameter.&lt;br /&gt;
* Command Number: 0x21&lt;br /&gt;
* Parameters/Payload: number of blocks to send per packet stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_GetDecimationFactor : To get the current decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x22&lt;br /&gt;
* Parameters/Payload: decimation factor stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetDecimationFactor : To set the decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x23&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: decimation factor stored in uint32_t datatype but casted into uint8_t datatype for transmission over TCP.&lt;br /&gt;
&lt;br /&gt;
; CMD_ERR : The command is sent if there is any type of error.&lt;br /&gt;
* Command Number: 0xFF&lt;br /&gt;
* Parameters/Payload: command which caused the error and the payload generated by the function handling the command.&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&amp;lt;u&amp;gt;Note:&amp;lt;/u&amp;gt; The packet format for this command is as follows: &lt;br /&gt;
[[File:Prog_Ref_NatusADC_CMD_ERR.png|center|Command CMD_ERR packet format.]]&lt;br /&gt;
&lt;br /&gt;
=== UDP Commands ===&lt;br /&gt;
; CMD_StreamPackage: The command is sent from the server/device to the client  application when only 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x11&lt;br /&gt;
* Parameters/Payload: Channel data of 1 block&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_VariableSizeStreamPackage: The command is sent from the server/device to the client application when more than 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x12&lt;br /&gt;
* Parameters/Payload: Channel data of more than 1 block (number of blocks as set by the CMD_SetBlockSize command)&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Poll ()&#039;&#039;&#039; - The function runs on server/device and continuously waits for any command from the NatusClient over the TCP protocol.&lt;br /&gt;
* &#039;&#039;&#039;void send_data (uint8_t cmd, uint8_t* payload, uint32_t len_payload, bool isError=false, PackageType t = Control)&#039;&#039;&#039; - The function creates a packet using cmd (the command) and the payload. The default values for isError is false (i.e., no error) and PackageType is Control (TCP prototcol). The channel data is sent over Stream PackageType (i.e., UDP Protocol).&lt;br /&gt;
* &#039;&#039;&#039;virtual void data_received (CmdStruct * payload) = 0&#039;&#039;&#039; - The function should be implemented in the child classes to ensure proper processing, in respect ot the child class, of the data recieved via TCP or UDP protocol is done.&lt;br /&gt;
* &#039;&#039;&#039;void printMessage (std::string)&#039;&#039;&#039; - Print the string parameter on the warning window. &lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextPackage ()&#039;&#039;&#039; - The function gets a TCP packet (from the server or from the Client, as the case may be) and store in struct CmdStruct. Definietion of CmdStruct can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextUDPPackage ()&#039;&#039;&#039; - The function is same as CmdStruct* getNextPackage(), except that it received packet over UDP protocol.  &lt;br /&gt;
* &#039;&#039;&#039;void delete_cmdstruct (CmdStruct* )&#039;&#039;&#039; - The function frees the memory occupied by a CmdStruct pointer.&lt;br /&gt;
* &#039;&#039;&#039;void initWSA ()&#039;&#039;&#039; - The function initializes the Winsock. &lt;br /&gt;
* &#039;&#039;&#039;SOCKET connection&#039;&#039;&#039; - It stores the TCP socket connection, i.e, in server/device - the connection to the client and in client - the connection to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;SOCKET udpSocket&#039;&#039;&#039; - It stores the UDP socket connection.&lt;br /&gt;
* &#039;&#039;&#039;sockaddr_in _udpReceiver&#039;&#039;&#039; - It stores the socket address for IPv4.&lt;br /&gt;
&lt;br /&gt;
== NatusDataServer ==&lt;br /&gt;
This class handles the server-side processing. It performs the following functions - starts-up the TCP and UDP server, check for new connections, gracefully disconnects from the client, registers various callbacks on client connection and deregister the callbacks when the client disconnects and responds to the commands (described in the NatusPackageInterface section) from the client via TCP protocol.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Startup (std::uint16_t port)&#039;&#039;&#039; - The function starts up the server and listens for a TCP connection on the port number specified by &#039;&#039;port&#039;&#039; and a UDP connection on the port number &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void CheckForConnection ()&#039;&#039;&#039; - The function checks for a client connection request and accept it if there is one.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterDataStreamCallback (NatusDataStreamRequest, void*)&#039;&#039;&#039; - The function registers the callbacks to start &amp;amp; stop streams.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterInformationCallback (NatusInformationRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device information.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterChannelInformationCallback (NatusChannelInfoRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device&#039;s channels&#039; names.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterErrorCallback (NatusResponse, void*)&#039;&#039;&#039; - The function registers the callback to call incase of any error.&lt;br /&gt;
* &#039;&#039;&#039;void UnregisterCallbacks ()&#039;&#039;&#039; - The function deregisters all the callbacks. It is called before closing the connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;void SendStreamData (float* data, uint32_t numdata)&#039;&#039;&#039; - The function accepts the channel &#039;&#039;data&#039;&#039; and the number of channels &#039;&#039;numdata&#039;&#039; and prepares the data by decimating it (if decimation factor is set) and by making packets with required number of blocks which are then sent to the client. &lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the UDP and TCP connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;bool HasClient ()&#039;&#039;&#039; - The function checks if there is a client connected to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; -  It stores the channel numbers which are to be streamed. The end of the array is defined by storing the last element as -1.&lt;br /&gt;
* &#039;&#039;&#039;int _numberOfChannelsToStream&#039;&#039;&#039; - It stores the number of channels to stream.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks for the command received from the client and calls the appropriate function to fulfill the client&#039;s request.&lt;br /&gt;
* &#039;&#039;&#039;void start_UDP_sever (std::uint16_t port)&#039;&#039;&#039; - The function opens up a UDP connection at the &#039;&#039;port&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== NatusClient ==&lt;br /&gt;
This class handles the client-side processing. It connects with the server/device, gets data from the operator module of the NatusADC and sends it to the server/device. It uses various commands as described in the NatusDataServer to set different parameters. Another important function of this class &#039;interpolateMissingBlocks&#039; linearly interpolates the missing UDP packets which contain the channel data values. Eg. &amp;lt;br/&amp;gt; &lt;br /&gt;
Consider the scenario where 1 block is sent per packet and decimation factor is 1. Suppose we received packet 1 and 3, packet 2 was lost. Data for packet 2 is interpolated as follows: &lt;br /&gt;
&amp;lt;br/&amp;gt; Interpolation formula&lt;br /&gt;
&#039;&#039;Interpolated Value = ((Current Packet value – Previous Packet value) / (Current Packet Number – Previous Packet Number)) * (Interpolated Packet Number – Previous Packet Number) + Previous Packet Value&#039;&#039;&lt;br /&gt;
[[File:Programming_Reference_NatusADC_Interpolation.png|center|500px|Linear Interpolation example]]&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;NatusDeviceInformation GetInformation ()&#039;&#039;&#039; - The function sends a CMD_GetInformation command to the server/device over TCP to query the sampling rate and number of channels of the device. It stores the received information in the &#039;&#039;NatusDeviceInformation&#039;&#039; struct type variable.&lt;br /&gt;
* &#039;&#039;&#039;void Connect (std::string server_name, int port)&#039;&#039;&#039; - The function establishes a TCP connection with the &#039;&#039;server_name&#039;&#039; server at port number &#039;&#039;port&#039;&#039; and calls the &#039;&#039;init_udp&#039;&#039; function to establish a UDP connection at port &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;bool TryConnect (std::string server_name, int port)&#039;&#039;&#039; - The function tries to establish a TCP and UDP connection again with the &#039;&#039;server_name&#039;&#039; if the connection is lost and returns &#039;&#039;true&#039;&#039; if the connection is successful otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the TCP and UDP connection with the server/device.&lt;br /&gt;
* &#039;&#039;&#039;void StartStream ()&#039;&#039;&#039; - The function sends the CMD_StartStream command to the server/device to request the channel stream data, which the server/device sends over the UDP.&lt;br /&gt;
* &#039;&#039;&#039;void StopStream ()&#039;&#039;&#039; -  The function sends the CMD_StopStream command to the server/device. &lt;br /&gt;
* &#039;&#039;&#039;uint8_t Ping (uint8_t ping)&#039;&#039;&#039; - The function sends a CMD_PING command to the sever/device with data stored in &#039;&#039;ping&#039;&#039; as payload.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* ReadStream ()&#039;&#039;&#039; - The function gets channel data blocks from the server/device through a UDP protocol, calls the &#039;&#039;interpolateMissingBlocks&#039;&#039; if there is any missing blocks, adds the block to the &#039;&#039;_receivequeue&#039;&#039; and returns the first block from the &#039;&#039;_receivequeue&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* create_natus_sampleblock (uint8_t* payload)&#039;&#039;&#039; - The function creates and returns a NatusSampleBlock structure variable from the payload passes. NatusSampleBlock contains block number, number of samples, samples and a boolean specifying whether the block was recieved from the server/device or was interpolated.&lt;br /&gt;
* &#039;&#039;&#039;void DeleteSampleBlock (NatusSampleBlock*)&#039;&#039;&#039; - The function free the space occupied by the NatusSampleBlock variable passed to it.&lt;br /&gt;
* &#039;&#039;&#039;void SetSampleBlockSize (uint32_t blocksize)&#039;&#039;&#039; - The function sends CMD_SetBlockSize command to the server/device to set number of blocks to be sent in a packet as &#039;&#039;blocksize&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void SetDecimationFactor (uint32_t decimationFactor)&#039;&#039;&#039; - The function sends CMD_SetDecimationFactor command to the server/device to set the decimation factor as &#039;&#039;decimationFactor&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation GetChannelInfo ()&#039;&#039;&#039; - The function sends CMD_GetChannelNames command to the server/device to query the channel and stream names of the device and stores them in a NatusChannelInformation structure.&lt;br /&gt;
* &#039;&#039;&#039;int GetDecimationFactor ()&#039;&#039;&#039; - The function queries from the server/device over TCP, the current decimation factor and returns it.&lt;br /&gt;
* &#039;&#039;&#039;int SelectChannelsToStream (std::string channels)&#039;&#039;&#039; -  The function sends CMD_SelectChannels command to the server/device along with the channels to stream stored in a space separated &#039;&#039;channels&#039;&#039; string.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; - It stores the channel numbers which are to be streamed.  &lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation channelInfo&#039;&#039;&#039; - The structure stores the channel and stream names of the device.  The NatusChannelInformation structure definition can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks if the data received from the server/device does not contain a CMD_ERR code.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* blockForPackage(uint32_t timeout)&#039;&#039;&#039; - The function waits to receive a TCP packet from server/device for the time specified by the &#039;&#039;timeout&#039;&#039; variable.&lt;br /&gt;
* &#039;&#039;&#039;std::queue&amp;lt;NatusSampleBlock*&amp;gt; _receivequeue&#039;&#039;&#039; - The queue stores the blocks received for processing.&lt;br /&gt;
* &#039;&#039;&#039;bool init_udp (int port)&#039;&#039;&#039; - The function creates and binds a UDP socket. If completed successfully, it returns &#039;&#039;true&#039;&#039;, otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock _prevblock&#039;&#039;&#039; - It stores the last data block received from the server/device and is used to check if any block is lost in between, when the client receives a new data block. &lt;br /&gt;
* &#039;&#039;&#039;void interpolateMissingBlocks (NatusSampleBlock*)&#039;&#039;&#039; - The function linearly interpolates any number of missing blocks between the current received data block and the last recieved data block.&lt;br /&gt;
* &#039;&#039;&#039;void emptyReceiveQueue ()&#039;&#039;&#039; - The function frees the memory occupied by the queue &#039;&#039;_receivequeue&#039;&#039; whenever the connection is closed or restarted.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[[Contributions:NatusADC]], [[User Reference:DataIOFilter]], [[Programming Reference:GenericADC Class]]&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:NatusPacketImage.png&amp;diff=8429</id>
		<title>File:NatusPacketImage.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:NatusPacketImage.png&amp;diff=8429"/>
		<updated>2019-07-29T20:52:09Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: NatusPacketImage&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NatusPacketImage&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:NatusADC&amp;diff=8428</id>
		<title>Contributions:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:NatusADC&amp;diff=8428"/>
		<updated>2019-07-29T20:23:18Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &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.  &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;
== 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&lt;br /&gt;
 &lt;br /&gt;
=== ServerBlockSize ===&lt;br /&gt;
The number of blocks 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;
== 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>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8427</id>
		<title>Programming Reference:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8427"/>
		<updated>2019-07-29T20:13:06Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: /* NatusPackageInterface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NatusADC module has 3 main classes - NatusPackageInterface, NatusDataServer and NatusClient. 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 serve/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 the BCI2000 where as NatusClient relies on BCI2000. &lt;br /&gt;
&lt;br /&gt;
== NatusPackageInterface ==&lt;br /&gt;
This class handles the communication between the server/device and the client. It should be included with both - NatusDataServer and NatusClient Class. The class performs the following functions -constructing TCP and UDP packets, calculating the CRC of a packet and checking the CRC on the receiving side, sending the packets over TCP/UDP port, receiving packets over TCP/UDP Port, reconstructing the data from the packets and listening for connections on device/server-side. &#039;&#039;Note - The file limits the maximum number of channels for a device (stored in MAX_NUM_CHANNELS in NatusPackageInterface.h) to 100.&#039;&#039;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The format of the packets constructed along with each field size is as follows:&lt;br /&gt;
[[File:Prog_Ref_NatusADC_Packet_format.png|center|600px|Packet format]]&lt;br /&gt;
&lt;br /&gt;
=== TCP Commands ===&lt;br /&gt;
The commands through which the NatusDataServer and NatusClient communicate are as follows:&lt;br /&gt;
; CMD_Ping : To check if the connection is successful and data can be sent and received.&lt;br /&gt;
* Command Number: 0x01&lt;br /&gt;
* Parameters/Payload: 0xff&lt;br /&gt;
* Return Value: returns payload &lt;br /&gt;
&lt;br /&gt;
; CMD_GetInformation : To send the device information such as the number of channels and sampling rate to the client application.&lt;br /&gt;
* Command Number: 0x02&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusDeviceInformation which contains the number of channels, sampling rate, and device identifier.&lt;br /&gt;
&lt;br /&gt;
; CMD_GetChannelNames : To send the channel names as set by the device to the client  application. If no channel names are set, NULL is sent.&lt;br /&gt;
* Command Number: 0x03&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusChannelInformation which contains all the channels and stream names.&lt;br /&gt;
&lt;br /&gt;
; CMD_StartStream : To start sending channel data over UDP port.&lt;br /&gt;
* Command Number: 0x10&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_StopStream : To stop sending channel data&lt;br /&gt;
* Command Number: 0x1F&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SelectChannels : To send data only for the channels numbers mentioned in the payload. It corresponds to the SourceChList parameter.&lt;br /&gt;
* Command Number: 0x20&lt;br /&gt;
* Parameters/Payload: a list of channel numbers separated by space and stored in a string &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetBlockSize : To set the number of blocks to send per packet. It corresponds to the SeverBlockSize parameter.&lt;br /&gt;
* Command Number: 0x21&lt;br /&gt;
* Parameters/Payload: number of blocks to send per packet stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_GetDecimationFactor : To get the current decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x22&lt;br /&gt;
* Parameters/Payload: decimation factor stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetDecimationFactor : To set the decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x23&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: decimation factor stored in uint32_t datatype but casted into uint8_t datatype for transmission over TCP.&lt;br /&gt;
&lt;br /&gt;
; CMD_ERR : The command is sent if there is any type of error.&lt;br /&gt;
* Command Number: 0xFF&lt;br /&gt;
* Parameters/Payload: command which caused the error and the payload generated by the function handling the command.&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&amp;lt;u&amp;gt;Note:&amp;lt;/u&amp;gt; The packet format for this command is as follows: &lt;br /&gt;
[[File:Prog_Ref_NatusADC_CMD_ERR.png|center|Command CMD_ERR packet format.]]&lt;br /&gt;
&lt;br /&gt;
=== UDP Commands ===&lt;br /&gt;
; CMD_StreamPackage: The command is sent from the server/device to the client  application when only 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x11&lt;br /&gt;
* Parameters/Payload: Channel data of 1 block&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_VariableSizeStreamPackage: The command is sent from the server/device to the client application when more than 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x12&lt;br /&gt;
* Parameters/Payload: Channel data of more than 1 block (number of blocks as set by the CMD_SetBlockSize command)&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Poll ()&#039;&#039;&#039; - The function runs on server/device and continuously waits for any command from the NatusClient over the TCP protocol.&lt;br /&gt;
* &#039;&#039;&#039;void send_data (uint8_t cmd, uint8_t* payload, uint32_t len_payload, bool isError=false, PackageType t = Control)&#039;&#039;&#039; - The function creates a packet using cmd (the command) and the payload. The default values for isError is false (i.e., no error) and PackageType is Control (TCP prototcol). The channel data is sent over Stream PackageType (i.e., UDP Protocol).&lt;br /&gt;
* &#039;&#039;&#039;virtual void data_received (CmdStruct * payload) = 0&#039;&#039;&#039; - The function should be implemented in the child classes to ensure proper processing, in respect ot the child class, of the data recieved via TCP or UDP protocol is done.&lt;br /&gt;
* &#039;&#039;&#039;void printMessage (std::string)&#039;&#039;&#039; - Print the string parameter on the warning window. &lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextPackage ()&#039;&#039;&#039; - The function gets a TCP packet (from the server or from the Client, as the case may be) and store in struct CmdStruct. Definietion of CmdStruct can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextUDPPackage ()&#039;&#039;&#039; - The function is same as CmdStruct* getNextPackage(), except that it received packet over UDP protocol.  &lt;br /&gt;
* &#039;&#039;&#039;void delete_cmdstruct (CmdStruct* )&#039;&#039;&#039; - The function frees the memory occupied by a CmdStruct pointer.&lt;br /&gt;
* &#039;&#039;&#039;void initWSA ()&#039;&#039;&#039; - The function initializes the Winsock. &lt;br /&gt;
* &#039;&#039;&#039;SOCKET connection&#039;&#039;&#039; - It stores the TCP socket connection, i.e, in server/device - the connection to the client and in client - the connection to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;SOCKET udpSocket&#039;&#039;&#039; - It stores the UDP socket connection.&lt;br /&gt;
* &#039;&#039;&#039;sockaddr_in _udpReceiver&#039;&#039;&#039; - It stores the socket address for IPv4.&lt;br /&gt;
&lt;br /&gt;
== NatusDataServer ==&lt;br /&gt;
This class handles the server-side processing. It performs the following functions - starts-up the TCP and UDP server, check for new connections, gracefully disconnects from the client, registers various callbacks on client connection and deregister the callbacks when the client disconnects and responds to the commands (described in the NatusPackageInterface section) from the client via TCP protocol.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Startup (std::uint16_t port)&#039;&#039;&#039; - The function starts up the server and listens for a TCP connection on the port number specified by &#039;&#039;port&#039;&#039; and a UDP connection on the port number &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void CheckForConnection ()&#039;&#039;&#039; - The function checks for a client connection request and accept it if there is one.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterDataStreamCallback (NatusDataStreamRequest, void*)&#039;&#039;&#039; - The function registers the callbacks to start &amp;amp; stop streams.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterInformationCallback (NatusInformationRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device information.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterChannelInformationCallback (NatusChannelInfoRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device&#039;s channels&#039; names.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterErrorCallback (NatusResponse, void*)&#039;&#039;&#039; - The function registers the callback to call incase of any error.&lt;br /&gt;
* &#039;&#039;&#039;void UnregisterCallbacks ()&#039;&#039;&#039; - The function deregisters all the callbacks. It is called before closing the connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;void SendStreamData (float* data, uint32_t numdata)&#039;&#039;&#039; - The function accepts the channel &#039;&#039;data&#039;&#039; and the number of channels &#039;&#039;numdata&#039;&#039; and prepares the data by decimating it (if decimation factor is set) and by making packets with required number of blocks which are then sent to the client. &lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the UDP and TCP connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;bool HasClient ()&#039;&#039;&#039; - The function checks if there is a client connected to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; -  It stores the channel numbers which are to be streamed. The end of the array is defined by storing the last element as -1.&lt;br /&gt;
* &#039;&#039;&#039;int _numberOfChannelsToStream&#039;&#039;&#039; - It stores the number of channels to stream.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks for the command received from the client and calls the appropriate function to fulfill the client&#039;s request.&lt;br /&gt;
* &#039;&#039;&#039;void start_UDP_sever (std::uint16_t port)&#039;&#039;&#039; - The function opens up a UDP connection at the &#039;&#039;port&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== NatusClient ==&lt;br /&gt;
This class handles the client-side processing. It connects with the server/device, gets data from the operator module of the NatusADC and sends it to the server/device. It uses various commands as described in the NatusDataServer to set different parameters. Another important function of this class &#039;interpolateMissingBlocks&#039; linearly interpolates the missing UDP packets which contain the channel data values. Eg. &amp;lt;br/&amp;gt; &lt;br /&gt;
Consider the scenario where 1 block is sent per packet and decimation factor is 1. Suppose we received packet 1 and 3, packet 2 was lost. Data for packet 2 is interpolated as follows: &lt;br /&gt;
&amp;lt;br/&amp;gt; Interpolation formula&lt;br /&gt;
&#039;&#039;Interpolated Value = ((Current Packet value – Previous Packet value) / (Current Packet Number – Previous Packet Number)) * (Interpolated Packet Number – Previous Packet Number) + Previous Packet Value&#039;&#039;&lt;br /&gt;
[[File:Programming_Reference_NatusADC_Interpolation.png|center|500px|Linear Interpolation example]]&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;NatusDeviceInformation GetInformation ()&#039;&#039;&#039; - The function sends a CMD_GetInformation command to the server/device over TCP to query the sampling rate and number of channels of the device. It stores the received information in the &#039;&#039;NatusDeviceInformation&#039;&#039; struct type variable.&lt;br /&gt;
* &#039;&#039;&#039;void Connect (std::string server_name, int port)&#039;&#039;&#039; - The function establishes a TCP connection with the &#039;&#039;server_name&#039;&#039; server at port number &#039;&#039;port&#039;&#039; and calls the &#039;&#039;init_udp&#039;&#039; function to establish a UDP connection at port &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;bool TryConnect (std::string server_name, int port)&#039;&#039;&#039; - The function tries to establish a TCP and UDP connection again with the &#039;&#039;server_name&#039;&#039; if the connection is lost and returns &#039;&#039;true&#039;&#039; if the connection is successful otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the TCP and UDP connection with the server/device.&lt;br /&gt;
* &#039;&#039;&#039;void StartStream ()&#039;&#039;&#039; - The function sends the CMD_StartStream command to the server/device to request the channel stream data, which the server/device sends over the UDP.&lt;br /&gt;
* &#039;&#039;&#039;void StopStream ()&#039;&#039;&#039; -  The function sends the CMD_StopStream command to the server/device. &lt;br /&gt;
* &#039;&#039;&#039;uint8_t Ping (uint8_t ping)&#039;&#039;&#039; - The function sends a CMD_PING command to the sever/device with data stored in &#039;&#039;ping&#039;&#039; as payload.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* ReadStream ()&#039;&#039;&#039; - The function gets channel data blocks from the server/device through a UDP protocol, calls the &#039;&#039;interpolateMissingBlocks&#039;&#039; if there is any missing blocks, adds the block to the &#039;&#039;_receivequeue&#039;&#039; and returns the first block from the &#039;&#039;_receivequeue&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* create_natus_sampleblock (uint8_t* payload)&#039;&#039;&#039; - The function creates and returns a NatusSampleBlock structure variable from the payload passes. NatusSampleBlock contains block number, number of samples, samples and a boolean specifying whether the block was recieved from the server/device or was interpolated.&lt;br /&gt;
* &#039;&#039;&#039;void DeleteSampleBlock (NatusSampleBlock*)&#039;&#039;&#039; - The function free the space occupied by the NatusSampleBlock variable passed to it.&lt;br /&gt;
* &#039;&#039;&#039;void SetSampleBlockSize (uint32_t blocksize)&#039;&#039;&#039; - The function sends CMD_SetBlockSize command to the server/device to set number of blocks to be sent in a packet as &#039;&#039;blocksize&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void SetDecimationFactor (uint32_t decimationFactor)&#039;&#039;&#039; - The function sends CMD_SetDecimationFactor command to the server/device to set the decimation factor as &#039;&#039;decimationFactor&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation GetChannelInfo ()&#039;&#039;&#039; - The function sends CMD_GetChannelNames command to the server/device to query the channel and stream names of the device and stores them in a NatusChannelInformation structure.&lt;br /&gt;
* &#039;&#039;&#039;int GetDecimationFactor ()&#039;&#039;&#039; - The function queries from the server/device over TCP, the current decimation factor and returns it.&lt;br /&gt;
* &#039;&#039;&#039;int SelectChannelsToStream (std::string channels)&#039;&#039;&#039; -  The function sends CMD_SelectChannels command to the server/device along with the channels to stream stored in a space separated &#039;&#039;channels&#039;&#039; string.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; - It stores the channel numbers which are to be streamed.  &lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation channelInfo&#039;&#039;&#039; - The structure stores the channel and stream names of the device.  The NatusChannelInformation structure definition can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks if the data received from the server/device does not contain a CMD_ERR code.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* blockForPackage(uint32_t timeout)&#039;&#039;&#039; - The function waits to receive a TCP packet from server/device for the time specified by the &#039;&#039;timeout&#039;&#039; variable.&lt;br /&gt;
* &#039;&#039;&#039;std::queue&amp;lt;NatusSampleBlock*&amp;gt; _receivequeue&#039;&#039;&#039; - The queue stores the blocks received for processing.&lt;br /&gt;
* &#039;&#039;&#039;bool init_udp (int port)&#039;&#039;&#039; - The function creates and binds a UDP socket. If completed successfully, it returns &#039;&#039;true&#039;&#039;, otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock _prevblock&#039;&#039;&#039; - It stores the last data block received from the server/device and is used to check if any block is lost in between, when the client receives a new data block. &lt;br /&gt;
* &#039;&#039;&#039;void interpolateMissingBlocks (NatusSampleBlock*)&#039;&#039;&#039; - The function linearly interpolates any number of missing blocks between the current received data block and the last recieved data block.&lt;br /&gt;
* &#039;&#039;&#039;void emptyReceiveQueue ()&#039;&#039;&#039; - The function frees the memory occupied by the queue &#039;&#039;_receivequeue&#039;&#039; whenever the connection is closed or restarted.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[[Contributions:NatusADC]], [[User Reference:DataIOFilter]], [[Programming Reference:GenericADC Class]]&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8426</id>
		<title>Programming Reference:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8426"/>
		<updated>2019-07-29T20:10:34Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: /* TCP Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NatusADC module has 3 main classes - NatusPackageInterface, NatusDataServer and NatusClient. 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 serve/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 the BCI2000 where as NatusClient relies on BCI2000. &lt;br /&gt;
&lt;br /&gt;
== NatusPackageInterface ==&lt;br /&gt;
This class handles the communication between the server/device and the client. It should be included with both - NatusDataServer and NatusClient Class. The class performs the following functions -constructing TCP and UDP packets, calculating the CRC of a packet and checking the CRC on the receiving side, sending the packets over TCP/UDP port, receiving packets over TCP/UDP Port, reconstructing the data from the packets and listening for connections on device/server-side. &#039;&#039;Note - The file limits the maximum number of channels for a device (stored in MAX_NUM_CHANNELS in NatusPackageInterface.h) to 100.&#039;&#039;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The format of the packets constructed along with each field size is as follows:&lt;br /&gt;
[[File:Prog_Ref_NatusADC_Packet_format.png|center|600px|Packet format]]&lt;br /&gt;
&lt;br /&gt;
=== TCP Commands ===&lt;br /&gt;
The commands through which the NatusDataServer and NatusClient communicate are as follows:&lt;br /&gt;
; CMD_Ping : To check if the connection is successful and data can be sent and received.&lt;br /&gt;
* Command Number: 0x01&lt;br /&gt;
* Parameters/Payload: 0xff&lt;br /&gt;
* Return Value: returns payload &lt;br /&gt;
&lt;br /&gt;
; CMD_GetInformation : To send the device information such as the number of channels and sampling rate to the client.&lt;br /&gt;
* Command Number: 0x02&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusDeviceInformation which contains the number of channels, sampling rate, and device identifier.&lt;br /&gt;
&lt;br /&gt;
; CMD_GetChannelNames : To send the channel names as set by the device to the client. If no channel names are set, NULL is sent.&lt;br /&gt;
* Command Number: 0x03&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusChannelInformation which contains all the channels and stream names.&lt;br /&gt;
&lt;br /&gt;
; CMD_StartStream : To start sending channel data over UDP port.&lt;br /&gt;
* Command Number: 0x10&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_StopStream : To stop sending channel data&lt;br /&gt;
* Command Number: 0x1F&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SelectChannels : To send data only for the channels numbers mentioned in the payload. It corresponds to the SourceChList parameter.&lt;br /&gt;
* Command Number: 0x20&lt;br /&gt;
* Parameters/Payload: a list of channel numbers separated by space and stored in a string &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetBlockSize : To set the number of blocks to send per packet. It corresponds to the SeverBlockSize parameter.&lt;br /&gt;
* Command Number: 0x21&lt;br /&gt;
* Parameters/Payload: number of blocks to send per packet stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_GetDecimationFactor : To get the current decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x22&lt;br /&gt;
* Parameters/Payload: decimation factor stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetDecimationFactor : To set the decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x23&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: decimation factor stored in uint32_t datatype but casted into uint8_t datatype for transmission over TCP.&lt;br /&gt;
&lt;br /&gt;
; CMD_ERR : The command is sent if there is any type of error.&lt;br /&gt;
* Command Number: 0xFF&lt;br /&gt;
* Parameters/Payload: command which caused the error and the payload generated by the function handling the command.&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&amp;lt;u&amp;gt;Note:&amp;lt;/u&amp;gt; The packet format for this command is as follows: &lt;br /&gt;
[[File:Prog_Ref_NatusADC_CMD_ERR.png|center|Command CMD_ERR packet format.]]&lt;br /&gt;
&lt;br /&gt;
=== UDP Commands ===&lt;br /&gt;
; CMD_StreamPackage: The command is sent from the server/device to the client when only 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x11&lt;br /&gt;
* Parameters/Payload: Channel data of 1 block&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_VariableSizeStreamPackage: The command is sent from the server/device to the client when more than 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x12&lt;br /&gt;
* Parameters/Payload: Channel data of more than 1 block (number of blocks as set by the CMD_SetBlockSize command)&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Poll ()&#039;&#039;&#039; - The function runs on server/device and continuously waits for any command from the NatusClient over the TCP protocol.&lt;br /&gt;
* &#039;&#039;&#039;void send_data (uint8_t cmd, uint8_t* payload, uint32_t len_payload, bool isError=false, PackageType t = Control)&#039;&#039;&#039; - The function creates a packet using cmd (the command) and the payload. The default values for isError is false (i.e., no error) and PackageType is Control (TCP prototcol). The channel data is sent over Stream PackageType (i.e., UDP Protocol).&lt;br /&gt;
* &#039;&#039;&#039;virtual void data_received (CmdStruct * payload) = 0&#039;&#039;&#039; - The function should be implemented in the child classes to ensure proper processing, in respect ot the child class, of the data recieved via TCP or UDP protocol is done.&lt;br /&gt;
* &#039;&#039;&#039;void printMessage (std::string)&#039;&#039;&#039; - Print the string parameter on the warning window. &lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextPackage ()&#039;&#039;&#039; - The function gets a TCP packet (from the server or from the Client, as the case may be) and store in struct CmdStruct. Definietion of CmdStruct can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextUDPPackage ()&#039;&#039;&#039; - The function is same as CmdStruct* getNextPackage(), except that it received packet over UDP protocol.  &lt;br /&gt;
* &#039;&#039;&#039;void delete_cmdstruct (CmdStruct* )&#039;&#039;&#039; - The function frees the memory occupied by a CmdStruct pointer.&lt;br /&gt;
* &#039;&#039;&#039;void initWSA ()&#039;&#039;&#039; - The function initializes the Winsock. &lt;br /&gt;
* &#039;&#039;&#039;SOCKET connection&#039;&#039;&#039; - It stores the TCP socket connection, i.e, in server/device - the connection to the client and in client - the connection to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;SOCKET udpSocket&#039;&#039;&#039; - It stores the UDP socket connection.&lt;br /&gt;
* &#039;&#039;&#039;sockaddr_in _udpReceiver&#039;&#039;&#039; - It stores the socket address for IPv4.&lt;br /&gt;
&lt;br /&gt;
== NatusDataServer ==&lt;br /&gt;
This class handles the server-side processing. It performs the following functions - starts-up the TCP and UDP server, check for new connections, gracefully disconnects from the client, registers various callbacks on client connection and deregister the callbacks when the client disconnects and responds to the commands (described in the NatusPackageInterface section) from the client via TCP protocol.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Startup (std::uint16_t port)&#039;&#039;&#039; - The function starts up the server and listens for a TCP connection on the port number specified by &#039;&#039;port&#039;&#039; and a UDP connection on the port number &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void CheckForConnection ()&#039;&#039;&#039; - The function checks for a client connection request and accept it if there is one.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterDataStreamCallback (NatusDataStreamRequest, void*)&#039;&#039;&#039; - The function registers the callbacks to start &amp;amp; stop streams.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterInformationCallback (NatusInformationRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device information.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterChannelInformationCallback (NatusChannelInfoRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device&#039;s channels&#039; names.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterErrorCallback (NatusResponse, void*)&#039;&#039;&#039; - The function registers the callback to call incase of any error.&lt;br /&gt;
* &#039;&#039;&#039;void UnregisterCallbacks ()&#039;&#039;&#039; - The function deregisters all the callbacks. It is called before closing the connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;void SendStreamData (float* data, uint32_t numdata)&#039;&#039;&#039; - The function accepts the channel &#039;&#039;data&#039;&#039; and the number of channels &#039;&#039;numdata&#039;&#039; and prepares the data by decimating it (if decimation factor is set) and by making packets with required number of blocks which are then sent to the client. &lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the UDP and TCP connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;bool HasClient ()&#039;&#039;&#039; - The function checks if there is a client connected to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; -  It stores the channel numbers which are to be streamed. The end of the array is defined by storing the last element as -1.&lt;br /&gt;
* &#039;&#039;&#039;int _numberOfChannelsToStream&#039;&#039;&#039; - It stores the number of channels to stream.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks for the command received from the client and calls the appropriate function to fulfill the client&#039;s request.&lt;br /&gt;
* &#039;&#039;&#039;void start_UDP_sever (std::uint16_t port)&#039;&#039;&#039; - The function opens up a UDP connection at the &#039;&#039;port&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== NatusClient ==&lt;br /&gt;
This class handles the client-side processing. It connects with the server/device, gets data from the operator module of the NatusADC and sends it to the server/device. It uses various commands as described in the NatusDataServer to set different parameters. Another important function of this class &#039;interpolateMissingBlocks&#039; linearly interpolates the missing UDP packets which contain the channel data values. Eg. &amp;lt;br/&amp;gt; &lt;br /&gt;
Consider the scenario where 1 block is sent per packet and decimation factor is 1. Suppose we received packet 1 and 3, packet 2 was lost. Data for packet 2 is interpolated as follows: &lt;br /&gt;
&amp;lt;br/&amp;gt; Interpolation formula&lt;br /&gt;
&#039;&#039;Interpolated Value = ((Current Packet value – Previous Packet value) / (Current Packet Number – Previous Packet Number)) * (Interpolated Packet Number – Previous Packet Number) + Previous Packet Value&#039;&#039;&lt;br /&gt;
[[File:Programming_Reference_NatusADC_Interpolation.png|center|500px|Linear Interpolation example]]&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;NatusDeviceInformation GetInformation ()&#039;&#039;&#039; - The function sends a CMD_GetInformation command to the server/device over TCP to query the sampling rate and number of channels of the device. It stores the received information in the &#039;&#039;NatusDeviceInformation&#039;&#039; struct type variable.&lt;br /&gt;
* &#039;&#039;&#039;void Connect (std::string server_name, int port)&#039;&#039;&#039; - The function establishes a TCP connection with the &#039;&#039;server_name&#039;&#039; server at port number &#039;&#039;port&#039;&#039; and calls the &#039;&#039;init_udp&#039;&#039; function to establish a UDP connection at port &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;bool TryConnect (std::string server_name, int port)&#039;&#039;&#039; - The function tries to establish a TCP and UDP connection again with the &#039;&#039;server_name&#039;&#039; if the connection is lost and returns &#039;&#039;true&#039;&#039; if the connection is successful otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the TCP and UDP connection with the server/device.&lt;br /&gt;
* &#039;&#039;&#039;void StartStream ()&#039;&#039;&#039; - The function sends the CMD_StartStream command to the server/device to request the channel stream data, which the server/device sends over the UDP.&lt;br /&gt;
* &#039;&#039;&#039;void StopStream ()&#039;&#039;&#039; -  The function sends the CMD_StopStream command to the server/device. &lt;br /&gt;
* &#039;&#039;&#039;uint8_t Ping (uint8_t ping)&#039;&#039;&#039; - The function sends a CMD_PING command to the sever/device with data stored in &#039;&#039;ping&#039;&#039; as payload.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* ReadStream ()&#039;&#039;&#039; - The function gets channel data blocks from the server/device through a UDP protocol, calls the &#039;&#039;interpolateMissingBlocks&#039;&#039; if there is any missing blocks, adds the block to the &#039;&#039;_receivequeue&#039;&#039; and returns the first block from the &#039;&#039;_receivequeue&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* create_natus_sampleblock (uint8_t* payload)&#039;&#039;&#039; - The function creates and returns a NatusSampleBlock structure variable from the payload passes. NatusSampleBlock contains block number, number of samples, samples and a boolean specifying whether the block was recieved from the server/device or was interpolated.&lt;br /&gt;
* &#039;&#039;&#039;void DeleteSampleBlock (NatusSampleBlock*)&#039;&#039;&#039; - The function free the space occupied by the NatusSampleBlock variable passed to it.&lt;br /&gt;
* &#039;&#039;&#039;void SetSampleBlockSize (uint32_t blocksize)&#039;&#039;&#039; - The function sends CMD_SetBlockSize command to the server/device to set number of blocks to be sent in a packet as &#039;&#039;blocksize&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void SetDecimationFactor (uint32_t decimationFactor)&#039;&#039;&#039; - The function sends CMD_SetDecimationFactor command to the server/device to set the decimation factor as &#039;&#039;decimationFactor&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation GetChannelInfo ()&#039;&#039;&#039; - The function sends CMD_GetChannelNames command to the server/device to query the channel and stream names of the device and stores them in a NatusChannelInformation structure.&lt;br /&gt;
* &#039;&#039;&#039;int GetDecimationFactor ()&#039;&#039;&#039; - The function queries from the server/device over TCP, the current decimation factor and returns it.&lt;br /&gt;
* &#039;&#039;&#039;int SelectChannelsToStream (std::string channels)&#039;&#039;&#039; -  The function sends CMD_SelectChannels command to the server/device along with the channels to stream stored in a space separated &#039;&#039;channels&#039;&#039; string.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; - It stores the channel numbers which are to be streamed.  &lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation channelInfo&#039;&#039;&#039; - The structure stores the channel and stream names of the device.  The NatusChannelInformation structure definition can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks if the data received from the server/device does not contain a CMD_ERR code.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* blockForPackage(uint32_t timeout)&#039;&#039;&#039; - The function waits to receive a TCP packet from server/device for the time specified by the &#039;&#039;timeout&#039;&#039; variable.&lt;br /&gt;
* &#039;&#039;&#039;std::queue&amp;lt;NatusSampleBlock*&amp;gt; _receivequeue&#039;&#039;&#039; - The queue stores the blocks received for processing.&lt;br /&gt;
* &#039;&#039;&#039;bool init_udp (int port)&#039;&#039;&#039; - The function creates and binds a UDP socket. If completed successfully, it returns &#039;&#039;true&#039;&#039;, otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock _prevblock&#039;&#039;&#039; - It stores the last data block received from the server/device and is used to check if any block is lost in between, when the client receives a new data block. &lt;br /&gt;
* &#039;&#039;&#039;void interpolateMissingBlocks (NatusSampleBlock*)&#039;&#039;&#039; - The function linearly interpolates any number of missing blocks between the current received data block and the last recieved data block.&lt;br /&gt;
* &#039;&#039;&#039;void emptyReceiveQueue ()&#039;&#039;&#039; - The function frees the memory occupied by the queue &#039;&#039;_receivequeue&#039;&#039; whenever the connection is closed or restarted.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[[Contributions:NatusADC]], [[User Reference:DataIOFilter]], [[Programming Reference:GenericADC Class]]&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8425</id>
		<title>Programming Reference:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8425"/>
		<updated>2019-07-29T20:08:15Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: /* TCP Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NatusADC module has 3 main classes - NatusPackageInterface, NatusDataServer and NatusClient. 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 serve/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 the BCI2000 where as NatusClient relies on BCI2000. &lt;br /&gt;
&lt;br /&gt;
== NatusPackageInterface ==&lt;br /&gt;
This class handles the communication between the server/device and the client. It should be included with both - NatusDataServer and NatusClient Class. The class performs the following functions -constructing TCP and UDP packets, calculating the CRC of a packet and checking the CRC on the receiving side, sending the packets over TCP/UDP port, receiving packets over TCP/UDP Port, reconstructing the data from the packets and listening for connections on device/server-side. &#039;&#039;Note - The file limits the maximum number of channels for a device (stored in MAX_NUM_CHANNELS in NatusPackageInterface.h) to 100.&#039;&#039;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The format of the packets constructed along with each field size is as follows:&lt;br /&gt;
[[File:Prog_Ref_NatusADC_Packet_format.png|center|600px|Packet format]]&lt;br /&gt;
&lt;br /&gt;
=== TCP Commands ===&lt;br /&gt;
The commands through which the NatusDataServer and NatusClient communicate are as follows:&lt;br /&gt;
; CMD_Ping : To check if the connection is successful and data can be sent and received.&lt;br /&gt;
* Command Number: 0x01&lt;br /&gt;
* Parameters/Payload: 0xff&lt;br /&gt;
* Return Value: returns payload &lt;br /&gt;
&lt;br /&gt;
; CMD_GetInformation : To send the device information such as the number of channels and sampling rate to the client.&lt;br /&gt;
* Command Number: 0x02&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusDeviceInformation which contains the number of channels, sampling rate, and device identifier.&lt;br /&gt;
&lt;br /&gt;
; CMD_GetChannelNames : To send the channel names as set by the device to the client. If no channel names are set, NULL is sent.&lt;br /&gt;
* Command Number: 0x03&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusChannelInformation which contains all the channels and stream names.&lt;br /&gt;
&lt;br /&gt;
; CMD_StartStream : To start sending channel data over UDP port.&lt;br /&gt;
* Command Number: 0x10&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_StopStream : To stop sending channel data&lt;br /&gt;
* Command Number: 0x1F&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SelectChannels : To send data only for the channels numbers mentioned in the payload&lt;br /&gt;
* Command Number: 0x20&lt;br /&gt;
* Parameters/Payload: a list of channel numbers separated by space and stored in a string &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetBlockSize : To set the number of blocks to send per packet. It corresponds to the SeverBlockSize parameter.&lt;br /&gt;
* Command Number: 0x21&lt;br /&gt;
* Parameters/Payload: number of blocks to send per packet stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_GetDecimationFactor : To get the current decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x22&lt;br /&gt;
* Parameters/Payload: decimation factor stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetDecimationFactor : To set the decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x23&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: decimation factor stored in uint32_t datatype but casted into uint8_t datatype for transmission over TCP.&lt;br /&gt;
&lt;br /&gt;
; CMD_ERR : The command is sent if there is any type of error.&lt;br /&gt;
* Command Number: 0xFF&lt;br /&gt;
* Parameters/Payload: command which caused the error and the payload generated by the function handling the command.&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&amp;lt;u&amp;gt;Note:&amp;lt;/u&amp;gt; The packet format for this command is as follows: &lt;br /&gt;
[[File:Prog_Ref_NatusADC_CMD_ERR.png|center|Command CMD_ERR packet format.]]&lt;br /&gt;
&lt;br /&gt;
=== UDP Commands ===&lt;br /&gt;
; CMD_StreamPackage: The command is sent from the server/device to the client when only 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x11&lt;br /&gt;
* Parameters/Payload: Channel data of 1 block&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_VariableSizeStreamPackage: The command is sent from the server/device to the client when more than 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x12&lt;br /&gt;
* Parameters/Payload: Channel data of more than 1 block (number of blocks as set by the CMD_SetBlockSize command)&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Poll ()&#039;&#039;&#039; - The function runs on server/device and continuously waits for any command from the NatusClient over the TCP protocol.&lt;br /&gt;
* &#039;&#039;&#039;void send_data (uint8_t cmd, uint8_t* payload, uint32_t len_payload, bool isError=false, PackageType t = Control)&#039;&#039;&#039; - The function creates a packet using cmd (the command) and the payload. The default values for isError is false (i.e., no error) and PackageType is Control (TCP prototcol). The channel data is sent over Stream PackageType (i.e., UDP Protocol).&lt;br /&gt;
* &#039;&#039;&#039;virtual void data_received (CmdStruct * payload) = 0&#039;&#039;&#039; - The function should be implemented in the child classes to ensure proper processing, in respect ot the child class, of the data recieved via TCP or UDP protocol is done.&lt;br /&gt;
* &#039;&#039;&#039;void printMessage (std::string)&#039;&#039;&#039; - Print the string parameter on the warning window. &lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextPackage ()&#039;&#039;&#039; - The function gets a TCP packet (from the server or from the Client, as the case may be) and store in struct CmdStruct. Definietion of CmdStruct can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextUDPPackage ()&#039;&#039;&#039; - The function is same as CmdStruct* getNextPackage(), except that it received packet over UDP protocol.  &lt;br /&gt;
* &#039;&#039;&#039;void delete_cmdstruct (CmdStruct* )&#039;&#039;&#039; - The function frees the memory occupied by a CmdStruct pointer.&lt;br /&gt;
* &#039;&#039;&#039;void initWSA ()&#039;&#039;&#039; - The function initializes the Winsock. &lt;br /&gt;
* &#039;&#039;&#039;SOCKET connection&#039;&#039;&#039; - It stores the TCP socket connection, i.e, in server/device - the connection to the client and in client - the connection to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;SOCKET udpSocket&#039;&#039;&#039; - It stores the UDP socket connection.&lt;br /&gt;
* &#039;&#039;&#039;sockaddr_in _udpReceiver&#039;&#039;&#039; - It stores the socket address for IPv4.&lt;br /&gt;
&lt;br /&gt;
== NatusDataServer ==&lt;br /&gt;
This class handles the server-side processing. It performs the following functions - starts-up the TCP and UDP server, check for new connections, gracefully disconnects from the client, registers various callbacks on client connection and deregister the callbacks when the client disconnects and responds to the commands (described in the NatusPackageInterface section) from the client via TCP protocol.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Startup (std::uint16_t port)&#039;&#039;&#039; - The function starts up the server and listens for a TCP connection on the port number specified by &#039;&#039;port&#039;&#039; and a UDP connection on the port number &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void CheckForConnection ()&#039;&#039;&#039; - The function checks for a client connection request and accept it if there is one.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterDataStreamCallback (NatusDataStreamRequest, void*)&#039;&#039;&#039; - The function registers the callbacks to start &amp;amp; stop streams.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterInformationCallback (NatusInformationRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device information.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterChannelInformationCallback (NatusChannelInfoRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device&#039;s channels&#039; names.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterErrorCallback (NatusResponse, void*)&#039;&#039;&#039; - The function registers the callback to call incase of any error.&lt;br /&gt;
* &#039;&#039;&#039;void UnregisterCallbacks ()&#039;&#039;&#039; - The function deregisters all the callbacks. It is called before closing the connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;void SendStreamData (float* data, uint32_t numdata)&#039;&#039;&#039; - The function accepts the channel &#039;&#039;data&#039;&#039; and the number of channels &#039;&#039;numdata&#039;&#039; and prepares the data by decimating it (if decimation factor is set) and by making packets with required number of blocks which are then sent to the client. &lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the UDP and TCP connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;bool HasClient ()&#039;&#039;&#039; - The function checks if there is a client connected to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; -  It stores the channel numbers which are to be streamed. The end of the array is defined by storing the last element as -1.&lt;br /&gt;
* &#039;&#039;&#039;int _numberOfChannelsToStream&#039;&#039;&#039; - It stores the number of channels to stream.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks for the command received from the client and calls the appropriate function to fulfill the client&#039;s request.&lt;br /&gt;
* &#039;&#039;&#039;void start_UDP_sever (std::uint16_t port)&#039;&#039;&#039; - The function opens up a UDP connection at the &#039;&#039;port&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== NatusClient ==&lt;br /&gt;
This class handles the client-side processing. It connects with the server/device, gets data from the operator module of the NatusADC and sends it to the server/device. It uses various commands as described in the NatusDataServer to set different parameters. Another important function of this class &#039;interpolateMissingBlocks&#039; linearly interpolates the missing UDP packets which contain the channel data values. Eg. &amp;lt;br/&amp;gt; &lt;br /&gt;
Consider the scenario where 1 block is sent per packet and decimation factor is 1. Suppose we received packet 1 and 3, packet 2 was lost. Data for packet 2 is interpolated as follows: &lt;br /&gt;
&amp;lt;br/&amp;gt; Interpolation formula&lt;br /&gt;
&#039;&#039;Interpolated Value = ((Current Packet value – Previous Packet value) / (Current Packet Number – Previous Packet Number)) * (Interpolated Packet Number – Previous Packet Number) + Previous Packet Value&#039;&#039;&lt;br /&gt;
[[File:Programming_Reference_NatusADC_Interpolation.png|center|500px|Linear Interpolation example]]&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;NatusDeviceInformation GetInformation ()&#039;&#039;&#039; - The function sends a CMD_GetInformation command to the server/device over TCP to query the sampling rate and number of channels of the device. It stores the received information in the &#039;&#039;NatusDeviceInformation&#039;&#039; struct type variable.&lt;br /&gt;
* &#039;&#039;&#039;void Connect (std::string server_name, int port)&#039;&#039;&#039; - The function establishes a TCP connection with the &#039;&#039;server_name&#039;&#039; server at port number &#039;&#039;port&#039;&#039; and calls the &#039;&#039;init_udp&#039;&#039; function to establish a UDP connection at port &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;bool TryConnect (std::string server_name, int port)&#039;&#039;&#039; - The function tries to establish a TCP and UDP connection again with the &#039;&#039;server_name&#039;&#039; if the connection is lost and returns &#039;&#039;true&#039;&#039; if the connection is successful otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the TCP and UDP connection with the server/device.&lt;br /&gt;
* &#039;&#039;&#039;void StartStream ()&#039;&#039;&#039; - The function sends the CMD_StartStream command to the server/device to request the channel stream data, which the server/device sends over the UDP.&lt;br /&gt;
* &#039;&#039;&#039;void StopStream ()&#039;&#039;&#039; -  The function sends the CMD_StopStream command to the server/device. &lt;br /&gt;
* &#039;&#039;&#039;uint8_t Ping (uint8_t ping)&#039;&#039;&#039; - The function sends a CMD_PING command to the sever/device with data stored in &#039;&#039;ping&#039;&#039; as payload.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* ReadStream ()&#039;&#039;&#039; - The function gets channel data blocks from the server/device through a UDP protocol, calls the &#039;&#039;interpolateMissingBlocks&#039;&#039; if there is any missing blocks, adds the block to the &#039;&#039;_receivequeue&#039;&#039; and returns the first block from the &#039;&#039;_receivequeue&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* create_natus_sampleblock (uint8_t* payload)&#039;&#039;&#039; - The function creates and returns a NatusSampleBlock structure variable from the payload passes. NatusSampleBlock contains block number, number of samples, samples and a boolean specifying whether the block was recieved from the server/device or was interpolated.&lt;br /&gt;
* &#039;&#039;&#039;void DeleteSampleBlock (NatusSampleBlock*)&#039;&#039;&#039; - The function free the space occupied by the NatusSampleBlock variable passed to it.&lt;br /&gt;
* &#039;&#039;&#039;void SetSampleBlockSize (uint32_t blocksize)&#039;&#039;&#039; - The function sends CMD_SetBlockSize command to the server/device to set number of blocks to be sent in a packet as &#039;&#039;blocksize&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void SetDecimationFactor (uint32_t decimationFactor)&#039;&#039;&#039; - The function sends CMD_SetDecimationFactor command to the server/device to set the decimation factor as &#039;&#039;decimationFactor&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation GetChannelInfo ()&#039;&#039;&#039; - The function sends CMD_GetChannelNames command to the server/device to query the channel and stream names of the device and stores them in a NatusChannelInformation structure.&lt;br /&gt;
* &#039;&#039;&#039;int GetDecimationFactor ()&#039;&#039;&#039; - The function queries from the server/device over TCP, the current decimation factor and returns it.&lt;br /&gt;
* &#039;&#039;&#039;int SelectChannelsToStream (std::string channels)&#039;&#039;&#039; -  The function sends CMD_SelectChannels command to the server/device along with the channels to stream stored in a space separated &#039;&#039;channels&#039;&#039; string.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; - It stores the channel numbers which are to be streamed.  &lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation channelInfo&#039;&#039;&#039; - The structure stores the channel and stream names of the device.  The NatusChannelInformation structure definition can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks if the data received from the server/device does not contain a CMD_ERR code.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* blockForPackage(uint32_t timeout)&#039;&#039;&#039; - The function waits to receive a TCP packet from server/device for the time specified by the &#039;&#039;timeout&#039;&#039; variable.&lt;br /&gt;
* &#039;&#039;&#039;std::queue&amp;lt;NatusSampleBlock*&amp;gt; _receivequeue&#039;&#039;&#039; - The queue stores the blocks received for processing.&lt;br /&gt;
* &#039;&#039;&#039;bool init_udp (int port)&#039;&#039;&#039; - The function creates and binds a UDP socket. If completed successfully, it returns &#039;&#039;true&#039;&#039;, otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock _prevblock&#039;&#039;&#039; - It stores the last data block received from the server/device and is used to check if any block is lost in between, when the client receives a new data block. &lt;br /&gt;
* &#039;&#039;&#039;void interpolateMissingBlocks (NatusSampleBlock*)&#039;&#039;&#039; - The function linearly interpolates any number of missing blocks between the current received data block and the last recieved data block.&lt;br /&gt;
* &#039;&#039;&#039;void emptyReceiveQueue ()&#039;&#039;&#039; - The function frees the memory occupied by the queue &#039;&#039;_receivequeue&#039;&#039; whenever the connection is closed or restarted.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[[Contributions:NatusADC]], [[User Reference:DataIOFilter]], [[Programming Reference:GenericADC Class]]&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8424</id>
		<title>Programming Reference:NatusADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:NatusADC&amp;diff=8424"/>
		<updated>2019-07-29T19:58:10Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NatusADC module has 3 main classes - NatusPackageInterface, NatusDataServer and NatusClient. 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 serve/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 the BCI2000 where as NatusClient relies on BCI2000. &lt;br /&gt;
&lt;br /&gt;
== NatusPackageInterface ==&lt;br /&gt;
This class handles the communication between the server/device and the client. It should be included with both - NatusDataServer and NatusClient Class. The class performs the following functions -constructing TCP and UDP packets, calculating the CRC of a packet and checking the CRC on the receiving side, sending the packets over TCP/UDP port, receiving packets over TCP/UDP Port, reconstructing the data from the packets and listening for connections on device/server-side. &#039;&#039;Note - The file limits the maximum number of channels for a device (stored in MAX_NUM_CHANNELS in NatusPackageInterface.h) to 100.&#039;&#039;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The format of the packets constructed along with each field size is as follows:&lt;br /&gt;
[[File:Prog_Ref_NatusADC_Packet_format.png|center|600px|Packet format]]&lt;br /&gt;
&lt;br /&gt;
=== TCP Commands ===&lt;br /&gt;
The commands through which the NatusDataServer and NatusClient communicate are as follows:&lt;br /&gt;
; CMD_Ping : To check if the connection is successful and data can be sent and received.&lt;br /&gt;
* Command Number: 0x01&lt;br /&gt;
* Parameters/Payload: 0xff&lt;br /&gt;
* Return Value: returns payload &lt;br /&gt;
&lt;br /&gt;
; CMD_GetInformation : To send the device information such as the number of channels and sampling rate to the client.&lt;br /&gt;
* Command Number: 0x02&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusDeviceInformation which contains the number of channels, sampling rate, and device identifier.&lt;br /&gt;
&lt;br /&gt;
; CMD_GetChannelNames : To send the channel names as set by the device to the client. If no channel names are set, NULL is sent.&lt;br /&gt;
* Command Number: 0x03&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: struct NatusChannelInformation which contains all the channels and stream names.&lt;br /&gt;
&lt;br /&gt;
; CMD_StartStream : To start sending channel data over UDP port.&lt;br /&gt;
* Command Number: 0x10&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_StopStream : To stop sending channel data&lt;br /&gt;
* Command Number: 0x1F&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SelectChannels : To send data only for the channels numbers mentioned in the payload&lt;br /&gt;
* Command Number: 0x20&lt;br /&gt;
* Parameters/Payload: a list of channel numbers separated by space and stored in a string &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetBlockSize : To set the number of blocks to send per packet.&lt;br /&gt;
* Command Number: 0x21&lt;br /&gt;
* Parameters/Payload: number of blocks to send per packet stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_GetDecimationFactor : To get the current decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x22&lt;br /&gt;
* Parameters/Payload: decimation factor stored in uint32_t datatype. &lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_SetDecimationFactor : To set the decimation factor of the device/server.&lt;br /&gt;
* Command Number: 0x23&lt;br /&gt;
* Parameters/Payload: NULL &lt;br /&gt;
* Return Value: decimation factor stored in uint32_t datatype but casted into uint8_t datatype for transmission over TCP.&lt;br /&gt;
&lt;br /&gt;
; CMD_ERR : The command is sent if there is any type of error.&lt;br /&gt;
* Command Number: 0xFF&lt;br /&gt;
* Parameters/Payload: command which caused the error and the payload generated by the function handling the command.&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&amp;lt;u&amp;gt;Note:&amp;lt;/u&amp;gt; The packet format for this command is as follows: &lt;br /&gt;
[[File:Prog_Ref_NatusADC_CMD_ERR.png|center|Command CMD_ERR packet format.]]&lt;br /&gt;
=== UDP Commands ===&lt;br /&gt;
; CMD_StreamPackage: The command is sent from the server/device to the client when only 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x11&lt;br /&gt;
* Parameters/Payload: Channel data of 1 block&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
; CMD_VariableSizeStreamPackage: The command is sent from the server/device to the client when more than 1 block per packet is sent.&lt;br /&gt;
* Command Number: 0x12&lt;br /&gt;
* Parameters/Payload: Channel data of more than 1 block (number of blocks as set by the CMD_SetBlockSize command)&lt;br /&gt;
* Return Value: NULL&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Poll ()&#039;&#039;&#039; - The function runs on server/device and continuously waits for any command from the NatusClient over the TCP protocol.&lt;br /&gt;
* &#039;&#039;&#039;void send_data (uint8_t cmd, uint8_t* payload, uint32_t len_payload, bool isError=false, PackageType t = Control)&#039;&#039;&#039; - The function creates a packet using cmd (the command) and the payload. The default values for isError is false (i.e., no error) and PackageType is Control (TCP prototcol). The channel data is sent over Stream PackageType (i.e., UDP Protocol).&lt;br /&gt;
* &#039;&#039;&#039;virtual void data_received (CmdStruct * payload) = 0&#039;&#039;&#039; - The function should be implemented in the child classes to ensure proper processing, in respect ot the child class, of the data recieved via TCP or UDP protocol is done.&lt;br /&gt;
* &#039;&#039;&#039;void printMessage (std::string)&#039;&#039;&#039; - Print the string parameter on the warning window. &lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextPackage ()&#039;&#039;&#039; - The function gets a TCP packet (from the server or from the Client, as the case may be) and store in struct CmdStruct. Definietion of CmdStruct can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* getNextUDPPackage ()&#039;&#039;&#039; - The function is same as CmdStruct* getNextPackage(), except that it received packet over UDP protocol.  &lt;br /&gt;
* &#039;&#039;&#039;void delete_cmdstruct (CmdStruct* )&#039;&#039;&#039; - The function frees the memory occupied by a CmdStruct pointer.&lt;br /&gt;
* &#039;&#039;&#039;void initWSA ()&#039;&#039;&#039; - The function initializes the Winsock. &lt;br /&gt;
* &#039;&#039;&#039;SOCKET connection&#039;&#039;&#039; - It stores the TCP socket connection, i.e, in server/device - the connection to the client and in client - the connection to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;SOCKET udpSocket&#039;&#039;&#039; - It stores the UDP socket connection.&lt;br /&gt;
* &#039;&#039;&#039;sockaddr_in _udpReceiver&#039;&#039;&#039; - It stores the socket address for IPv4.&lt;br /&gt;
&lt;br /&gt;
== NatusDataServer ==&lt;br /&gt;
This class handles the server-side processing. It performs the following functions - starts-up the TCP and UDP server, check for new connections, gracefully disconnects from the client, registers various callbacks on client connection and deregister the callbacks when the client disconnects and responds to the commands (described in the NatusPackageInterface section) from the client via TCP protocol.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables  ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;void Startup (std::uint16_t port)&#039;&#039;&#039; - The function starts up the server and listens for a TCP connection on the port number specified by &#039;&#039;port&#039;&#039; and a UDP connection on the port number &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void CheckForConnection ()&#039;&#039;&#039; - The function checks for a client connection request and accept it if there is one.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterDataStreamCallback (NatusDataStreamRequest, void*)&#039;&#039;&#039; - The function registers the callbacks to start &amp;amp; stop streams.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterInformationCallback (NatusInformationRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device information.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterChannelInformationCallback (NatusChannelInfoRequest, void*)&#039;&#039;&#039; - The function registers the callback to get the device&#039;s channels&#039; names.&lt;br /&gt;
* &#039;&#039;&#039;void RegisterErrorCallback (NatusResponse, void*)&#039;&#039;&#039; - The function registers the callback to call incase of any error.&lt;br /&gt;
* &#039;&#039;&#039;void UnregisterCallbacks ()&#039;&#039;&#039; - The function deregisters all the callbacks. It is called before closing the connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;void SendStreamData (float* data, uint32_t numdata)&#039;&#039;&#039; - The function accepts the channel &#039;&#039;data&#039;&#039; and the number of channels &#039;&#039;numdata&#039;&#039; and prepares the data by decimating it (if decimation factor is set) and by making packets with required number of blocks which are then sent to the client. &lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the UDP and TCP connection with the client.&lt;br /&gt;
* &#039;&#039;&#039;bool HasClient ()&#039;&#039;&#039; - The function checks if there is a client connected to the server/device.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; -  It stores the channel numbers which are to be streamed. The end of the array is defined by storing the last element as -1.&lt;br /&gt;
* &#039;&#039;&#039;int _numberOfChannelsToStream&#039;&#039;&#039; - It stores the number of channels to stream.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks for the command received from the client and calls the appropriate function to fulfill the client&#039;s request.&lt;br /&gt;
* &#039;&#039;&#039;void start_UDP_sever (std::uint16_t port)&#039;&#039;&#039; - The function opens up a UDP connection at the &#039;&#039;port&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== NatusClient ==&lt;br /&gt;
This class handles the client-side processing. It connects with the server/device, gets data from the operator module of the NatusADC and sends it to the server/device. It uses various commands as described in the NatusDataServer to set different parameters. Another important function of this class &#039;interpolateMissingBlocks&#039; linearly interpolates the missing UDP packets which contain the channel data values. Eg. &amp;lt;br/&amp;gt; &lt;br /&gt;
Consider the scenario where 1 block is sent per packet and decimation factor is 1. Suppose we received packet 1 and 3, packet 2 was lost. Data for packet 2 is interpolated as follows: &lt;br /&gt;
&amp;lt;br/&amp;gt; Interpolation formula&lt;br /&gt;
&#039;&#039;Interpolated Value = ((Current Packet value – Previous Packet value) / (Current Packet Number – Previous Packet Number)) * (Interpolated Packet Number – Previous Packet Number) + Previous Packet Value&#039;&#039;&lt;br /&gt;
[[File:Programming_Reference_NatusADC_Interpolation.png|center|500px|Linear Interpolation example]]&lt;br /&gt;
&lt;br /&gt;
=== Functions and Variables ===&lt;br /&gt;
The public and protected functions and variables defined in this class are as follows: &lt;br /&gt;
* &#039;&#039;&#039;NatusDeviceInformation GetInformation ()&#039;&#039;&#039; - The function sends a CMD_GetInformation command to the server/device over TCP to query the sampling rate and number of channels of the device. It stores the received information in the &#039;&#039;NatusDeviceInformation&#039;&#039; struct type variable.&lt;br /&gt;
* &#039;&#039;&#039;void Connect (std::string server_name, int port)&#039;&#039;&#039; - The function establishes a TCP connection with the &#039;&#039;server_name&#039;&#039; server at port number &#039;&#039;port&#039;&#039; and calls the &#039;&#039;init_udp&#039;&#039; function to establish a UDP connection at port &#039;&#039;port+1&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;bool TryConnect (std::string server_name, int port)&#039;&#039;&#039; - The function tries to establish a TCP and UDP connection again with the &#039;&#039;server_name&#039;&#039; if the connection is lost and returns &#039;&#039;true&#039;&#039; if the connection is successful otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void Disconnect ()&#039;&#039;&#039; - The function gracefully closes the TCP and UDP connection with the server/device.&lt;br /&gt;
* &#039;&#039;&#039;void StartStream ()&#039;&#039;&#039; - The function sends the CMD_StartStream command to the server/device to request the channel stream data, which the server/device sends over the UDP.&lt;br /&gt;
* &#039;&#039;&#039;void StopStream ()&#039;&#039;&#039; -  The function sends the CMD_StopStream command to the server/device. &lt;br /&gt;
* &#039;&#039;&#039;uint8_t Ping (uint8_t ping)&#039;&#039;&#039; - The function sends a CMD_PING command to the sever/device with data stored in &#039;&#039;ping&#039;&#039; as payload.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* ReadStream ()&#039;&#039;&#039; - The function gets channel data blocks from the server/device through a UDP protocol, calls the &#039;&#039;interpolateMissingBlocks&#039;&#039; if there is any missing blocks, adds the block to the &#039;&#039;_receivequeue&#039;&#039; and returns the first block from the &#039;&#039;_receivequeue&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock* create_natus_sampleblock (uint8_t* payload)&#039;&#039;&#039; - The function creates and returns a NatusSampleBlock structure variable from the payload passes. NatusSampleBlock contains block number, number of samples, samples and a boolean specifying whether the block was recieved from the server/device or was interpolated.&lt;br /&gt;
* &#039;&#039;&#039;void DeleteSampleBlock (NatusSampleBlock*)&#039;&#039;&#039; - The function free the space occupied by the NatusSampleBlock variable passed to it.&lt;br /&gt;
* &#039;&#039;&#039;void SetSampleBlockSize (uint32_t blocksize)&#039;&#039;&#039; - The function sends CMD_SetBlockSize command to the server/device to set number of blocks to be sent in a packet as &#039;&#039;blocksize&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;void SetDecimationFactor (uint32_t decimationFactor)&#039;&#039;&#039; - The function sends CMD_SetDecimationFactor command to the server/device to set the decimation factor as &#039;&#039;decimationFactor&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation GetChannelInfo ()&#039;&#039;&#039; - The function sends CMD_GetChannelNames command to the server/device to query the channel and stream names of the device and stores them in a NatusChannelInformation structure.&lt;br /&gt;
* &#039;&#039;&#039;int GetDecimationFactor ()&#039;&#039;&#039; - The function queries from the server/device over TCP, the current decimation factor and returns it.&lt;br /&gt;
* &#039;&#039;&#039;int SelectChannelsToStream (std::string channels)&#039;&#039;&#039; -  The function sends CMD_SelectChannels command to the server/device along with the channels to stream stored in a space separated &#039;&#039;channels&#039;&#039; string.&lt;br /&gt;
* &#039;&#039;&#039;int _channelsToStream[MAX_NUM_CHANNELS]&#039;&#039;&#039; - It stores the channel numbers which are to be streamed.  &lt;br /&gt;
* &#039;&#039;&#039;NatusChannelInformation channelInfo&#039;&#039;&#039; - The structure stores the channel and stream names of the device.  The NatusChannelInformation structure definition can be found in &#039;&#039;NatusPackageInterface.h&#039;&#039; file.&lt;br /&gt;
* &#039;&#039;&#039;void data_received (CmdStruct *payload)&#039;&#039;&#039; - The function checks if the data received from the server/device does not contain a CMD_ERR code.&lt;br /&gt;
* &#039;&#039;&#039;CmdStruct* blockForPackage(uint32_t timeout)&#039;&#039;&#039; - The function waits to receive a TCP packet from server/device for the time specified by the &#039;&#039;timeout&#039;&#039; variable.&lt;br /&gt;
* &#039;&#039;&#039;std::queue&amp;lt;NatusSampleBlock*&amp;gt; _receivequeue&#039;&#039;&#039; - The queue stores the blocks received for processing.&lt;br /&gt;
* &#039;&#039;&#039;bool init_udp (int port)&#039;&#039;&#039; - The function creates and binds a UDP socket. If completed successfully, it returns &#039;&#039;true&#039;&#039;, otherwise &#039;&#039;false&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;NatusSampleBlock _prevblock&#039;&#039;&#039; - It stores the last data block received from the server/device and is used to check if any block is lost in between, when the client receives a new data block. &lt;br /&gt;
* &#039;&#039;&#039;void interpolateMissingBlocks (NatusSampleBlock*)&#039;&#039;&#039; - The function linearly interpolates any number of missing blocks between the current received data block and the last recieved data block.&lt;br /&gt;
* &#039;&#039;&#039;void emptyReceiveQueue ()&#039;&#039;&#039; - The function frees the memory occupied by the queue &#039;&#039;_receivequeue&#039;&#039; whenever the connection is closed or restarted.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[[Contributions:NatusADC]], [[User Reference:DataIOFilter]], [[Programming Reference:GenericADC Class]]&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8418</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8418"/>
		<updated>2019-07-26T20:32:28Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCIStart ===&lt;br /&gt;
The 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 the 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;
&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;
=== BCIUpdateState ===&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the Custom Components, 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Make sure you don&#039;t run the experiments on full screen if you are using a single screen. &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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8417</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8417"/>
		<updated>2019-07-26T19:38:13Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCIStart ===&lt;br /&gt;
The 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 the 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;
&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;
=== BCIUpdateState ===&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&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 &#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 &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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 and in the builder view, under the Custom Components, 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8416</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8416"/>
		<updated>2019-07-26T19:31:10Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCIStart ===&lt;br /&gt;
The 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 the 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;
&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;
=== BCIUpdateState ===&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; from &#039;&#039;src/contrib/PsychoPy Components&#039;&#039; directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;
Start Psychopy application and in the builder view, under the Custom Components, 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8415</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8415"/>
		<updated>2019-07-26T19:08:07Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1].&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCIStart ===&lt;br /&gt;
The 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 the 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;
&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;
=== BCIUpdateState ===&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;
Start Psychopy application and in the builder view, under the Custom Components, 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8414</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8414"/>
		<updated>2019-07-26T18:57:41Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1]&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCIStart ===&lt;br /&gt;
The 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 the 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;
&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;
=== BCIUpdateState ===&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;
Start Psychopy application and in the builder view, under the Custom Components, 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;
[[File:PsychoPy_Start.png|alt=&amp;quot;PsychoPy Homepage with BCI2000 Components&amp;quot;|PsychoPy Homepage with BCI2000 Components]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [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;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:BCI2000UpdateState.png&amp;diff=8413</id>
		<title>File:BCI2000UpdateState.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:BCI2000UpdateState.png&amp;diff=8413"/>
		<updated>2019-07-26T18:47:44Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: Dashmeetkaur uploaded a new version of File:BCI2000UpdateState.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:BCI2000Start.png&amp;diff=8412</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=8412"/>
		<updated>2019-07-26T18:47:10Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: Dashmeetkaur uploaded a new version of File:BCI2000Start.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPy_Start.png&amp;diff=8411</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=8411"/>
		<updated>2019-07-26T18:46:07Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: Dashmeetkaur uploaded a new version of File:PsychoPy Start.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:PsychoPy_Start.png&amp;diff=8410</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=8410"/>
		<updated>2019-07-26T18:44:58Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:BCI2000UpdateState.png&amp;diff=8409</id>
		<title>File:BCI2000UpdateState.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:BCI2000UpdateState.png&amp;diff=8409"/>
		<updated>2019-07-26T18:44:40Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:BCI2000Start.png&amp;diff=8408</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=8408"/>
		<updated>2019-07-26T18:44:22Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8407</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8407"/>
		<updated>2019-07-26T18:42:55Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1]&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
=== BCIStart ===&lt;br /&gt;
The 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 the 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;
&lt;br /&gt;
&lt;br /&gt;
=== BCIUpdateState ===&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8406</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8406"/>
		<updated>2019-07-26T18:39:13Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
&lt;br /&gt;
==== BCIStart ====&lt;br /&gt;
The 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 the 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;
&lt;br /&gt;
&lt;br /&gt;
==== BCIUpdateState ====&lt;br /&gt;
The 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 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 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 variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8405</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8405"/>
		<updated>2019-07-26T18:36:31Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
&lt;br /&gt;
==== BCIStart ====&lt;br /&gt;
The 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 the 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;
&lt;br /&gt;
&lt;br /&gt;
==== BCIUpdateState ====&lt;br /&gt;
The 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 be set OR the variable which contains the new value of the state. &#039;&#039;&#039;Note-&#039;&#039;&#039; the variables are 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. &lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases, where the variable is not available and the users want more control over how the state is updated. &#039;&#039;&#039;Note-&#039;&#039;&#039; the user would have to use commands like &#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;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8404</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8404"/>
		<updated>2019-07-26T18:24:44Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
&lt;br /&gt;
==== BCIStart ====&lt;br /&gt;
The 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 the 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;
&lt;br /&gt;
&lt;br /&gt;
==== BCIUpdateState ====&lt;br /&gt;
The 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 be set OR the variable which contains the new value of the state. Note - the variables are 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. &lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases, where the variable is not available and the users want more control over how the state is updated. Note - the user would have to use commands like &#039;&#039;bci.Execute&#039;&#039; and &#039;&#039;SET STATE&#039;&#039; to update the state in such cases. See this for more details.&lt;br /&gt;
&lt;br /&gt;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;&lt;br /&gt;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== Usage == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8403</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8403"/>
		<updated>2019-07-26T18:18:28Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
&lt;br /&gt;
==== BCIStart ====&lt;br /&gt;
The 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 the BCI2000. The states in the list are defined as follows: &#039;StateName defaultValue maxValue&#039;. Eg: &amp;lt;br/&amp;gt; &lt;br /&gt;
lastKey 0 255, correctKey 0 1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== BCIUpdateState ====&lt;br /&gt;
The 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 be set OR the variable which contains the new value of the state.&lt;br /&gt;
; Use Expression : If it is checked, the code written in &#039;Expression&#039; is executed for each Frame. &lt;br /&gt;
; Expression : The code to execute for each Frame. It is given for the cases, where the variable is not available and the users want more control over how the state is updated. &lt;br /&gt;
&lt;br /&gt;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;&lt;br /&gt;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== Usage == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8402</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8402"/>
		<updated>2019-07-26T17:36:54Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
&lt;br /&gt;
==== BCIStart ====&lt;br /&gt;
The component starts up the BCI2000 modules remotely. The component takes two parameters:&lt;br /&gt;
; Path : Path to the BCI directory &lt;br /&gt;
; States : States to add to the BCI2000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== BCIUpdateState ====&lt;br /&gt;
&lt;br /&gt;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;&lt;br /&gt;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== Usage == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8401</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8401"/>
		<updated>2019-07-26T17:06:58Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 from the PsychoPy and the second section lists the steps to follow to add the new components in the PsychoPy application.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
==== BCIStart ====&lt;br /&gt;
==== BCIUpdateState ====&lt;br /&gt;
&lt;br /&gt;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;&lt;br /&gt;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== Usage == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PyschoPy&amp;diff=8400</id>
		<title>PyschoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PyschoPy&amp;diff=8400"/>
		<updated>2019-07-26T17:03:05Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Psychopy&amp;diff=8399</id>
		<title>Psychopy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Psychopy&amp;diff=8399"/>
		<updated>2019-07-26T17:02:03Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: Dashmeetkaur moved page Psychopy to PsychoPy&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[PsychoPy]]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8398</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8398"/>
		<updated>2019-07-26T17:02:03Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: Dashmeetkaur moved page Psychopy to PsychoPy&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 using the PsychoPy&lt;br /&gt;
=== Components ===&lt;br /&gt;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;&lt;br /&gt;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== Usage == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8397</id>
		<title>PsychoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PsychoPy&amp;diff=8397"/>
		<updated>2019-07-26T16:59:42Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: Created page with &amp;quot;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described h...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 using the PsychoPy&lt;br /&gt;
=== Components ===&lt;br /&gt;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;&lt;br /&gt;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== Usage == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PyschoPy&amp;diff=8396</id>
		<title>PyschoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PyschoPy&amp;diff=8396"/>
		<updated>2019-07-26T16:59:18Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PsychoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== BCI2000 and PyschoPy ==&lt;br /&gt;
This section first describes the two components that are developed to remotely start BCI2000 using the PsychoPy&lt;br /&gt;
=== Components ===&lt;br /&gt;
=== Integrating BCI2000 into PyschoPy ===&lt;br /&gt;
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open 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;&lt;br /&gt;
Start Psychopy application and in the builder view, under the Custom Components, 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;
== Usage == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PsychoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=PyschoPy&amp;diff=8395</id>
		<title>PyschoPy</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=PyschoPy&amp;diff=8395"/>
		<updated>2019-07-26T16:54:12Z</updated>

		<summary type="html">&lt;p&gt;Dashmeetkaur: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed.[1] This documentation described how to integrate BCI2000 in PyschoPy and its usage.&lt;br /&gt;
&lt;br /&gt;
== Integrating BCI2000 into PyschoPy ==&lt;br /&gt;
Download the PyschoPy from the [https://www.psychopy.org/download.html PyschoPy] website. &amp;lt;br/&amp;gt;&lt;br /&gt;
Copy the following two folders &#039;&#039;&#039;BCIStart&#039;&#039;&#039; and &#039;&#039;&#039;BCIUpdateState&#039;&#039;&#039; in the folder {$PsychoPyHome}\psychopy\experiment\components.&lt;br /&gt;
Open terminal and navigate to the PyschoPy 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;&lt;br /&gt;
&lt;br /&gt;
Start Pyschopy application and in the builder view, under the Custom Components, you should see the two new components - &#039;&#039;BCI2000Start&#039;&#039; and &#039;&#039;BCI2000UpdateState&#039;&#039;&lt;br /&gt;
== Usage == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.psychopy.org/ PyschoPy site]&lt;/div&gt;</summary>
		<author><name>Dashmeetkaur</name></author>
	</entry>
</feed>