<?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=Cstocks</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=Cstocks"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php/Special:Contributions/Cstocks"/>
	<updated>2026-06-09T07:11:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Technical_Reference:State_Definition&amp;diff=6160</id>
		<title>Technical Reference:State Definition</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Technical_Reference:State_Definition&amp;diff=6160"/>
		<updated>2011-06-22T16:42:24Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* State Vector */ Convert to 0-based numbering, since that is what is used in the state vector definition section of the data files.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the concept of BCI2000 states, in conjunction with their textual representation as a &amp;quot;state line&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For information about how to access state values from code, please refer to [[Programming Reference:Environment Class]].&lt;br /&gt;
For information about individual states, please refer to [[User Reference:States]].&lt;br /&gt;
&lt;br /&gt;
==State Concept==&lt;br /&gt;
States are variables that represent the internal state of a BCI2000 system as it is evolving over time in response to:&lt;br /&gt;
*brain signal input&lt;br /&gt;
*user interaction through the operator interface&lt;br /&gt;
*trial sequencing by the application module.&lt;br /&gt;
&lt;br /&gt;
Typical quantities/qualities encoded by states are:&lt;br /&gt;
*whether the system is running or suspended&lt;br /&gt;
*the time when a block of data was recorded &lt;br /&gt;
*stimulus or task being presented&lt;br /&gt;
*the classification result&lt;br /&gt;
*the state of an external marker (trigger) to be saved for off-line analysis.&lt;br /&gt;
&lt;br /&gt;
Typically, state values change once per block of data, or once per trial.&lt;br /&gt;
In a [[Technical Reference:BCI2000 File Format|BCI2000 data file]], the full set of states is stored along with the data, allowing for reconstruction of on-line system state off-line.&lt;br /&gt;
&lt;br /&gt;
==State Vector==&lt;br /&gt;
In a BCI2000 system, a collection of states is maintained as a &#039;&#039;State List&#039;&#039;.&lt;br /&gt;
For each state present in that state list, its value is kept as a range of bits in a bit vector called &#039;&#039;State Vector&#039;&#039;.&lt;br /&gt;
BCI2000 modules and filters may read and write state values during processing.&lt;br /&gt;
The state vector&#039;s content is saved, in its binary form, into [[Technical Reference:BCI2000 File Format|BCI2000 data files]] per-block.&lt;br /&gt;
Using the ByteLocation, BitLocation, and Length fields from the state definitions present in a file, a state&#039;s value may be read from the data file.&lt;br /&gt;
&lt;br /&gt;
A state vector is a narrowly packed bit field in &#039;&#039;&#039;little endian&#039;&#039;&#039; ordering.&lt;br /&gt;
This implies that, for a state containing more than a single bit, &#039;&#039;&#039;more&#039;&#039;&#039; significant bits are placed at &#039;&#039;&#039;higher&#039;&#039;&#039; bit and byte locations.&lt;br /&gt;
&lt;br /&gt;
As an example, consider a state vector consisting of a 1-bit state &amp;quot;Running&amp;quot;, and a 16-bit state &amp;quot;SourceTime&amp;quot;. This will result in a three-byte state vector layout like this:&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 0&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2&lt;br /&gt;
|-&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==State Lines==&lt;br /&gt;
State lines are a human-readable format used to represent individual states in&lt;br /&gt;
*[[Technical Reference:BCI2000 File Format|BCI2000 data files]],&lt;br /&gt;
*[[Technical Reference:BCI2000 Messages|BCI2000 messages]] sent between modules.&lt;br /&gt;
Core modules and the operator module use this format to communicate in the system initialization phase, as well as during system performance and for system termination.&lt;br /&gt;
&lt;br /&gt;
The format of a state line is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Name Length Value ByteLocation BitLocation CRLF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;Length&amp;lt;/tt&amp;gt; refers to the number of bits used to represent the state&#039;s value,&lt;br /&gt;
and &amp;lt;tt&amp;gt;ByteLocation&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;BitLocation&amp;lt;/tt&amp;gt; refer to its position in the State Vector, with &amp;lt;tt&amp;gt;BitLocation&amp;lt;/tt&amp;gt; ranging from 0 to 7.&lt;br /&gt;
&lt;br /&gt;
Depending on the context of a state line, one or more of its fields may be ignored:&lt;br /&gt;
*In a State message sent from the operator module to a core module, Length, ByteLocation, and BitLocation will be ignored.&lt;br /&gt;
*In a State line contained in a data file, the Value field matches the state&#039;s value stored with the first block of data samples.&lt;br /&gt;
&lt;br /&gt;
Generally, the Value field specifies an &#039;&#039;initial value&#039;&#039; of a state. Actual values are stored in the State Vector data structure.&lt;br /&gt;
&lt;br /&gt;
State values are interpreted as unsigned integers, and limited to 32 bit in the current implementation (as defined by the &amp;lt;tt&amp;gt;State::ValueType&amp;lt;/tt&amp;gt; typedef in &amp;lt;tt&amp;gt;BCI2000/src/shared/types/State.h&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:States]], [[Technical Reference:Parameter Definition]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Specification]]&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5772</id>
		<title>User Reference:P300Classifier</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5772"/>
		<updated>2010-08-12T17:26:57Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* Location */  The previous link no longer seems to exist. While this links to a branch instead of the trunk, it was the only related link I could find.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
The P300 Classifier GUI (Graphical User Interface) is a tool that allows to train and test a linear classifier for detection of evoked related potentials collected with [http://www.bci2000.org/wiki BCI2000]. This GUI is designed for the analysis of BCI2000 data collected using the P3Speller or Stimuli Presentation paradigms. The program generates feature weights by using a linear classifier algorithm called Stepwise Linear Discriminant Analysis (SWLDA). The specifics of the feature space and training routine can be manipulated using the GUI. The feature weights derived from the GUI can be saved and imported into BCI2000 as a parameter file fragment (*.prm) for online testing. Unlike the Matlab-based P300 GUI, the P300 Classifier GUI has the main advantage of being completely Matlab independent. All its core functionality is written in C++ accompanied with a friendly graphical user interface written in [http://en.wikipedia.org/wiki/Qt_(toolkit) Qt]. Additionally, this new tool is completely scriptable; that is the investigator can write all the commands needed to train and test the linear classifier in a [http://en.wikipedia.org/wiki/Batch_file batch] file without using the GUI. The P300 Classifier GUI provides the following functionality to investigators: &lt;br /&gt;
&lt;br /&gt;
; Classifier Training: Generates feature weights from BCI2000 P3Speller or Stimuli Presentation data files &lt;br /&gt;
&lt;br /&gt;
; Classifier Testing: Applies current feature weights to BCI2000 P3Speller or Stimuli Presentation data files and compares the results&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
http://{{SERVERNAME}}/svn/branches/3.0/src/core/Tools/P300Classifier&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Author===&lt;br /&gt;
Cristhian Mauricio Potes&lt;br /&gt;
&lt;br /&gt;
===e-mail===&lt;br /&gt;
cmpotes@miners.utep.edu&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: May 15, 2009&lt;br /&gt;
*Tested under: Windows XP, Windows Vista&lt;br /&gt;
*Known to compile under: Visual Studio 2008&lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
==Control Panel==&lt;br /&gt;
&lt;br /&gt;
The P300 Classifier GUI is composed of three panes: Data, Parameters, and Details. &lt;br /&gt;
&lt;br /&gt;
===Data Pane===&lt;br /&gt;
Data Pane allows the user to&lt;br /&gt;
&lt;br /&gt;
* Load training and testing data files and an INI file &lt;br /&gt;
* Generate and apply feature weights&lt;br /&gt;
* Write a parameter file fragment (*.prm)&lt;br /&gt;
&lt;br /&gt;
[[image:dataPaneLabels.png|frame|center|Data pane]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [1] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Load Training Data Files:&#039;&#039;&#039; Use this button to load [http://www.bci2000.org/wiki BCI2000] data files for classifier training. The information for the selected files will appear at the top of the button.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [2] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Load Testing Data Files:&#039;&#039;&#039; Use this button to load [http://www.bci2000.org/wiki BCI2000] data files for classifier testing. The information for the selected files will appear at the top of the button. Training and testing data files must be compatible.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [3] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Load Ini File:&#039;&#039;&#039; Use this button to load an [http://en.wikipedia.org/wiki/INI_file INI file] with all the parameters needed for the classifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Initialization]&lt;br /&gt;
&lt;br /&gt;
maxiter = 60 // to set Max Model Features&lt;br /&gt;
penter = 0.1000 // to set Penter&lt;br /&gt;
premove = 0.1500 // to set Premove&lt;br /&gt;
spatial_filter = 1 // to set Spatial Filter. Set 1 for RAW and 2 for CAR&lt;br /&gt;
decimation_frequency_Hz = 20 // to set Decimation Frequency&lt;br /&gt;
channel_set = 1 2 3 4 5 6 7 8 // to set Channel Set&lt;br /&gt;
Resp_window_ms = 0 800 // to set Response Window. The response window must be in milliseconds (ms) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [4] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Generate Feature Weights:&#039;&#039;&#039; Use this button to generate the feature weights after properly configuring all of the parameters in the  [[User_Reference:P300_classifier#Parameters|Parameters]] pane. This button will be enable only if the parameters are properly configured and there exists training data files. Once it has been generated feature weights properly, a suggested name for the parameter file fragment (*.prm) will show up at the top of the [[User_Reference:P300_classifier#Write *.prm File|Write *.prm File]] button.   &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [5] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Apply Feature Weights:&#039;&#039;&#039; Use this button to test the classification accuracy of the feature weights currently stored in the GUI. The classification results will appear in the [[User_Reference:P300_classifier#Details Pane|Details]] pane.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [6] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Write *.prm File:&#039;&#039;&#039; Use this button to save the parameter file fragment with the name suggested at the top of this button. The *.prm file is a [http://www.bci2000.org/wiki BCI2000] parameter file fragment that can be imported into [http://www.bci2000.org/wiki BCI2000] for online testing of the feature weights.&lt;br /&gt;
&lt;br /&gt;
===Parameters Pane===&lt;br /&gt;
Parameters Pane contains all the parameters needed to generate feature weights by using the SWLDA algorithm. These parameters can be loaded using the [[User_Reference:P300_classifier#Load Ini File|Data Pane]] button. If the parameters are properly configured the [[User_Reference:P300_classifier#Data Pane|Generate Feature Weights]] button is enabled.&lt;br /&gt;
&lt;br /&gt;
[[image:parametersPaneLabel.png|frame|center|Parameters pane]]&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [7] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Max Model Features:&#039;&#039;&#039; Used to specify the maximum number of features to be kept in the SWLDA algorithm. Only a single value can be entered for evaluation. The default value is 60.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [8] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Penter:&#039;&#039;&#039; Used to specify the maximum [http://en.wikipedia.org/wiki/P-value p-value] for  a variable to be entered. The default value is 0.1000. Penter must be less than Premove and 0&amp;lt;Penter&amp;lt;1. Only a single value can be entered for evaluation.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [9] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Premove:&#039;&#039;&#039; Used to specify the maximum  [http://en.wikipedia.org/wiki/P-value p-value] for a variable to be removed. The default value is 0.1500. Premove must be greater than Penter and 0&amp;lt;Premove&amp;lt;1. Only a single value can be entered for evaluation.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [10] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Spatial Filter:&#039;&#039;&#039; Selects the spatial filter applied to the training data. Select &#039;&#039;&#039;RAW&#039;&#039;&#039; or &#039;&#039;&#039;CAR&#039;&#039;&#039; from the drop-down menu. &#039;&#039;&#039;RAW&#039;&#039;&#039; is no spatial filter applied to the data, and &#039;&#039;&#039;CAR&#039;&#039;&#039; is a common average reference filter using all of the channels contained in the data file &#039;&#039;&#039;(not just the channels specified in the GUI channel set)&#039;&#039;&#039;. The default spatial filter is &#039;&#039;&#039;RAW&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [11] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Decimation Frequency:&#039;&#039;&#039; Used to specify the temporal decimation frequency of the data in Hz. Only a single value can be entered for evaluation. Set this parameter to the [[User_Reference:P300_classifier#Details Pane|Sampling Rate]] value for no decimation. The lower the Decimation Frequency, the less original data retained for processing.   &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [12] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Channel Set:&#039;&#039;&#039; Used to specify the channel set that will be used to create feature weights. The specified channels must be a subset of the channels contained in the training data file. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [13] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Response Window:&#039;&#039;&#039; Used to specify the &#039;&#039;Begin&#039;&#039; and &#039;&#039;End&#039;&#039; time points in milliseconds (ms) following the stimuli collected for the analysis. These two values are automatically converted into samples according to the sampling rate of the data (rounded). Only a single data window can be entered and will be evaluated. &#039;&#039;Begin&#039;&#039; must be less than &#039;&#039;End&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===Details Pane===&lt;br /&gt;
Details Pane displays information about the [http://www.bci2000.org/wiki BCI2000] training data files and the classification results. &lt;br /&gt;
&lt;br /&gt;
[[image:detailsPaneLabel.png|frame|center|Details pane]]&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [14] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Sampling Rate:&#039;&#039;&#039; Displays the sampling rate in (Hz) contained in the training data files.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [15] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Number of Channels:&#039;&#039;&#039; Displays the total number of channels contained in the training data files. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [16] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Classifier:&#039;&#039;&#039; Displays the classifier applied to generate the feature weights. The P300Classifier GUI only uses the SWLDA classifier algorithm.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [17] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Application:&#039;&#039;&#039; Displays the type of application used for the investigator. The application can be either &#039;&#039;P3SpellerTask&#039;&#039; or &#039;&#039;StimulusPresentationTask&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [18] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Interpret Mode:&#039;&#039;&#039; Displays the interpret mode used for the investigator. The mode can be either &#039;&#039;Copy Mode&#039;&#039; or &#039;&#039;Online Free Mode&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [19] &amp;lt;/font&amp;gt; &#039;&#039;&#039;Duration:&#039;&#039;&#039; Displays the duration in seconds (s) of the whole training data files. &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;font color=red&amp;gt; [20] &amp;lt;/font&amp;gt; The text editor displays the classification results for the training and testing data files.&lt;br /&gt;
&lt;br /&gt;
==Methodology==&lt;br /&gt;
&lt;br /&gt;
===Methodology Concept===&lt;br /&gt;
The idea behind the P300Classifier is to train and test a linear classifier (SWLDA) for detection of evoked potentials collected from brain signals. This is achieved in the following steps:&lt;br /&gt;
* Training Data Files&lt;br /&gt;
# Load BCI2000 data files&lt;br /&gt;
# Get P300 responses&lt;br /&gt;
# Generate feature weights for a linear model using SWLDA&lt;br /&gt;
# Apply linear classifier to get scores &lt;br /&gt;
# Interpret scores according to the given application &lt;br /&gt;
&lt;br /&gt;
* Testing Data Files&lt;br /&gt;
# Load BCI2000 data files&lt;br /&gt;
# Get P300 responses&lt;br /&gt;
# Apply linear classifier to get scores &lt;br /&gt;
# Interpret scores according to the given application&lt;br /&gt;
&lt;br /&gt;
===Methodology Step By Step===&lt;br /&gt;
&lt;br /&gt;
====Step 1: [http://www.bci2000.org/wiki/index.php/UserReference:P300ClassifierMethods Load BCI2000 Data Files]====&lt;br /&gt;
&lt;br /&gt;
The first step to start using the P300Classifier GUI is to load training and testing BCI2000 data files specified by the investigator. The BCI2000 data files are checked for compatibility and consistency. If all training data files are valid then the &#039;&#039;Generate Feature Weights&#039;&#039; button is enabled and each file is colored with light green. Otherwise, the &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled, and each file is colored either with yellow or pink. See the following color coded scheme and example.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;span style=&amp;quot;background-color:lightgreen&amp;quot;&amp;gt;&amp;lt;b&amp;gt;files ok&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; : The files are valid.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;background-color:yellow&amp;quot;&amp;gt;&amp;lt;b&amp;gt;files mismatch&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; : The files may be valid but there is a mismatch with another file.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;background-color:pink&amp;quot;&amp;gt;&amp;lt;b&amp;gt;files error&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; : The files are invalid.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial0.png|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data file is valid; the file is highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until the training data file is valid.]]&lt;br /&gt;
&lt;br /&gt;
====Step 2: [http://www.bci2000.org/wiki/index.php/UserReference:P300ClassifierMethods Get P300 Responses] ====&lt;br /&gt;
&lt;br /&gt;
Signals, states, and parameters are extracted from BCI2000 training and testing data files. However, the signals that are only extracted for analysis are those defined by the user in the [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Response Window&#039;&#039;&#039;]]. Only these signals are filtered and downsampled. The filter employed is a [http://en.wikipedia.org/wiki/Moving_average Moving Average (MA) Filter] implemented as a &#039;&#039;Direct form II Transposed&#039;&#039;. The MA filter belongs to the FIR filter and works as a low pass filter removing high frequency components of the signal.&lt;br /&gt;
&lt;br /&gt;
====Step 3: [http://www.bci2000.org/wiki/index.php/UserReference:P300ClassifierMethods Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA)]====&lt;br /&gt;
&lt;br /&gt;
The idea behind SWLDA is to obtain a final linear model that approximately fits a set of data (stimulus) by using multiple linear regressions and iterative statistical procedures, thus selecting only significant variables that are included in the final regression.&lt;br /&gt;
 &lt;br /&gt;
The SWLDA algorithm can be summarized in the following steps:&lt;br /&gt;
&lt;br /&gt;
* STEP 1: Compute the autocorrelation matrix to select the variable most highly correlated to the observations. The selected variable is included in the linear model.&lt;br /&gt;
&lt;br /&gt;
* STEP 2: Fit an initial model by performing a linear regression equation with the included variable using least squares.&lt;br /&gt;
&lt;br /&gt;
* STEP 3: Check if the variable added is that one which makes greatest improvements in &amp;quot;goodness of fit.&amp;quot; That is, remove the added variable if its variance contribution in the regression is insignificant at a specified F level (F-test). If the added variable is removed go to Step 5, else go to Step 4.&lt;br /&gt;
&lt;br /&gt;
* STEP 4: Add the variable to the model if there is a significant variance reduction at a specified F-level.&lt;br /&gt;
&lt;br /&gt;
* STEP 5: Remove the added variable from the correlation matrix. Go to step 1.&lt;br /&gt;
&lt;br /&gt;
The method terminates when no single step improves the model.&lt;br /&gt;
&lt;br /&gt;
====Step 4: Apply Linear Classifier to Get Scores ====&lt;br /&gt;
&lt;br /&gt;
Scores are computed based on the variables included in the final linear model and the corresponding feature weights.&lt;br /&gt;
&lt;br /&gt;
====Step 5: Interpret Scores ====&lt;br /&gt;
&lt;br /&gt;
Scores are interpreted according to the given application, which can be either P300SpellerTask or StimulusPresentationTask.&lt;br /&gt;
&lt;br /&gt;
==Tutorial==&lt;br /&gt;
&lt;br /&gt;
===Training the SWLDA Classifier===&lt;br /&gt;
The &#039;&#039;Parameters&#039;&#039; pane contains all of the parameters for generating feature weights from BCI2000 data files.&lt;br /&gt;
&lt;br /&gt;
The investigator must follow the next steps to generate feature weights: &lt;br /&gt;
&lt;br /&gt;
* Press the &#039;&#039;Load Training Data Files&#039;&#039; &amp;lt;font color=red&amp;gt; [1] &amp;lt;/font&amp;gt; button in the &#039;&#039;Data&#039;&#039; pane.&lt;br /&gt;
&lt;br /&gt;
* From the dialog box, select the desire BCI2000 *.dat file(s) for training. Selected files can be from different sessions of the same paradigm but must contain consistent parameters. Each training data file is colored according to the color coded scheme explained in [[User_Reference:P300_classifier#Step 1: Load BCI2000 data files|Load BCI2000 data files]]. Files can only be selected from a single directory; the desired training data files should be organized into the same directory prior to using the P300Classifier GUI.&lt;br /&gt;
&lt;br /&gt;
* Once the &#039;&#039;Parameters&#039;&#039; pane is correctly set as desired, the &#039;&#039;Generate Feature Weights&#039;&#039; button is enable. Press this button to perform the analysis and generate feature weights. The &#039;&#039;Overall Progress&#039;&#039; bar displayed in &#039;&#039;Data&#039;&#039; and &#039;&#039;Details&#039;&#039; panes will indicate the progress of the SWLDA. The classification results will appear in the text editor &amp;lt;font color=red&amp;gt; [20] &amp;lt;/font&amp;gt; of &#039;&#039;Details&#039;&#039; pane. Every time it is pressed the &#039;&#039;Generate Feature Weights&#039;&#039; button, and the analysis is successfully completed, there is generated a new feature weights set. &lt;br /&gt;
&lt;br /&gt;
* The training procedure can be repeated multiple times generating a new feature weights set that depends on the configured parameters.&lt;br /&gt;
&lt;br /&gt;
* After training is completed and feature weights are generated, it is recommended to test (cross validate) the feature weights on independent data (testing data files) before saving the parameter file fragment (*.prm). Additionally, there is a suggested parameter file fragment name displayed on the top of &#039;&#039;Write *.prm File&#039;&#039; button, which can be used to save the *.prm file either with the suggested name or the name specified by the investigator.&lt;br /&gt;
&lt;br /&gt;
===Testing the SWLDA Classifier===&lt;br /&gt;
The &#039;&#039;Data&#039;&#039; pane contains the &#039;&#039;Apply Feature Weights&#039;&#039; &amp;lt;font color=red&amp;gt; [5] &amp;lt;/font&amp;gt; button for testing the generated feature weights to one or more BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
The investigator must follow the next steps for applying feature weights to testing data files:&lt;br /&gt;
&lt;br /&gt;
* Once it has been successfully generated feature weights and there exists testing data files, the &#039;&#039;Apply Feature Weights&#039;&#039; button is enabled. If there are no testing data files loaded, the investigator must press this button to load testing data file(s). One or more BCI2000 *.dat files can be selected from the same directory as a single &#039;test file group&#039; each time the button is pressed. Selected files can be from different sessions of the same paradigm but must contain consistent parameters. Each testing data file is colored according to the color coded scheme explained in [[User_Reference:P300_classifier#Step 1: Load BCI2000 data files|Load BCI2000 data files]]. All testing files selected should have the same sampling rate and electrode montage as the training data files selected to generate the current feature weights set. &lt;br /&gt;
&lt;br /&gt;
* After all the testing data files are correctly selected, press the &#039;&#039;Apply Feature Weights&#039;&#039; &amp;lt;font color=red&amp;gt; [5] &amp;lt;/font&amp;gt; button to perform the analysis. Results of the classification are displayed in the text editor &amp;lt;font color=red&amp;gt; [20] &amp;lt;/font&amp;gt;  of &#039;&#039;Details&#039;&#039; pane. The &#039;&#039;Overall Progress&#039;&#039; bar displayed in &#039;&#039;Data&#039;&#039; and &#039;&#039;Details&#039;&#039; panes will indicate the progress of the classification.&lt;br /&gt;
&lt;br /&gt;
* After evaluating the classification results, the *.prm file from the current session can be saved by pressing the &#039;&#039;Write *.prm File&#039;&#039; button.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
In the next example, it is desired to compute feature weights from the following BCI2000 training data file &#039;&#039;&#039;eeg3_1.dat&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button the file &#039;&#039;&#039;eeg3_1.dat&#039;&#039;&#039; is uploaded as shown in the next figure. Notice that the training data file is set up correctly since it is colored in light green. Remember that the classifier algorithm will be trained by using this training data file. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial1.png|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data file. The classifier algorithm is trained by using this training data file.]]&lt;br /&gt;
&lt;br /&gt;
The parameters shown in &#039;&#039;Parameters Pane&#039;&#039; are set by default. For illustration purposes, however, it is desired to load initial parameters from an INI file called parameters.ini by pressing the &#039;&#039;Load Ini File&#039;&#039; button. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Initialization]&lt;br /&gt;
maxiter = 60 &lt;br /&gt;
penter = 0.1000 &lt;br /&gt;
premove = 0.1500 &lt;br /&gt;
spatial_filter = 2 &lt;br /&gt;
decimation_frequency_Hz = 20 &lt;br /&gt;
channel_set = 1 2 3 4 5 6 7 8 &lt;br /&gt;
Resp_window_ms = 0 800 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial2.png|frame|center|By pressing the &#039;&#039;Load Ini File&#039;&#039; button it is uploaded the desired initial parameters that the classifier algorithm will use to generate the corresponding feature weights.]]&lt;br /&gt;
&lt;br /&gt;
Once the initial parameters are loaded and properly set up, the &#039;&#039;Generate Feature Weights&#039;&#039; button is enabled, and each one of the parameter fields is colored in light green as shown in the next figure.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial3.png|frame|center|All of the parameter fields are properly set up. Thus, each parameter field is colored in light green.]]&lt;br /&gt;
&lt;br /&gt;
The investigator can change any of the parameters fields at any time. However, if that change is not properly set up (i.e., the given parameter is invalid), the corresponding parameter field will be colored in pink.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;span style=&amp;quot;background-color:lightgreen&amp;quot;&amp;gt;&amp;lt;b&amp;gt;parameter field ok&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; : The parameter is valid.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;background-color:pink&amp;quot;&amp;gt;&amp;lt;b&amp;gt;parameter field error&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; : The parameter is invalid.&lt;br /&gt;
&lt;br /&gt;
In the next figure, the investigator changes the &#039;&#039;Channel Set&#039;&#039; field introducing one more channel, channel 9. Since this channel is not a subset of the channels contained in the training data file, the corresponding field is colored in pink, and a tool tip is popped up displaying the error message. Additionally, the &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial4.png|frame|center|The &#039;&#039;Channel Set&#039;&#039; field is modified by introducing one more channel, channel 9. This field is colored in pink since channel 9 is not a subset of the channels contained in the training data file.]]&lt;br /&gt;
&lt;br /&gt;
Once the parameters are properly configured, the investigator is ready to generate feature weights by pressing the &#039;&#039;Generate Feature Weights&#039;&#039; button. Details of the training data file and progress of the classification are displayed in the &#039;&#039;Details Pane&#039;&#039; as shown below.   &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial5.png|frame|center|Details of the training data file and progress of the classification. There is an overall progress bar in both the &#039;&#039;Data Pane&#039;&#039; and &#039;&#039;Details Pane&#039;&#039;.]]&lt;br /&gt;
&lt;br /&gt;
Once the classifier has been trained with the BCI2000 training data file, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data file &#039;&#039;&#039;eeg3_2.dat&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button this file is uploaded as shown in the next figure. Notice that the testing data file is set up correctly since it is colored in light green. If the testing data file is valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enabled.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial6.png|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data file. The file is colored in light green if valid.]]&lt;br /&gt;
&lt;br /&gt;
The investigator is ready to apply feature weights by pressing the &#039;&#039;Apply Feature Weights&#039;&#039; button. Details of the training data file (no testing data file) and progress of the classification are displayed in the &#039;&#039;Details Pane&#039;&#039; as shown below.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial7.png|frame|center|Details of the training data file and progress of the classification. Testing feature weights generated from the training data file &#039;&#039;&#039;eeg3_2.dat&#039;&#039;&#039;. There is an overall progress bar in both the &#039;&#039;Data Pane&#039;&#039; and &#039;&#039;Details Pane&#039;&#039;.]]&lt;br /&gt;
&lt;br /&gt;
If satisfied with the classification obtained from the current feature weights, the investigator can write a parameter file fragment *.prm with the name suggested in the &#039;&#039;Write *.prm File&#039;&#039; field by pressing the &#039;&#039;Write *.prm File&#039;&#039; button. The *.prm file is a BCI2000 parameter file fragment that can be imported into BCI2000 for online testing of the feature weights. In the following image, it is written a *.prm file called &#039;&#039;&#039;MUDChS1_RAW_SW.prm&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial8.png|frame|center|Write a parameter file fragment *.prm. The *.prm file is a BCI2000 parameter file fragment that can be imported into BCI2000 for online testing of the feature weights.]]&lt;br /&gt;
&lt;br /&gt;
Every time the investigator changes any of the parameters in the &#039;&#039;Parameters Pane&#039;&#039;, the &#039;&#039;Apply Feature Weights&#039;&#039; button is disabled. To enable it, the investigator must generate feature weights again.&lt;br /&gt;
&lt;br /&gt;
==Future work==&lt;br /&gt;
&lt;br /&gt;
* Present classification results as topographies and graphs as the Matlab-based P300 GUI&lt;br /&gt;
&lt;br /&gt;
* Let the P300Classifier GUI work with frequency-based features&lt;br /&gt;
&lt;br /&gt;
* Speed up the P300Classifier GUI by using multithreading when solving the Least Squares (QR factorization)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* N. R. Draper, H. Smith. &#039;&#039;Applied Regression Analysis&#039;&#039;. John Wiley &amp;amp; Sons, Inc, New York, 1966.&lt;br /&gt;
&lt;br /&gt;
* P. M. Embree, B. Kimble. &#039;&#039;C Language Algorithms for Digital Signal Processing&#039;&#039;. Prentice Hall, Englewood Cliffs, New Jersey, 1991.&lt;br /&gt;
&lt;br /&gt;
* A. Ralston, H. S. Wilf. &#039;&#039;Mathematical Methods for Digital Computers&#039;&#039;. John Wiley &amp;amp; Sons, Inc, New York, 1962.&lt;br /&gt;
&lt;br /&gt;
* W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery. &#039;&#039;Numerical Recipes in C&#039;&#039;. Cambridge University Press, New York, 1988.&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:User_Reference:P3SpellerTask&amp;diff=5769</id>
		<title>Talk:User Reference:P3SpellerTask</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:User_Reference:P3SpellerTask&amp;diff=5769"/>
		<updated>2010-08-05T13:57:46Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* More detail on state meaning */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== More detail on state meaning ==&lt;br /&gt;
&lt;br /&gt;
It would be helpful if there were more data on the meaning of certain states, specifically with regard to how they should be interpreted. For example, how do you use the StimulusCode to figure out which row/column is flashing when in row/column mode?&lt;br /&gt;
&lt;br /&gt;
[[User:Cstocks|Cstocks]] 13:55, 5 August 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User:Cstocks&amp;diff=5768</id>
		<title>User:Cstocks</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User:Cstocks&amp;diff=5768"/>
		<updated>2010-08-05T13:57:19Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I&#039;m Collin. I have done some research at the Wadsworth Center, and plan to continue.&lt;br /&gt;
&lt;br /&gt;
Come September, I will be attending college at The Cooper Union.&lt;br /&gt;
&lt;br /&gt;
Anyway, stop wasting time reading my user page.&lt;br /&gt;
&lt;br /&gt;
[[User:Cstocks|Cstocks]] 13:57, 5 August 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:User_Reference:P3SpellerTask&amp;diff=5767</id>
		<title>Talk:User Reference:P3SpellerTask</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:User_Reference:P3SpellerTask&amp;diff=5767"/>
		<updated>2010-08-05T13:55:33Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: More detail on state meaning&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== More detail on state meaning ==&lt;br /&gt;
&lt;br /&gt;
It would be helpful if there were more data on the meaning of certain states, specifically with regard to how they should be interpreted. For example, how do you use the StimulusCode to figure out which row/column is flashing when in row/column mode?&lt;br /&gt;
[[User:Cstocks|Cstocks]] 13:55, 5 August 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000FileReader_Class&amp;diff=5765</id>
		<title>Programming Reference:BCI2000FileReader Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000FileReader_Class&amp;diff=5765"/>
		<updated>2010-07-29T21:11:39Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* CalibratedValue(channel, sample) */  correct parameter names&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &amp;lt;tt&amp;gt;BCI2000FileReader&amp;lt;/tt&amp;gt; class provides an interface to data stored in a single BCI2000 data file.&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
===BCI2000FileReader([file name])===&lt;br /&gt;
With a file name given as an argument, the constructor will try to open the specified file.&lt;br /&gt;
&lt;br /&gt;
===Open(file name, [buffer size=50kB])===&lt;br /&gt;
Will open the specified data file. Use the &amp;lt;tt&amp;gt;IsOpen&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;ErrorState&amp;lt;/tt&amp;gt; properties to check whether a file is actually open.&lt;br /&gt;
In a second argument, the size of &amp;lt;tt&amp;gt;BCI2000FileReader&amp;lt;/tt&amp;gt;&#039;s internal data buffer may be specified in bytes; when no buffer size argument is given, a default size of 50kB is used.&lt;br /&gt;
&lt;br /&gt;
===RawValue(channel, sample)===&lt;br /&gt;
Sets the current sample position to the value specified in the second argument, and returns the raw sample value for the channel specified in the first argument.&lt;br /&gt;
&lt;br /&gt;
===CalibratedValue(channel, sample)===&lt;br /&gt;
Sets the current sample position to the value specified in the second argument, and returns the calibrated sample value for the channel specified in the first argument.&lt;br /&gt;
The calibrated sample value is obtained by applying channel-specific sample offsets and gains as present in the file&#039;s &#039;&#039;SourceChOffset&#039;&#039; and &#039;&#039;SourceChGain&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===ReadStateVector(sample)===&lt;br /&gt;
Sets the current sample position to the specified value, and reads state vector data.&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
===IsOpen (r)===&lt;br /&gt;
&#039;&#039;true&#039;&#039; when a file has been opened successfully, &#039;&#039;false&#039;&#039; otherwise.&lt;br /&gt;
===ErrorState (r)===&lt;br /&gt;
One of&lt;br /&gt;
*NoError,&lt;br /&gt;
*FileOpenError,&lt;br /&gt;
*MalformedHeader.&lt;br /&gt;
===NumSamples (r)===&lt;br /&gt;
The number of samples in the currently opened data file.&lt;br /&gt;
===SamplingRate (r)===&lt;br /&gt;
The currently opened data file&#039;s sampling rate.&lt;br /&gt;
===SignalProperties (r)===&lt;br /&gt;
A [[Programming_Reference:Signals#SignalProperties_Class|&amp;lt;tt&amp;gt;SignalProperties&amp;lt;/tt&amp;gt;]] object describing the current file&#039;s data format, number of channels, sample block size (in its Elements property), and physical units.&lt;br /&gt;
&lt;br /&gt;
===FileFormatVersion (r)===&lt;br /&gt;
A string describing the file&#039;s format as specified by the file header. Currently, this is &amp;quot;1.0&amp;quot; or &amp;quot;1.1&amp;quot;.&lt;br /&gt;
===HeaderLength (r)===&lt;br /&gt;
The data file&#039;s header length in bytes.&lt;br /&gt;
===StateVectorLength (r)===&lt;br /&gt;
The state vector&#039;s length in bytes.&lt;br /&gt;
===Parameters (r)===&lt;br /&gt;
A [[Programming Reference:Parameters#ParamList Class|&amp;lt;tt&amp;gt;ParamList&amp;lt;/tt&amp;gt;]] object that contains all parameters present in the file.&lt;br /&gt;
&lt;br /&gt;
===Parameter (r)===&lt;br /&gt;
Access to an individual parameter, following the [[Programming_Reference:Environment_Class#Access_to_Parameters_and_States|syntax provided by the &amp;lt;tt&amp;gt;Environment&amp;lt;/tt&amp;gt; class]].&lt;br /&gt;
===States (r)===&lt;br /&gt;
A [[Programming Reference:States#StateList Class|&amp;lt;tt&amp;gt;StateList&amp;lt;/tt&amp;gt;]] object containing all state variables present in the file.&lt;br /&gt;
&lt;br /&gt;
===State (r)===&lt;br /&gt;
Access to an individual state variable, following the [[Programming_Reference:Environment_Class#Access_to_Parameters_and_States|syntax provided by the &amp;lt;tt&amp;gt;Environment&amp;lt;/tt&amp;gt; class]]. The returned value will match the state variable&#039;s value at the current sample position, as specified to a previous call to one of the &amp;lt;tt&amp;gt;RawValue&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;CalibratedValue&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;ReadStateVector&amp;lt;/tt&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
===StateVector (r)===&lt;br /&gt;
Access to the full state vector, with state values matching those at the current sample position.&lt;br /&gt;
&lt;br /&gt;
==Performance Considerations==&lt;br /&gt;
To improve performance when reading data, &amp;lt;tt&amp;gt;BCI2000FileReader&amp;lt;/tt&amp;gt; uses an internal buffer which is 50kB in size by default but may be set to a different value using an optional second argument to &amp;lt;tt&amp;gt;BCI2000FileReader::Open()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Buffering strategy is optimized for &#039;&#039;sequential forward access&#039;&#039;, which is supposed to be the most relevant use case. Buffering is non-overlapping, with the requested sample always the first one in the buffer in case the buffer needs updating. In case of sequential access in &#039;&#039;reverse&#039;&#039; direction, this buffering scheme breaks down and becomes maximally inefficient because the entire buffer is updated on each access.&lt;br /&gt;
&lt;br /&gt;
In a BCI2000 data file, data is organized such that, for each sample, values from all channels and states are stored, followed with all values from the next sample point, etc. When reading data from multiple channels, this implies that it is favorable to iterate over &#039;&#039;channels&#039;&#039; in an &#039;&#039;inner&#039;&#039; loop, and over &#039;&#039;samples&#039;&#039; in an &#039;&#039;outer&#039;&#039; loop; otherwise, buffering will become less efficient by a factor identical to the number of channels read.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:BCI2000 File Format]], [[User Reference:BCI2000FileWriter]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Framework API]] [[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5505</id>
		<title>Talk:Technical Reference:State Definition</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5505"/>
		<updated>2010-01-05T23:07:05Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: Pseudocode&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== State Vector ==&lt;br /&gt;
&lt;br /&gt;
The section on state vectors is totally wrong. After reverse-engineering some data files with the help of the BCI2000Viewer, it appears that the state vectors are actually encoded in reverse-big-endian. In other words, if smaller numbers represent lower order bits, then the state vector layout mentioned in this section would actually be encoded as follows:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Which on the physical machine actually maps to:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|SourceTime!!Running!!colspan=&amp;quot;8&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused!!SourceTime&lt;br /&gt;
|-&lt;br /&gt;
!6!!5!!4!!3!!2!!1!!0!!0!!14!!13!!12!!11!!10!!9!!8!!7!!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;!!15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Fixed section on state vector encoding ==&lt;br /&gt;
&lt;br /&gt;
Thanks for pointing out the error. State vector encoding is actually little-endian (LSB first) rather than big-endian, and its layout on a little-endian machine is straightforward as a concatenation of little-endian encoded state values. I fixed the description accordingly.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode reference ==&lt;br /&gt;
&lt;br /&gt;
Do you think it would be helpful to readers to put (in pseudocode) a way to read the State Definition?&lt;br /&gt;
&lt;br /&gt;
 int ExtractStateValue(unsigned char[] vector, int byteoffset, int bitoffset, int numberofbits){&lt;br /&gt;
 &lt;br /&gt;
     int numberofbytes = numberofbits / 8 + 1;&lt;br /&gt;
     char bytes[numbytes] = vector[ byteoffset : byteoffset + numbytes ];&lt;br /&gt;
 &lt;br /&gt;
     int ret = bytes[0] &amp;gt;&amp;gt; bitoffset;&lt;br /&gt;
     for ( int i=1; i&amp;lt;numbytes; i++ ){&lt;br /&gt;
         ret += bytes[i] &amp;lt;&amp;lt; ( 8 * i - bitoffset );&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     return ret % ( 1 &amp;lt;&amp;lt; numbits );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is not compilable C or C++ code, as far as I know. However, I think it might make things clearer.&lt;br /&gt;
&lt;br /&gt;
[[User:Cstocks|Cstocks]] 21:15, 4 January 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Actual C++ code ==&lt;br /&gt;
&lt;br /&gt;
The actual C++ code is here:&lt;br /&gt;
http://www.bci2000.org/tracproj/browser/trunk/src/shared/types/StateVectorSample.cpp#L69&lt;br /&gt;
(log into trac if you get a message about browser view privileges)&lt;br /&gt;
&lt;br /&gt;
[[User:Mellinger|Mellinger]] 15:00, 5 January 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Pseudocode ==&lt;br /&gt;
&lt;br /&gt;
Thanks for pointing that out, but to someone (like me) who is not terribly familiar with C++ code, seeing the actual code is not very helpful. For example, I would have to start hunting through the code to find out what State::ValueType, mByteLength, mpData, et cetera mean.&lt;br /&gt;
&lt;br /&gt;
Also, I am proud to note that my algorithm is at least 8 times more efficient than the C++ function you pointed me to.&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User:Cstocks&amp;diff=5502</id>
		<title>User:Cstocks</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User:Cstocks&amp;diff=5502"/>
		<updated>2010-01-04T21:23:05Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I&#039;m Collin. I have done some research at the Wadsworth Center, and plan to continue.&lt;br /&gt;
&lt;br /&gt;
I am currently developing a way to classify P300 data using known weights in Python, sort of like how the old MatLab script did it, but it will also work for classifying online free spelling data. Perhaps later I will program some techniques for generating weights in Python. If I do, it will likely be used to generate weights from online data once it has been determined what the correct classifications should have been. This method may possibly generate more useful weights, because there may be a difference in the P300 signal during copy spelling as compared to the P300 signal during free spelling.&lt;br /&gt;
&lt;br /&gt;
Anyway, stop wasting time reading my user page.&lt;br /&gt;
&lt;br /&gt;
[[User:Cstocks|Cstocks]] 21:23, 4 January 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5501</id>
		<title>Talk:Technical Reference:State Definition</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5501"/>
		<updated>2010-01-04T21:15:23Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: Pseudocode reference&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== State Vector ==&lt;br /&gt;
&lt;br /&gt;
The section on state vectors is totally wrong. After reverse-engineering some data files with the help of the BCI2000Viewer, it appears that the state vectors are actually encoded in reverse-big-endian. In other words, if smaller numbers represent lower order bits, then the state vector layout mentioned in this section would actually be encoded as follows:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Which on the physical machine actually maps to:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|SourceTime!!Running!!colspan=&amp;quot;8&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused!!SourceTime&lt;br /&gt;
|-&lt;br /&gt;
!6!!5!!4!!3!!2!!1!!0!!0!!14!!13!!12!!11!!10!!9!!8!!7!!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;!!15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Fixed section on state vector encoding ==&lt;br /&gt;
&lt;br /&gt;
Thanks for pointing out the error. State vector encoding is actually little-endian (LSB first) rather than big-endian, and its layout on a little-endian machine is straightforward as a concatenation of little-endian encoded state values. I fixed the description accordingly.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode reference ==&lt;br /&gt;
&lt;br /&gt;
Do you think it would be helpful to readers to put (in pseudocode) a way to read the State Definition?&lt;br /&gt;
&lt;br /&gt;
 int ExtractStateValue(unsigned char[] vector, int byteoffset, int bitoffset, int numberofbits){&lt;br /&gt;
 &lt;br /&gt;
     int numberofbytes = numberofbits / 8 + 1;&lt;br /&gt;
     char bytes[numbytes] = vector[ byteoffset : byteoffset + numbytes ];&lt;br /&gt;
 &lt;br /&gt;
     int ret = bytes[0] &amp;gt;&amp;gt; bitoffset;&lt;br /&gt;
     for ( int i=1; i&amp;lt;numbytes; i++ ){&lt;br /&gt;
         ret += bytes[i] &amp;lt;&amp;lt; ( 8 * i - bitoffset );&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     return ret % ( 1 &amp;lt;&amp;lt; numbits );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is not compilable C or C++ code, as far as I know. However, I think it might make things clearer.&lt;br /&gt;
&lt;br /&gt;
[[User:Cstocks|Cstocks]] 21:15, 4 January 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5497</id>
		<title>Talk:Technical Reference:State Definition</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5497"/>
		<updated>2010-01-01T00:45:11Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* State Vector */ Finally correct, again. I made a mistake before.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== State Vector ==&lt;br /&gt;
&lt;br /&gt;
The section on state vectors is totally wrong. After reverse-engineering some data files with the help of the BCI2000Viewer, it appears that the state vectors are actually encoded in reverse-big-endian. In other words, if smaller numbers represent lower order bits, then the state vector layout mentioned in this section would actually be encoded as follows:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Which on the physical machine actually maps to:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|SourceTime!!Running!!colspan=&amp;quot;8&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused!!SourceTime&lt;br /&gt;
|-&lt;br /&gt;
!6!!5!!4!!3!!2!!1!!0!!0!!14!!13!!12!!11!!10!!9!!8!!7!!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;!!15&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5496</id>
		<title>Talk:Technical Reference:State Definition</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5496"/>
		<updated>2010-01-01T00:30:40Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* State Vector */ Finally got it correct&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== State Vector ==&lt;br /&gt;
&lt;br /&gt;
The section on state vectors is totally wrong. After reverse-engineering some data files with the help of the BCI2000Viewer, it appears that the state vectors are actually encoded in reverse-big-endian. In other words, if smaller numbers represent lower order bits, then the state vector layout mentioned in this section would actually be encoded as follows:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Which on the physical machine actually maps to:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|SourceTime!!Running!!colspan=&amp;quot;9&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!6!!5!!4!!3!!2!!1!!0!!0!!14!!13!!12!!11!!10!!9!!8!!7!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5495</id>
		<title>Talk:Technical Reference:State Definition</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5495"/>
		<updated>2010-01-01T00:24:31Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* State Vector */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== State Vector ==&lt;br /&gt;
&lt;br /&gt;
The section on state vectors is totally wrong. After reverse-engineering some data files with the help of the BCI2000Viewer, it appears that the state vectors are actually encoded in reverse-big-endian. In other words, if smaller numbers represent lower order bits, then the state vector layout mentioned in this section would actually be encoded as follows:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Which on the physical machine actually maps to:&lt;br /&gt;
&lt;br /&gt;
(I need to correct this later)&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5494</id>
		<title>Talk:Technical Reference:State Definition</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5494"/>
		<updated>2010-01-01T00:23:33Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* State Vector */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== State Vector ==&lt;br /&gt;
&lt;br /&gt;
The section on state vectors is totally wrong. After reverse-engineering some data files with the help of the BCI2000Viewer, it appears that the state vectors are actually encoded in reverse-big-endian. In other words, if smaller numbers represent lower order bits, then the state vector layout mentioned in this section would actually be encoded as follows:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Which on the physical machine actually maps to:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!6!!5!!4!!3!!2!!1!!0!!14!!13!!12!!11!!10!!9!!8!!7!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5493</id>
		<title>Talk:Technical Reference:State Definition</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Talk:Technical_Reference:State_Definition&amp;diff=5493"/>
		<updated>2010-01-01T00:22:27Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: State Vector&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== State Vector ==&lt;br /&gt;
&lt;br /&gt;
The section on state vectors is totally wrong. After reverse-engineering some data files with the help of the BCI2000Viewer, it appears that the state vectors are actually encoded in reverse-big-endian. In other words, if smaller numbers represent lower order bits, then the state vector layout mentioned in this section would actually be encoded as follows:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0!!1!!2!!3!!4!!5!!6!!7!!8!!9!!10!!11!!12!!13!!14!!15&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Which on the physical machine actually maps to:&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot;&lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 1 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 2 &lt;br /&gt;
!colspan=&amp;quot;8&amp;quot;|State Vector Byte 3&lt;br /&gt;
|-&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
!7!!6!!5!!4!!3!!2!!1!!0&lt;br /&gt;
|-&lt;br /&gt;
!Running!!colspan=&amp;quot;16&amp;quot;|SourceTime!!colspan=&amp;quot;7&amp;quot;|unused&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!6!!5!!4!!3!!2!!1!!0!!15!!14!!13!!12!!11!!10!!9!!8!!7&lt;br /&gt;
!colspan=&amp;quot;7&amp;quot;|&amp;amp;nbsp;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Technical_Reference:BCI2000_File_Format&amp;diff=5492</id>
		<title>Technical Reference:BCI2000 File Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Technical_Reference:BCI2000_File_Format&amp;diff=5492"/>
		<updated>2009-12-31T16:14:53Z</updated>

		<summary type="html">&lt;p&gt;Cstocks: /* Binary Data */  Clarify what &amp;quot;the last CRLF&amp;quot; means. The binary data could possibly (and probably does for large files) contain two consecutive bytes that could be interpretted as CRLF.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A BCI2000 data file consists of a header and the actual raw brain signals.&lt;br /&gt;
Its associated file name extension is &amp;lt;code&amp;gt;.dat&amp;lt;/code&amp;gt;.&lt;br /&gt;
The header consists of a definition of all system parameters and states. &lt;br /&gt;
Thus, parameter values cannot change within a [[BCI2000 Glossary#Run|run]], which in turn corresponds to a single data file.&lt;br /&gt;
&lt;br /&gt;
==Header==&lt;br /&gt;
The header of a data file consists of lines of ASCII characters, separated by a carriage return/line feed (CRLF) control character sequence typically present in DOS/Windows text files.&lt;br /&gt;
Its total length is given by the &amp;lt;code&amp;gt;HeaderLen&amp;lt;/code&amp;gt; field in the first line.&lt;br /&gt;
The header contains meta information, state (event) definitions, and parameters.&lt;br /&gt;
&lt;br /&gt;
===Meta Information===&lt;br /&gt;
The fields in the first line specify meta information required to access the binary data that follows the header.&lt;br /&gt;
&lt;br /&gt;
Since version 1.1, the first line begins with a &amp;lt;code&amp;gt;BCI2000V&amp;lt;/code&amp;gt;&lt;br /&gt;
field containing a floating point version number, and ends with a&lt;br /&gt;
&amp;lt;code&amp;gt;DataFormat&amp;lt;/code&amp;gt; field describing the format of the binary data as&lt;br /&gt;
&amp;lt;code&amp;gt;int16&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;int32&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;float32&amp;lt;/code&amp;gt;.&lt;br /&gt;
A missing &amp;lt;code&amp;gt;BCI2000V&amp;lt;/code&amp;gt; field indicates a file format version of&lt;br /&gt;
1.0, and a &amp;lt;code&amp;gt;DataFormat&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;int16&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The number of bytes in the state vector is determined by the sum of the lengths (given in bits) for all states, rounded up to the next byte (which equals the value of &amp;lt;code&amp;gt;StateVectorLength&amp;lt;/code&amp;gt; in both the first line and, since &amp;lt;code&amp;gt;StateVectorLength&amp;lt;/code&amp;gt; is also a system-wide parameter, in one of the lines in the &amp;lt;code&amp;gt;[ Parameter Definition ]&amp;lt;/code&amp;gt; section).&lt;br /&gt;
Thus, the first line contains all information required to read the binary information contained in the data file.&lt;br /&gt;
&lt;br /&gt;
===State Definitions===&lt;br /&gt;
State definitions are preceded with a line &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[ State Vector Definition ]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, and given in the general [[Technical Reference:State Definition|State Definition]] format.&lt;br /&gt;
In the context of the file header, the state definitions&#039; &#039;&#039;value&#039;&#039; fields are redundant since they match the values associated with the first sample in the data file.&lt;br /&gt;
&lt;br /&gt;
===Parameter Definitions===&lt;br /&gt;
Parameter definitions are preceded with a line &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[ Parameter Definition ]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, and follow the general [[Technical Reference:Parameter Definition|Parameter Definition]] format. They represent the respective parameters&#039; values at the beginning of the recording.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
 BCI2000V= 1.1 HeaderLen= l SourceCh= m StateVectorLength= k DataFormat= f CRLF&lt;br /&gt;
 [ State Vector Definition ] CRLF&lt;br /&gt;
 Name1 Length1 Value1 ByteLocation1 BitLocation1 CRLF&lt;br /&gt;
 Name2 Length2 Value2 ByteLocation2 BitLocation2 CRLF&lt;br /&gt;
 Name3 Length3 Value3 ByteLocation3 BitLocation3 CRLF&lt;br /&gt;
 ...&lt;br /&gt;
 [ Parameter Definition ] CRLF&lt;br /&gt;
 Section1 DataType1 Name1= Value1 DefaultValue1 LowRange1 HighRange1 // Comment CRLF&lt;br /&gt;
 Section2 DataType2 Name2= Value2 DefaultValue2 LowRange2 HighRange2 // Comment CRLF&lt;br /&gt;
 Section3 DataType3 Name3= Value3 DefaultValue3 LowRange3 HighRange3 // Comment CRLF&lt;br /&gt;
 ...&lt;br /&gt;
 CRLF&lt;br /&gt;
&lt;br /&gt;
==Binary Data==&lt;br /&gt;
The binary data directly follows the last CRLF. (The end of the header is marked by CRLF CRLF.)&lt;br /&gt;
For each sample, data values for all channels are stored, followed by &amp;lt;code&amp;gt;StateVectorLength&amp;lt;/code&amp;gt; bytes for the state vector.&lt;br /&gt;
Data samples are always stored in little endian byte ordering.&lt;br /&gt;
Their format depends on the &amp;lt;code&amp;gt;DataFormat&amp;lt;/code&amp;gt; field:&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! DataFormat field !! data type &lt;br /&gt;
|-&lt;br /&gt;
|  int16           || 2-byte signed integer &lt;br /&gt;
|-&lt;br /&gt;
|  int32           || 4-byte signed integer&lt;br /&gt;
|-&lt;br /&gt;
|  float32         || 4-byte floating point (IEEE 754)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the total file size, and the information present in the header&#039;s first line, the number of samples in a data file may be calculated as follows:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
  \textrm{samples}&lt;br /&gt;
    =\frac{(\textrm{file\ size\ in\ bytes})-\texttt{HeaderLen}}&lt;br /&gt;
    {\textrm{(data\ value\ size\ in\ bytes)}\times\texttt{SourceCh}&lt;br /&gt;
    +\texttt{StateVectorLength}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required Parameters==&lt;br /&gt;
These parameters will be present in any BCI2000 data file.&lt;br /&gt;
While some of these parameters are required to interpret a data file&#039;s content (source parameters), others reflect information about external circumstances (storage parameters), or internal housekeeping (system parameters).&lt;br /&gt;
&lt;br /&gt;
===Section Source===&lt;br /&gt;
The parameters in this section are required to be present in any BCI2000 data file.&lt;br /&gt;
These parameters are necessary to interpret the raw data contained in the file, and are thus belonging into section &#039;&#039;Source&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|+Required Parameters&lt;br /&gt;
! Type !! Parameter Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| int || SampleBlockSize || number of samples acquired, transmitted, and stored at a time&lt;br /&gt;
|-&lt;br /&gt;
| float || SamplingRate || data acquisition rate in samples per second&lt;br /&gt;
|-&lt;br /&gt;
| int || SourceCh || number of digitized and stored channels&lt;br /&gt;
|-&lt;br /&gt;
| floatlist || SourceChOffset || raw data zero offset in AD units&lt;br /&gt;
|-&lt;br /&gt;
| floatlist || SourceChGain || factor to convert raw AD units into &amp;lt;math&amp;gt;\mu V&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| int || AlignChannels || flag indicating whether data require alignment in time&lt;br /&gt;
|-&lt;br /&gt;
| floatlist || SourceChTimeOffset || individual channel offsets in time, ranging between 0 and 1; -1 indicates that offsets are distributed uniformly over 0..1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Section Storage===&lt;br /&gt;
These parameters are used to identify external circumstances of a recording, by listing subject, technical equipment, and technician information.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|+Storage Parameters&lt;br /&gt;
! Type !! Parameter Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| string || SubjectName || subject alias&lt;br /&gt;
|-&lt;br /&gt;
| string || SubjectSession || subject session number&lt;br /&gt;
|-&lt;br /&gt;
| string || SubjectRun || run number within session (auto-incremented)&lt;br /&gt;
|-&lt;br /&gt;
| string || DataDirectory || directory under which the session directory is to be created&lt;br /&gt;
|-&lt;br /&gt;
| string || ID_System || rowspan=&amp;quot;3&amp;quot; | equipment identification&lt;br /&gt;
|-&lt;br /&gt;
| string || ID_Amp&lt;br /&gt;
|-&lt;br /&gt;
| string || ID_Montage&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===Section System===&lt;br /&gt;
The parameters in this section are used by the BCI2000 modules to organize their connections, and they provide module versioning information.&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|+System Parameters&lt;br /&gt;
! Type !! Parameter Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| string || EEGsourceIP|| IP address the source module listens on&lt;br /&gt;
|-&lt;br /&gt;
| int || EEGsourcePort|| IP port the source module listens on&lt;br /&gt;
|-&lt;br /&gt;
| matrix || EEGsourceVersion || source module versioning information&lt;br /&gt;
|-&lt;br /&gt;
| string || SignalProcessingIP|| IP address the signal processing module listens on&lt;br /&gt;
|-&lt;br /&gt;
| int || SignalProcessingPort|| IP port the signal processing module listens on&lt;br /&gt;
|-&lt;br /&gt;
| matrix || SignalProcessingVersion || signal processing module versioning information&lt;br /&gt;
|-&lt;br /&gt;
| string || ApplicationIP|| IP address the application module listens on&lt;br /&gt;
|-&lt;br /&gt;
| int || ApplicationPort|| IP port the application module listens on&lt;br /&gt;
|-&lt;br /&gt;
| matrix || ApplicationVersion || application module versioning information&lt;br /&gt;
|-&lt;br /&gt;
| matrix || OperatorVersion || operator module versioning information&lt;br /&gt;
|-&lt;br /&gt;
| int || StateVectorLength || length of the state vector in bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Required States==&lt;br /&gt;
These states are present in all BCI2000 data files.&lt;br /&gt;
Individual [[User Reference:Filters|filters]] may add states to the system; see filter reference pages for a description of these states.&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|+Common States&lt;br /&gt;
! Length (bits) !! State Name !! Remarks&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Running || Setting this state to 0 will put BCI2000 into suspended mode.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || SourceTime || rowspan=&amp;quot;2&amp;quot; | Time of data acquisition/stimulus delivery as an unsigned wrap-around value with a resolution of 1ms. This information is used to measure [[User Reference:Timing|system timing]].&lt;br /&gt;
|-&lt;br /&gt;
| 16 || StimulusTime&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Software Components==&lt;br /&gt;
*For writing, information about the BCI2000 data file format is encapsulated into the [[User Reference:BCI2000FileWriter|&amp;lt;code&amp;gt;shared/fileio/dat/BCI2000FileWriter&amp;lt;/code&amp;gt;]] component.&lt;br /&gt;
*For reading, information about the BCI2000 data file format is encapsulated into [[Programming Reference:BCI2000FileReader|&amp;lt;code&amp;gt;shared/fileio/dat/BCI2000FileReader&amp;lt;/code&amp;gt;]].&lt;br /&gt;
*A Matlab mex file to read BCI2000 data files is provided at [[User Reference:Matlab MEX Files#load_bcidat|&amp;lt;code&amp;gt;Tools/mex/load_bcidat&amp;lt;/code&amp;gt;]]. This mex file uses the &amp;lt;code&amp;gt;BCI2000FileReader&amp;lt;/code&amp;gt; component.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Data File Formats]], [[Technical Reference:Parameter Definition]], [[Technical Reference:State Definition]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Data Storage]][[Category:Specification]]&lt;/div&gt;</summary>
		<author><name>Cstocks</name></author>
	</entry>
</feed>