Difference between revisions of "PsychoPy"

From BCI2000 Wiki
Jump to: navigation, search
Line 22: Line 22:
 
== Integrating BCI2000 into PyschoPy ==
 
== Integrating BCI2000 into PyschoPy ==
 
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. <br/>
 
Download the PsychoPy from the [https://www.psychopy.org/download.html PyschoPy] website. <br/>
 +
 +
 +
=== Standalone version ===
 +
For Windows, Copy the folders '''BCIStart''' and '''BCIUpdateState''' from ''src/contrib/PsychoPy Components'' directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.
 +
 +
 +
=== Developer version ===
 
Copy the folders '''BCIStart''' and '''BCIUpdateState''' from ''src/contrib/PsychoPy Components'' directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.
 
Copy the folders '''BCIStart''' and '''BCIUpdateState''' from ''src/contrib/PsychoPy Components'' directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components.
 
Open terminal and navigate to the PsychoPy home directory where ''setup.py'' resides.
 
Open terminal and navigate to the PsychoPy home directory where ''setup.py'' resides.
 
Run the following command in the terminal: <br/>
 
Run the following command in the terminal: <br/>
 
<code>pip install -e .</code> <br/><br/>
 
<code>pip install -e .</code> <br/><br/>
 +
<br/><br/>
 
Start Psychopy application and in the builder view, under the Custom Components, you should see the two new components - ''BCI2000Start'' and ''BCI2000UpdateState'' as shown in the figure below.
 
Start Psychopy application and in the builder view, under the Custom Components, you should see the two new components - ''BCI2000Start'' and ''BCI2000UpdateState'' as shown in the figure below.
  

Revision as of 19:38, 26 July 2019

PsychoPy is an open-source application using which a large number of neuroscience, psychology and psychophysics experiments can be performed [1]. 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.

Components

BCIStart

The component starts up the BCI2000 modules remotely. The component takes two parameters:

Path 
Path to the BCI2000 prog directory which contains the BCI2000Remote.py file.
States 
List of new states to add to the BCI2000. The states in the list are defined as follows: 'StateName defaultValue maxValue'. Eg: lastKey 0 255, correctKey 0 1.

"BCI2000 start component image showing its parameters"

BCIUpdateState

The component defines which state to update and when. It takes the following parameters:

State Name 
The name of the state in BCI2000 to update.
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 variable is written as $VariableName.
Use Expression 
If it is checked, the code written in 'Expression' is executed for each Frame and the variable specified is not used to update the state.
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 bci.Execute and SET STATE to update the state in such cases. See Programming Reference:BCI2000Remote Class and User Reference:Operator Module Scripting for more details.

"BCI2000 update state component image showing its parameters"

Integrating BCI2000 into PyschoPy

Download the PsychoPy from the PyschoPy website.


Standalone version

For Windows, Copy the folders BCIStart and BCIUpdateState from src/contrib/PsychoPy Components directory of your BCI2000 repository into the folder {$PsychoPyHome}\Lib\site-packages\psychopy\experiment\components folder.


Developer version

Copy the folders BCIStart and BCIUpdateState from src/contrib/PsychoPy Components directory of your BCI2000 repository into the folder {$PsychoPyHome}\psychopy\experiment\components. Open terminal and navigate to the PsychoPy home directory where setup.py resides. Run the following command in the terminal:
pip install -e .



Start Psychopy application and in the builder view, under the Custom Components, you should see the two new components - BCI2000Start and BCI2000UpdateState as shown in the figure below.

"PsychoPy Homepage with BCI2000 Components"

References

See Also