<?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=Cmpotes</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=Cmpotes"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php/Special:Contributions/Cmpotes"/>
	<updated>2026-07-02T02:11:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Impulse_response.jpg&amp;diff=6606</id>
		<title>File:Impulse response.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Impulse_response.jpg&amp;diff=6606"/>
		<updated>2012-03-20T20:20:09Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: Impulse response. N = 501&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Impulse response. N = 501&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6605</id>
		<title>Contributions:HilbertFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6605"/>
		<updated>2012-03-20T20:19:19Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
This filter computes the envelope or the phase of a signal using Hilbert transform. The discrete input signal  &#039;&#039;x&#039;&#039;(&#039;&#039;n&#039;&#039;) is first transformed to its analytic representation (i.e., analytic signal), which is composed of real and imaginary parts.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; x_{a}(n) = \operatorname{Re}(x(n)) + \operatorname{Im}(x(n))  &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The real part is the same input signal, and the imaginary part is the Hilbert transform of the input signal. The Hilbert transform is implemented as the convolution of the input signal with the filter &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi n}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even}\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get an ideal Hilbert transform, &#039;&#039;n&#039;&#039; must be infinitely long &amp;lt;math&amp;gt;(-\infty &amp;lt; n &amp;lt; \infty)&amp;lt;/math&amp;gt;. However, for real time implementations, &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;) must be truncated and delayed to guarantee a causal filter. Thus, the FIR filter is defined as &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi (n-\frac{N-1}{2})}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even},\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; 0\leq n \leq N-1 &amp;lt;/math&amp;gt;, where &#039;&#039;N&#039;&#039; must be an odd number representing the length of the filter. The resulting Hilbert transform is delayed by &amp;lt;math&amp;gt; \delta = \frac{N-1}{2} &amp;lt;/math&amp;gt; implying that the real part of the analytic signal must be delayed by the same amount too in order to estimate  the envelope and phase of the input signal.&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
Not yet released:  will be released at  http://{{SERVERNAME}}/svn/trunk/src/contrib/SignalProcessing/HilbertSignalProcessing/HilbertFilter.cpp&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Cristhian Potes, Jeremy Hill&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under:&lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: &lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===OutputSignal===&lt;br /&gt;
This parameter may be one of&lt;br /&gt;
;0 - Copy input signal&lt;br /&gt;
:no processing,&lt;br /&gt;
;1 - Magnitude&lt;br /&gt;
:Hilbert envelope amplitude,&lt;br /&gt;
;2 - Phase&lt;br /&gt;
:Hilbert phase,&lt;br /&gt;
;3 - Real part&lt;br /&gt;
:original input signal, but with a delay to match its timing to the imaginary part.&lt;br /&gt;
;4 - Imaginary part&lt;br /&gt;
:original signal filtered with an FIR-Hilbert transformer.&lt;br /&gt;
&lt;br /&gt;
===Delay===&lt;br /&gt;
The delay of the Hilbert transform can be calculated as &amp;lt;math&amp;gt; \delta = \frac{N-1}{2} &amp;lt;/math&amp;gt;, where &#039;&#039;N&#039;&#039; is an odd number representing the length of the filter. &lt;br /&gt;
 &lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Contributions:HilbertSignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6604</id>
		<title>Contributions:HilbertFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6604"/>
		<updated>2012-03-20T19:31:48Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Synopsis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
This filter computes the envelope or the phase of a signal using Hilbert transform. The discrete input signal  &#039;&#039;x&#039;&#039;(&#039;&#039;n&#039;&#039;) is first transformed to its analytic representation (i.e., analytic signal), which is composed of real and imaginary parts.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; x_{a}(n) = \operatorname{Re}(x(n)) + \operatorname{Im}(x(n))  &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The real part is the same input signal, and the imaginary part is the Hilbert transform of the input signal. The Hilbert transform is implemented as the convolution of the input signal with the filter &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi n}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even}\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get an ideal Hilbert transform, &#039;&#039;n&#039;&#039; must be infinitely long &amp;lt;math&amp;gt;(-\infty &amp;lt; n &amp;lt; \infty)&amp;lt;/math&amp;gt;. However, for real time implementations, &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;) must be truncated and delayed to guarantee a causal filter. Thus, the FIR filter is defined as &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi (n-\frac{N-1}{2})}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even},\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; 0\leq n \leq N-1 &amp;lt;/math&amp;gt;, where &#039;&#039;N&#039;&#039; must be an odd number representing the length of the filter. The resulting Hilbert transform is delayed by &amp;lt;math&amp;gt; \delta = \frac{N-1}{2} &amp;lt;/math&amp;gt; implying that the real part of the analytic signal must be delayed by the same amount too in order to estimate  the envelope and phase of the input signal.&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
Not yet released:  will be released at  http://{{SERVERNAME}}/svn/trunk/src/contrib/SignalProcessing/HilbertSignalProcessing/HilbertFilter.cpp&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Cristhian Potes, Jeremy Hill&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under:&lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: &lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===OutputSignal===&lt;br /&gt;
This parameter may be one of&lt;br /&gt;
;0 - Copy input signal&lt;br /&gt;
:no processing,&lt;br /&gt;
;1 - Magnitude&lt;br /&gt;
:Hilbert envelope amplitude,&lt;br /&gt;
;2 - Phase&lt;br /&gt;
:Hilbert phase,&lt;br /&gt;
;3 - Real part&lt;br /&gt;
:original input signal, but with a delay to match its timing to the imaginary part.&lt;br /&gt;
;4 - Imaginary part&lt;br /&gt;
:original signal filtered with an FIR-Hilbert transformer.&lt;br /&gt;
&lt;br /&gt;
===Delay===&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Contributions:HilbertSignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6603</id>
		<title>Contributions:HilbertFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6603"/>
		<updated>2012-03-20T19:24:15Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Synopsis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
This filter computes the envelope or the phase of a signal using Hilbert transform. The discrete input signal  &#039;&#039;x&#039;&#039;(&#039;&#039;n&#039;&#039;) is first transformed to its analytic representation (i.e., analytic signal), which is composed of real and imaginary parts.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; x_{a}(n) = \operatorname{Re}(x(n)) + \operatorname{Im}(x(n))  &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The real part is the same input signal, and the imaginary part is the Hilbert transform of the input signal. The Hilbert transform is implemented as the convolution of the input signal with the filter &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi n}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even}\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get an ideal Hilbert transform, &#039;&#039;n&#039;&#039; must be infinitely long &amp;lt;math&amp;gt;(-\infty &amp;lt; n &amp;lt; \infty)&amp;lt;/math&amp;gt;. However, for real time implementations, &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;) must be truncated and delayed to guarantee a causal filter. Thus, the FIR filter is defined as &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi (n-\frac{N-1}{2})}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even},\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; 0\leq n \leq N-1 &amp;lt;/math&amp;gt;, where &#039;&#039;N&#039;&#039; must be an odd number representing the length of the filter. The resulting Hilbert transform is delayed by &amp;lt;math&amp;gt; \delta = \frac{N-1}{2} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
Not yet released:  will be released at  http://{{SERVERNAME}}/svn/trunk/src/contrib/SignalProcessing/HilbertSignalProcessing/HilbertFilter.cpp&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Cristhian Potes, Jeremy Hill&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under:&lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: &lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===OutputSignal===&lt;br /&gt;
This parameter may be one of&lt;br /&gt;
;0 - Copy input signal&lt;br /&gt;
:no processing,&lt;br /&gt;
;1 - Magnitude&lt;br /&gt;
:Hilbert envelope amplitude,&lt;br /&gt;
;2 - Phase&lt;br /&gt;
:Hilbert phase,&lt;br /&gt;
;3 - Real part&lt;br /&gt;
:original input signal, but with a delay to match its timing to the imaginary part.&lt;br /&gt;
;4 - Imaginary part&lt;br /&gt;
:original signal filtered with an FIR-Hilbert transformer.&lt;br /&gt;
&lt;br /&gt;
===Delay===&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Contributions:HilbertSignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6602</id>
		<title>Contributions:HilbertFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6602"/>
		<updated>2012-03-20T19:23:22Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Synopsis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
This filter computes the envelope or the phase of a signal using Hilbert transform. The discrete input signal  &#039;&#039;x&#039;&#039;(&#039;&#039;n&#039;&#039;) is first transformed to its analytic representation (i.e., analytic signal), which is composed of real and imaginary parts.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; x_{a}(n) = \operatorname{Re}(x(n)) + \operatorname{Im}(x(n))  &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The real part is the same input signal, and the imaginary part is the Hilbert transform of the input signal. The Hilbert transform was implemented as the convolution of the input signal with the filter &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi n}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even}\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get an ideal Hilbert transform, &#039;&#039;n&#039;&#039; must be infinitely long &amp;lt;math&amp;gt;(-\infty &amp;lt; n &amp;lt; \infty)&amp;lt;/math&amp;gt;. However, for real time implementations, &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;) must be truncated and delayed to guarantee a causal filter. Thus, the FIR filter is defined as &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi (n-\frac{N-1}{2})}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even},\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; 0\leq n \leq N-1 &amp;lt;/math&amp;gt;, where &#039;&#039;N&#039;&#039; must be an odd number representing the length of the filter. The resulting Hilbert transform is delayed by &amp;lt;math&amp;gt; \delta = \frac{N-1}{2} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
Not yet released:  will be released at  http://{{SERVERNAME}}/svn/trunk/src/contrib/SignalProcessing/HilbertSignalProcessing/HilbertFilter.cpp&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Cristhian Potes, Jeremy Hill&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under:&lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: &lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===OutputSignal===&lt;br /&gt;
This parameter may be one of&lt;br /&gt;
;0 - Copy input signal&lt;br /&gt;
:no processing,&lt;br /&gt;
;1 - Magnitude&lt;br /&gt;
:Hilbert envelope amplitude,&lt;br /&gt;
;2 - Phase&lt;br /&gt;
:Hilbert phase,&lt;br /&gt;
;3 - Real part&lt;br /&gt;
:original input signal, but with a delay to match its timing to the imaginary part.&lt;br /&gt;
;4 - Imaginary part&lt;br /&gt;
:original signal filtered with an FIR-Hilbert transformer.&lt;br /&gt;
&lt;br /&gt;
===Delay===&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Contributions:HilbertSignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6601</id>
		<title>Contributions:HilbertFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6601"/>
		<updated>2012-03-20T19:22:45Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Synopsis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
This filter computes the envelope or the phase of a signal using Hilbert transform. The discrete input signal  &#039;&#039;x&#039;&#039;(&#039;&#039;n&#039;&#039;) is first transformed to its analytic representation (i.e., analytic signal), which is composed of a real and an imaginary part.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; x_{a}(n) = \operatorname{Re}(x(n)) + \operatorname{Im}(x(n))  &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The real part is the same input signal, and the imaginary part is the Hilbert transform of the input signal. The Hilbert transform was implemented as the convolution of the input signal with the filter &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi n}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even}\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get an ideal Hilbert transform, &#039;&#039;n&#039;&#039; must be infinitely long &amp;lt;math&amp;gt;(-\infty &amp;lt; n &amp;lt; \infty)&amp;lt;/math&amp;gt;. However, for real time implementations, &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;) must be truncated and delayed to guarantee a causal filter. Thus, the FIR filter is defined as &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi (n-\frac{N-1}{2})}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even},\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; 0\leq n \leq N-1 &amp;lt;/math&amp;gt;, where &#039;&#039;N&#039;&#039; must be an odd number representing the length of the filter. The resulting Hilbert transform is delayed by &amp;lt;math&amp;gt; \delta = \frac{N-1}{2} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
Not yet released:  will be released at  http://{{SERVERNAME}}/svn/trunk/src/contrib/SignalProcessing/HilbertSignalProcessing/HilbertFilter.cpp&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Cristhian Potes, Jeremy Hill&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under:&lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: &lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===OutputSignal===&lt;br /&gt;
This parameter may be one of&lt;br /&gt;
;0 - Copy input signal&lt;br /&gt;
:no processing,&lt;br /&gt;
;1 - Magnitude&lt;br /&gt;
:Hilbert envelope amplitude,&lt;br /&gt;
;2 - Phase&lt;br /&gt;
:Hilbert phase,&lt;br /&gt;
;3 - Real part&lt;br /&gt;
:original input signal, but with a delay to match its timing to the imaginary part.&lt;br /&gt;
;4 - Imaginary part&lt;br /&gt;
:original signal filtered with an FIR-Hilbert transformer.&lt;br /&gt;
&lt;br /&gt;
===Delay===&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Contributions:HilbertSignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6600</id>
		<title>Contributions:HilbertFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6600"/>
		<updated>2012-03-19T21:27:19Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Synopsis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
This filter computes the envelope or the phase of a signal using Hilbert transform. The discrete input signal  &#039;&#039;x&#039;&#039;(&#039;&#039;n&#039;&#039;) is first transformed to its analytic representation (i.e., analytic signal), which is composed of a real and an imaginary part.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; x_{a}(n) = \operatorname{Re}(x(n)) + \operatorname{Im}(x(n))  &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The real part is the same input signal, and the imaginary part is the Hilbert transform of the input signal. The Hilbert transform was implemented as the convolution of the input signal with the FIR filter &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi n}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even}\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get an ideal Hilbert transform, &#039;&#039;n&#039;&#039; must be infinitely long &amp;lt;math&amp;gt;(-\infty &amp;lt; n &amp;lt; \infty)&amp;lt;/math&amp;gt;. However, for real time implementations, &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;) must be truncated and delayed to guarantee a causal filter.&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
Not yet released:  will be released at  http://{{SERVERNAME}}/svn/trunk/src/contrib/SignalProcessing/HilbertSignalProcessing/HilbertFilter.cpp&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Cristhian Potes, Jeremy Hill&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under:&lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: &lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===OutputSignal===&lt;br /&gt;
This parameter may be one of&lt;br /&gt;
;0 - Copy input signal&lt;br /&gt;
:no processing,&lt;br /&gt;
;1 - Magnitude&lt;br /&gt;
:Hilbert envelope amplitude,&lt;br /&gt;
;2 - Phase&lt;br /&gt;
:Hilbert phase,&lt;br /&gt;
;3 - Real part&lt;br /&gt;
:original input signal, but with a delay to match its timing to the imaginary part.&lt;br /&gt;
;4 - Imaginary part&lt;br /&gt;
:original signal filtered with an FIR-Hilbert transformer.&lt;br /&gt;
&lt;br /&gt;
===Delay===&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Contributions:HilbertSignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6599</id>
		<title>Contributions:HilbertFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6599"/>
		<updated>2012-03-19T21:19:13Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Synopsis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
This filter computes the envelope or the phase of a signal using Hilbert transform. The discrete input signal &amp;lt;math&amp;gt; x(n) &amp;lt;/math&amp;gt; is first transformed to its analytic representation (i.e., analytic signal), which is composed of a real and an imaginary part.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; x_{a}(n) = \operatorname{Re}(x(n)) + \operatorname{Im}(x(n))  &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The real part is the same input signal, and the imaginary part is the Hilbert transform of the input signal. The Hilbert transform was implemented as the convolution of the input signal with the FIR filter &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi n}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even}\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get an ideal Hilbert transform, &#039;&#039;n&#039;&#039; must be infinitely long &amp;lt;math&amp;gt;(-\infty &amp;lt; n &amp;lt; \infty)&amp;lt;/math&amp;gt;. However, for real time implementations, &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;) must be truncated and delayed to guarantee a causal filter.&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
Not yet released:  will be released at  http://{{SERVERNAME}}/svn/trunk/src/contrib/SignalProcessing/HilbertSignalProcessing/HilbertFilter.cpp&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Cristhian Potes, Jeremy Hill&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under:&lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: &lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===OutputSignal===&lt;br /&gt;
This parameter may be one of&lt;br /&gt;
;0 - Copy input signal&lt;br /&gt;
:no processing,&lt;br /&gt;
;1 - Magnitude&lt;br /&gt;
:Hilbert envelope amplitude,&lt;br /&gt;
;2 - Phase&lt;br /&gt;
:Hilbert phase,&lt;br /&gt;
;3 - Real part&lt;br /&gt;
:original input signal, but with a delay to match its timing to the imaginary part.&lt;br /&gt;
;4 - Imaginary part&lt;br /&gt;
:original signal filtered with an FIR-Hilbert transformer.&lt;br /&gt;
&lt;br /&gt;
===Delay===&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Contributions:HilbertSignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6598</id>
		<title>Contributions:HilbertFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:HilbertFilter&amp;diff=6598"/>
		<updated>2012-03-19T21:10:26Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Synopsis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
This filter computes the envelope or the phase of a signal using Hilbert transform. The discrete input signal &amp;lt;math&amp;gt; x(n) &amp;lt;/math&amp;gt; is first transformed to its analytic representation (i.e., analytic signal), which is composed of a real and an imaginary part.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; x_{a}(n) = \operatorname{Re}(x(n)) + \operatorname{Im}(x(n))  &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The real part is the same input signal, and the imaginary part is the Hilbert transform of the input signal. The Hilbert transform was implemented as the convolution of the input signal &#039;&#039;x&#039;&#039;(&#039;&#039;n&#039;&#039;) with the FIR filter &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;). To get a good approximation of the Hilbert transform, &#039;&#039;n&#039;&#039; must be infinitely long (\-inf &amp;lt; n &amp;lt; /inf)&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; h(n) =  &lt;br /&gt;
\begin{cases}&lt;br /&gt;
\ \ {2 \over \pi n}, &amp;amp; \mbox{for } n \mbox{ odd}\\&lt;br /&gt;
\ \ 0, &amp;amp; \mbox{for } n \mbox{ even}\\&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &#039;&#039;h&#039;&#039;(&#039;&#039;n&#039;&#039;) must be a causal filter, there is a&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
Not yet released:  will be released at  http://{{SERVERNAME}}/svn/trunk/src/contrib/SignalProcessing/HilbertSignalProcessing/HilbertFilter.cpp&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
Cristhian Potes, Jeremy Hill&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under:&lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: &lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===OutputSignal===&lt;br /&gt;
This parameter may be one of&lt;br /&gt;
;0 - Copy input signal&lt;br /&gt;
:no processing,&lt;br /&gt;
;1 - Magnitude&lt;br /&gt;
:Hilbert envelope amplitude,&lt;br /&gt;
;2 - Phase&lt;br /&gt;
:Hilbert phase,&lt;br /&gt;
;3 - Real part&lt;br /&gt;
:original input signal, but with a delay to match its timing to the imaginary part.&lt;br /&gt;
;4 - Imaginary part&lt;br /&gt;
:original signal filtered with an FIR-Hilbert transformer.&lt;br /&gt;
&lt;br /&gt;
===Delay===&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Contributions:HilbertSignalProcessing]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Signal Processing]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5439</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=5439"/>
		<updated>2009-09-15T22:35:50Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5438</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=5438"/>
		<updated>2009-09-15T22:32:25Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5437</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=5437"/>
		<updated>2009-09-15T22:09:43Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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 files.]]&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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5436</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=5436"/>
		<updated>2009-09-15T22:08:03Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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 files.]]&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 files (no testing data files) 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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5435</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=5435"/>
		<updated>2009-09-15T22:06:36Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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 files.]]&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 files. Each 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 files (no testing data files) 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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5434</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=5434"/>
		<updated>2009-09-15T22:04:37Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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 files.]]&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 files 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 files. Each 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 files (no testing data files) 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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5433</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=5433"/>
		<updated>2009-09-15T22:02:19Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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 files, 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 enable 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 files.]]&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 files 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 files. Each 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 files (no testing data files) 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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial8.png&amp;diff=5432</id>
		<title>File:Tutorial8.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial8.png&amp;diff=5432"/>
		<updated>2009-09-15T22:00:50Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial7.png&amp;diff=5431</id>
		<title>File:Tutorial7.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial7.png&amp;diff=5431"/>
		<updated>2009-09-15T22:00:40Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial6.png&amp;diff=5430</id>
		<title>File:Tutorial6.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial6.png&amp;diff=5430"/>
		<updated>2009-09-15T22:00:25Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial5.png&amp;diff=5429</id>
		<title>File:Tutorial5.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial5.png&amp;diff=5429"/>
		<updated>2009-09-15T22:00:12Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial4.png&amp;diff=5428</id>
		<title>File:Tutorial4.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial4.png&amp;diff=5428"/>
		<updated>2009-09-15T21:57:44Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial3.png&amp;diff=5427</id>
		<title>File:Tutorial3.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial3.png&amp;diff=5427"/>
		<updated>2009-09-15T21:56:56Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial2.png&amp;diff=5426</id>
		<title>File:Tutorial2.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial2.png&amp;diff=5426"/>
		<updated>2009-09-15T21:56:01Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5425</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=5425"/>
		<updated>2009-09-15T21:54:27Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5424</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=5424"/>
		<updated>2009-09-15T21:51:10Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial1.png&amp;diff=5423</id>
		<title>File:Tutorial1.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial1.png&amp;diff=5423"/>
		<updated>2009-09-15T21:49:42Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5422</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=5422"/>
		<updated>2009-09-15T21:49:04Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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 these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5421</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=5421"/>
		<updated>2009-09-15T21:45:55Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Step 1: [http://www.bci2000.org/wiki/index.php/UserReference:P300ClassifierMethods Load BCI2000 Data Files] */&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/trunk/src/private/Tools/P300_classifier&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 enable. If there are not 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 these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1_1.png|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5420</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=5420"/>
		<updated>2009-09-15T21:44:36Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Step 1: [http://www.bci2000.org/wiki/index.php/UserReference:P300ClassifierMethods Load BCI2000 Data Files] */&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/trunk/src/private/Tools/P300_classifier&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 files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training data files are 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 enable. If there are not 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 these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1_1.png|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial0.png&amp;diff=5419</id>
		<title>File:Tutorial0.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial0.png&amp;diff=5419"/>
		<updated>2009-09-15T21:43:20Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5418</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=5418"/>
		<updated>2009-09-15T19:39:27Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Step 1: [http://www.bci2000.org/wiki/index.php/UserReference:P300ClassifierMethods Load BCI2000 Data Files] */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training data files are 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 enable. If there are not 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 these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1_1.png|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial_1_1.png&amp;diff=5417</id>
		<title>File:Tutorial 1 1.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Tutorial_1_1.png&amp;diff=5417"/>
		<updated>2009-09-15T19:25:44Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5416</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=5416"/>
		<updated>2009-09-15T19:25:20Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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 enable. If there are not 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 these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1_1.png|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5415</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=5415"/>
		<updated>2009-09-15T19:23:28Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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 enable. If there are not 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 these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1_1.tif|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5414</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=5414"/>
		<updated>2009-09-15T19:20:29Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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 enable. If there are not 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 these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1_1.tiff|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5413</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=5413"/>
		<updated>2009-09-15T19:17:25Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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 enable. If there are not 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 these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1_1.jpg|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5412</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=5412"/>
		<updated>2009-09-15T19:13:26Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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 enable. If there are not 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 \bf{eeg3_1.dat}.&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1.jpg|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5411</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=5411"/>
		<updated>2009-09-15T19:11:34Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Example */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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 enable. If there are not 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.&lt;br /&gt;
&lt;br /&gt;
; eeg3_1.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1.jpg|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5407</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=5407"/>
		<updated>2009-09-14T00:14:12Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Testing the SWLDA Classifier */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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 enable. If there are not 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 files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R02.dat&lt;br /&gt;
; PXBS001R04.dat&lt;br /&gt;
; PXBS001R06.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1.jpg|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5406</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=5406"/>
		<updated>2009-09-14T00:11:02Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Step 3: [http://www.bci2000.org/wiki/index.php/User_Reference:Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA)] */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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 enable. If there are not testing data files loaded, the investigator must press this button to load testing data file(s). One or more BCI200 *.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 files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R02.dat&lt;br /&gt;
; PXBS001R04.dat&lt;br /&gt;
; PXBS001R06.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1.jpg|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5405</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=5405"/>
		<updated>2009-09-14T00:10:03Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Step 2: [http://www.bci2000.org/wiki/index.php/User_Reference:Methods Get P300 Responses] */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are 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/User_Reference: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 enable. If there are not testing data files loaded, the investigator must press this button to load testing data file(s). One or more BCI200 *.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 files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R02.dat&lt;br /&gt;
; PXBS001R04.dat&lt;br /&gt;
; PXBS001R06.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1.jpg|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:P300Classifier&amp;diff=5404</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=5404"/>
		<updated>2009-09-14T00:09:35Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Step 1: [http://www.bci2000.org/wiki/index.php/User_Reference:Methods Load BCI2000 Data Files] */&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/trunk/src/private/Tools/P300_classifier&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:filesok.jpg|frame|center|Training data file is not valid; the file is highlighted in pink. Testing data files are valid; all the files are highlighted in light green. The &#039;&#039;Generate Feature Weights&#039;&#039; button is not enabled until all the training and testing data files are valid.]]&lt;br /&gt;
&lt;br /&gt;
====Step 2: [http://www.bci2000.org/wiki/index.php/User_Reference:Methods 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/User_Reference: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 enable. If there are not testing data files loaded, the investigator must press this button to load testing data file(s). One or more BCI200 *.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 files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R02.dat&lt;br /&gt;
; PXBS001R04.dat&lt;br /&gt;
; PXBS001R06.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the training data files are set up correctly since they are colored in light green. Remember that the classifier algorithm will be trained by using these training data files. &lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_1.jpg|frame|center|By pressing the &#039;&#039;Load Training Data Files&#039;&#039; button it is uploaded the desired BCI2000 training data files. The classifier algorithm is trained by using these training data files.]]&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 // 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 = 2 // 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;
[[image:tutorial_2.jpg|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 enable, 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:tutorial_3.jpg|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 files, 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 enable until that specific field is properly configured.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_4.jpg|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 files.]]&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 files 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:tutorial_5.jpg|frame|center|Details of the training data files 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 files, and it has generated the corresponding feature weights, it is desired to test these feature weights with the following BCI2000 testing data files.&lt;br /&gt;
&lt;br /&gt;
; PXBS001R08.dat&lt;br /&gt;
; PXBS001R10.dat&lt;br /&gt;
; PXBS001R12.dat&lt;br /&gt;
&lt;br /&gt;
By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button these files are uploaded as shown in the next figure. Notice that all the testing data files are set up correctly since they are colored in light green. If all the testing data files are valid then the &#039;&#039;Apply Feature Weights&#039;&#039; button is enable.&lt;br /&gt;
&lt;br /&gt;
[[image:tutorial_6.jpg|frame|center|By pressing the &#039;&#039;Load Testing Data Files&#039;&#039; button it is uploaded the desired BCI2000 testing data files. Each 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 files (no testing data files) 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:tutorial_7.jpg|frame|center|Details of the training data files and progress of the classification. Testing feature weights generated from the training data files. 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:tutorial_8.jpg|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>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Methods&amp;diff=5403</id>
		<title>User Reference:Methods</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Methods&amp;diff=5403"/>
		<updated>2009-09-14T00:08:25Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: User Reference:Methods moved to UserReference:P300ClassifierMethods: It is most appropriate.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[UserReference:P300ClassifierMethods]]&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5402</id>
		<title>UserReference:P300ClassifierMethods</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5402"/>
		<updated>2009-09-14T00:08:25Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: User Reference:Methods moved to UserReference:P300ClassifierMethods: It is most appropriate.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Load BCI2000 Data Files ==&lt;br /&gt;
&lt;br /&gt;
Once the BCI2000 data files are check for compatibility, signals are extracted either from each training or testing data file and are arranged in a matrix form as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{\mathbf{X_{i}^{k}(n)}} =&lt;br /&gt;
\begin{bmatrix}&lt;br /&gt;
x_{1}^{1}(0) &amp;amp; x_{1}^{1}(1) &amp;amp; \cdots &amp;amp; x_{1}^{1}(p-1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(0) &amp;amp; x_{1}^{l}(1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(p-1) \\&lt;br /&gt;
x_{2}^{1}(0) &amp;amp; x_{2}^{1}(1) &amp;amp; \cdots &amp;amp; x_{2}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{2}^{l}(0) &amp;amp; x_{2}^{l}(1) &amp;amp; \cdots &amp;amp; x_{2}^{l}(p-1) \\&lt;br /&gt;
\vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp;\vdots &amp;amp; \cdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp; \vdots \\&lt;br /&gt;
x_{m}^{1}(0) &amp;amp; x_{m}^{1}(1) &amp;amp; \cdots &amp;amp; x_{m}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{m}^{l}(0) &amp;amp; x_{m}^{l}(1) &amp;amp; \cdots &amp;amp; x_{m}^{l}(p-1) \\&lt;br /&gt;
\end{bmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; i = 1, 2, \ldots, m; &amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; k = 1, 2, \ldots, l; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; n = 0, 1, \ldots, p-1; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
being &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; the total number of observations (stimuli), &amp;lt;math&amp;gt; l &amp;lt;/math&amp;gt; the total number of channels, and &amp;lt;math&amp;gt; p = t*Fs &amp;lt;/math&amp;gt; the total number of samples recorded for each channel. &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; is the recording stimulus time, and &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt; is the sampling frequency.&lt;br /&gt;
&lt;br /&gt;
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word &amp;quot;SEND&amp;quot;, a total of 4 characters.&lt;br /&gt;
&lt;br /&gt;
[[Image:P3SpellerScreen.PNG|center|frame|A 6 by 6 speller matrix. Here, the user&#039;s task is to spell the word &amp;quot;SEND&amp;quot; (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]&lt;br /&gt;
&lt;br /&gt;
Assume that the data set is recorded from 8 channels at 256 Hz, the elapsed time from the start to the end of each intensification is 800 ms, and the [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Decimation Frequency&#039;&#039;&#039;]] provided by the investigator is 20 Hz.  For this example, &amp;lt;math&amp;gt; m = 12x15x4 = 720 &amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt; l = 8 &amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt; p = round(256 x 0.800) = 205 &amp;lt;/math&amp;gt;. The total number of columns (variables) of the above matrix is &amp;lt;math&amp;gt; 8 x 205 = 1640 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Get P300 Responses ==&lt;br /&gt;
&lt;br /&gt;
In this step, it is computed the corresponding time samples of a time [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Response Window&#039;&#039;&#039;]] &amp;lt;math&amp;gt; [t_{1}, t_{2}] &amp;lt;/math&amp;gt; in (ms). Following the above example, assume that the time Response Window specified by the investigator is [0 800] ms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{1} = round\left(\frac{t_{1}Fs}{1000}\right) = round\left(\frac{0*256}{1000}\right) = 0&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{2} = round\left(\frac{t_{2}Fs}{1000}\right) = round\left(\frac{800*256}{1000}\right) = 205&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals of interest are extracted from &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; and are defined&lt;br /&gt;
only for &amp;lt;math&amp;gt; n_{1}\le n &amp;lt; n_{2} &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The coefficients &amp;lt;math&amp;gt; b_{i} &amp;lt;/math&amp;gt; of the [http://en.wikipedia.org/wiki/Moving_average Moving Average (MA)] filter are found as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
b_{i} = \frac{1}{N+1}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; i = 0, 1, 2, \ldots, N &amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the filter order. The filter order can be computed from the sampling frequency &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt;  and the provided decimation frequency &amp;lt;math&amp;gt; Df &amp;lt;/math&amp;gt; as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; &lt;br /&gt;
N = round \left(\frac{Fs}{Df}\right) = round \left(\frac{256}{20}\right) = 13 &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt; can be computed as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
h(n) = \frac{1}{N+1} \sum_{i=0}^{N-1} \delta(n-i).&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To filter the selected signals, each channel &amp;lt;math&amp;gt; k &amp;lt;/math&amp;gt; and each observation (stimulus) &amp;lt;math&amp;gt; i &amp;lt;/math&amp;gt; of the matrix &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; is convolved &amp;lt;math&amp;gt; (\star) &amp;lt;/math&amp;gt; with the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt;. The next equation shows how to filter a signal for channel &amp;lt;math&amp;gt; k = 1 &amp;lt;/math&amp;gt; and observation &amp;lt;math&amp;gt; i = 1 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
y_{1}^{1}(n) = x_{1}^{1}(n) \star h(n).&lt;br /&gt;
&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The output &amp;lt;math&amp;gt; y_{i}^{k}(n)&amp;lt;/math&amp;gt;, result of the convolution between all the extracted signals —for channels &amp;lt;math&amp;gt; k = 1, 2, \ldots, l &amp;lt;/math&amp;gt; and observations &amp;lt;math&amp;gt; i = 1, 2, \ldots, m &amp;lt;/math&amp;gt;— and the impulse response, is [http://en.wikipedia.org/wiki/Downsampling downsampled] by a factor &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA) ==&lt;br /&gt;
Consider a data vector &amp;lt;math&amp;gt; \mathbf {d} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; observations, a vector &amp;lt;math&amp;gt; \mathbf{w} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; n &amp;lt;/math&amp;gt; model parameters (weights) to estimate, and a matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt; representing the final linear model. This inverse problem can be written as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{G}\mathbf{w} = \mathbf{d}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An approximate solution to this problem can be found by minimizing the difference (residuals) between the actual data &amp;lt;math&amp;gt; \mathbf{d} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \mathbf{G}\mathbf{w} &amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{r} = \mathbf{d} - \mathbf{G}\mathbf{w}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The least squares or 2-norm solution has been adopted to minimize these residuals.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{w} = (\mathbf{G^{T}}\mathbf{G})^{-1}\mathbf{G^{T}}\mathbf{d}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The symbol &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; represents the transpose of the matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt;. Note that least squares solution is only valid for overdetermined systems (&amp;lt;math&amp;gt; m \le n &amp;lt;/math&amp;gt;); there must be in the model more observations than variables. If the residuals have a normal distribution, the least squares corresponds to the maximum likelihood criterion.&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5401</id>
		<title>UserReference:P300ClassifierMethods</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5401"/>
		<updated>2009-09-12T21:35:03Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Get P300 Responses */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Load BCI2000 Data Files ==&lt;br /&gt;
&lt;br /&gt;
Once the BCI2000 data files are check for compatibility, signals are extracted either from each training or testing data file and are arranged in a matrix form as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{\mathbf{X_{i}^{k}(n)}} =&lt;br /&gt;
\begin{bmatrix}&lt;br /&gt;
x_{1}^{1}(0) &amp;amp; x_{1}^{1}(1) &amp;amp; \cdots &amp;amp; x_{1}^{1}(p-1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(0) &amp;amp; x_{1}^{l}(1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(p-1) \\&lt;br /&gt;
x_{2}^{1}(0) &amp;amp; x_{2}^{1}(1) &amp;amp; \cdots &amp;amp; x_{2}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{2}^{l}(0) &amp;amp; x_{2}^{l}(1) &amp;amp; \cdots &amp;amp; x_{2}^{l}(p-1) \\&lt;br /&gt;
\vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp;\vdots &amp;amp; \cdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp; \vdots \\&lt;br /&gt;
x_{m}^{1}(0) &amp;amp; x_{m}^{1}(1) &amp;amp; \cdots &amp;amp; x_{m}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{m}^{l}(0) &amp;amp; x_{m}^{l}(1) &amp;amp; \cdots &amp;amp; x_{m}^{l}(p-1) \\&lt;br /&gt;
\end{bmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; i = 1, 2, \ldots, m; &amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; k = 1, 2, \ldots, l; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; n = 0, 1, \ldots, p-1; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
being &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; the total number of observations (stimuli), &amp;lt;math&amp;gt; l &amp;lt;/math&amp;gt; the total number of channels, and &amp;lt;math&amp;gt; p = t*Fs &amp;lt;/math&amp;gt; the total number of samples recorded for each channel. &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; is the recording stimulus time, and &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt; is the sampling frequency.&lt;br /&gt;
&lt;br /&gt;
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word &amp;quot;SEND&amp;quot;, a total of 4 characters.&lt;br /&gt;
&lt;br /&gt;
[[Image:P3SpellerScreen.PNG|center|frame|A 6 by 6 speller matrix. Here, the user&#039;s task is to spell the word &amp;quot;SEND&amp;quot; (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]&lt;br /&gt;
&lt;br /&gt;
Assume that the data set is recorded from 8 channels at 256 Hz, the elapsed time from the start to the end of each intensification is 800 ms, and the [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Decimation Frequency&#039;&#039;&#039;]] provided by the investigator is 20 Hz.  For this example, &amp;lt;math&amp;gt; m = 12x15x4 = 720 &amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt; l = 8 &amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt; p = round(256 x 0.800) = 205 &amp;lt;/math&amp;gt;. The total number of columns (variables) of the above matrix is &amp;lt;math&amp;gt; 8 x 205 = 1640 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Get P300 Responses ==&lt;br /&gt;
&lt;br /&gt;
In this step, it is computed the corresponding time samples of a time [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Response Window&#039;&#039;&#039;]] &amp;lt;math&amp;gt; [t_{1}, t_{2}] &amp;lt;/math&amp;gt; in (ms). Following the above example, assume that the time Response Window specified by the investigator is [0 800] ms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{1} = round\left(\frac{t_{1}Fs}{1000}\right) = round\left(\frac{0*256}{1000}\right) = 0&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{2} = round\left(\frac{t_{2}Fs}{1000}\right) = round\left(\frac{800*256}{1000}\right) = 205&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals of interest are extracted from &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; and are defined&lt;br /&gt;
only for &amp;lt;math&amp;gt; n_{1}\le n &amp;lt; n_{2} &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The coefficients &amp;lt;math&amp;gt; b_{i} &amp;lt;/math&amp;gt; of the [http://en.wikipedia.org/wiki/Moving_average Moving Average (MA)] filter are found as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
b_{i} = \frac{1}{N+1}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; i = 0, 1, 2, \ldots, N &amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the filter order. The filter order can be computed from the sampling frequency &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt;  and the provided decimation frequency &amp;lt;math&amp;gt; Df &amp;lt;/math&amp;gt; as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; &lt;br /&gt;
N = round \left(\frac{Fs}{Df}\right) = round \left(\frac{256}{20}\right) = 13 &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt; can be computed as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
h(n) = \frac{1}{N+1} \sum_{i=0}^{N-1} \delta(n-i).&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To filter the selected signals, each channel &amp;lt;math&amp;gt; k &amp;lt;/math&amp;gt; and each observation (stimulus) &amp;lt;math&amp;gt; i &amp;lt;/math&amp;gt; of the matrix &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; is convolved &amp;lt;math&amp;gt; (\star) &amp;lt;/math&amp;gt; with the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt;. The next equation shows how to filter a signal for channel &amp;lt;math&amp;gt; k = 1 &amp;lt;/math&amp;gt; and observation &amp;lt;math&amp;gt; i = 1 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
y_{1}^{1}(n) = x_{1}^{1}(n) \star h(n).&lt;br /&gt;
&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The output &amp;lt;math&amp;gt; y_{i}^{k}(n)&amp;lt;/math&amp;gt;, result of the convolution between all the extracted signals —for channels &amp;lt;math&amp;gt; k = 1, 2, \ldots, l &amp;lt;/math&amp;gt; and observations &amp;lt;math&amp;gt; i = 1, 2, \ldots, m &amp;lt;/math&amp;gt;— and the impulse response, is [http://en.wikipedia.org/wiki/Downsampling downsampled] by a factor &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA) ==&lt;br /&gt;
Consider a data vector &amp;lt;math&amp;gt; \mathbf {d} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; observations, a vector &amp;lt;math&amp;gt; \mathbf{w} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; n &amp;lt;/math&amp;gt; model parameters (weights) to estimate, and a matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt; representing the final linear model. This inverse problem can be written as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{G}\mathbf{w} = \mathbf{d}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An approximate solution to this problem can be found by minimizing the difference (residuals) between the actual data &amp;lt;math&amp;gt; \mathbf{d} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \mathbf{G}\mathbf{w} &amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{r} = \mathbf{d} - \mathbf{G}\mathbf{w}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The least squares or 2-norm solution has been adopted to minimize these residuals.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{w} = (\mathbf{G^{T}}\mathbf{G})^{-1}\mathbf{G^{T}}\mathbf{d}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The symbol &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; represents the transpose of the matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt;. Note that least squares solution is only valid for overdetermined systems (&amp;lt;math&amp;gt; m \le n &amp;lt;/math&amp;gt;); there must be in the model more observations than variables. If the residuals have a normal distribution, the least squares corresponds to the maximum likelihood criterion.&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5400</id>
		<title>UserReference:P300ClassifierMethods</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5400"/>
		<updated>2009-09-12T21:33:00Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Get P300 Responses */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Load BCI2000 Data Files ==&lt;br /&gt;
&lt;br /&gt;
Once the BCI2000 data files are check for compatibility, signals are extracted either from each training or testing data file and are arranged in a matrix form as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{\mathbf{X_{i}^{k}(n)}} =&lt;br /&gt;
\begin{bmatrix}&lt;br /&gt;
x_{1}^{1}(0) &amp;amp; x_{1}^{1}(1) &amp;amp; \cdots &amp;amp; x_{1}^{1}(p-1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(0) &amp;amp; x_{1}^{l}(1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(p-1) \\&lt;br /&gt;
x_{2}^{1}(0) &amp;amp; x_{2}^{1}(1) &amp;amp; \cdots &amp;amp; x_{2}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{2}^{l}(0) &amp;amp; x_{2}^{l}(1) &amp;amp; \cdots &amp;amp; x_{2}^{l}(p-1) \\&lt;br /&gt;
\vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp;\vdots &amp;amp; \cdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp; \vdots \\&lt;br /&gt;
x_{m}^{1}(0) &amp;amp; x_{m}^{1}(1) &amp;amp; \cdots &amp;amp; x_{m}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{m}^{l}(0) &amp;amp; x_{m}^{l}(1) &amp;amp; \cdots &amp;amp; x_{m}^{l}(p-1) \\&lt;br /&gt;
\end{bmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; i = 1, 2, \ldots, m; &amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; k = 1, 2, \ldots, l; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; n = 0, 1, \ldots, p-1; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
being &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; the total number of observations (stimuli), &amp;lt;math&amp;gt; l &amp;lt;/math&amp;gt; the total number of channels, and &amp;lt;math&amp;gt; p = t*Fs &amp;lt;/math&amp;gt; the total number of samples recorded for each channel. &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; is the recording stimulus time, and &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt; is the sampling frequency.&lt;br /&gt;
&lt;br /&gt;
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word &amp;quot;SEND&amp;quot;, a total of 4 characters.&lt;br /&gt;
&lt;br /&gt;
[[Image:P3SpellerScreen.PNG|center|frame|A 6 by 6 speller matrix. Here, the user&#039;s task is to spell the word &amp;quot;SEND&amp;quot; (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]&lt;br /&gt;
&lt;br /&gt;
Assume that the data set is recorded from 8 channels at 256 Hz, the elapsed time from the start to the end of each intensification is 800 ms, and the [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Decimation Frequency&#039;&#039;&#039;]] provided by the investigator is 20 Hz.  For this example, &amp;lt;math&amp;gt; m = 12x15x4 = 720 &amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt; l = 8 &amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt; p = round(256 x 0.800) = 205 &amp;lt;/math&amp;gt;. The total number of columns (variables) of the above matrix is &amp;lt;math&amp;gt; 8 x 205 = 1640 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Get P300 Responses ==&lt;br /&gt;
&lt;br /&gt;
In this step, it is computed the corresponding time samples of a time [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Response Window&#039;&#039;&#039;]] &amp;lt;math&amp;gt; [t_{1}, t_{2}] &amp;lt;/math&amp;gt; in (ms). Following the above example, assume that the time Response Window specified by the investigator is [0 800] ms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{1} = round\left(\frac{t_{1}Fs}{1000}\right) = round\left(\frac{0*256}{1000}\right) = 0&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{2} = round\left(\frac{t_{2}Fs}{1000}\right) = round\left(\frac{800*256}{1000}\right) = 205&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals of interest are extracted from &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; and are defined&lt;br /&gt;
only for &amp;lt;math&amp;gt; n_{1}\le n &amp;lt; n_{2} &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The coefficients &amp;lt;math&amp;gt; b_{i} &amp;lt;/math&amp;gt; of the [http://en.wikipedia.org/wiki/Moving_average Moving Average (MA)] filter are found as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
b_{i} = \frac{1}{N+1}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; i = 0, 1, 2, \ldots, N &amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the filter order. The filter order can be computed from the sampling frequency &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt;  and the provided decimation frequency &amp;lt;math&amp;gt; Df &amp;lt;/math&amp;gt; as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; &lt;br /&gt;
N = round(\frac{Fs}{Df}) = round(\frac{256}{20}) = 13 &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt; can be computed as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
h(n) = \frac{1}{N+1} \sum_{i=0}^{N-1} \delta(n-i).&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To filter the selected signals, each channel &amp;lt;math&amp;gt; k &amp;lt;/math&amp;gt; and each observation (stimulus) &amp;lt;math&amp;gt; i &amp;lt;/math&amp;gt; of the matrix &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; is convolved &amp;lt;math&amp;gt; (\star) &amp;lt;/math&amp;gt; with the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt;. The next equation shows how to filter a signal for channel &amp;lt;math&amp;gt; k = 1 &amp;lt;/math&amp;gt; and observation &amp;lt;math&amp;gt; i = 1 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
y_{1}^{1}(n) = x_{1}^{1}(n) \star h(n).&lt;br /&gt;
&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The output &amp;lt;math&amp;gt; y_{i}^{k}(n)&amp;lt;/math&amp;gt;, result of the convolution between all the extracted signals —for channels &amp;lt;math&amp;gt; k = 1, 2, \ldots, l &amp;lt;/math&amp;gt; and observations &amp;lt;math&amp;gt; i = 1, 2, \ldots, m &amp;lt;/math&amp;gt;— and the impulse response, is [http://en.wikipedia.org/wiki/Downsampling downsampled] by a factor &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA) ==&lt;br /&gt;
Consider a data vector &amp;lt;math&amp;gt; \mathbf {d} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; observations, a vector &amp;lt;math&amp;gt; \mathbf{w} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; n &amp;lt;/math&amp;gt; model parameters (weights) to estimate, and a matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt; representing the final linear model. This inverse problem can be written as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{G}\mathbf{w} = \mathbf{d}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An approximate solution to this problem can be found by minimizing the difference (residuals) between the actual data &amp;lt;math&amp;gt; \mathbf{d} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \mathbf{G}\mathbf{w} &amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{r} = \mathbf{d} - \mathbf{G}\mathbf{w}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The least squares or 2-norm solution has been adopted to minimize these residuals.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{w} = (\mathbf{G^{T}}\mathbf{G})^{-1}\mathbf{G^{T}}\mathbf{d}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The symbol &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; represents the transpose of the matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt;. Note that least squares solution is only valid for overdetermined systems (&amp;lt;math&amp;gt; m \le n &amp;lt;/math&amp;gt;); there must be in the model more observations than variables. If the residuals have a normal distribution, the least squares corresponds to the maximum likelihood criterion.&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5399</id>
		<title>UserReference:P300ClassifierMethods</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5399"/>
		<updated>2009-09-12T21:31:36Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Load BCI2000 Data Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Load BCI2000 Data Files ==&lt;br /&gt;
&lt;br /&gt;
Once the BCI2000 data files are check for compatibility, signals are extracted either from each training or testing data file and are arranged in a matrix form as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{\mathbf{X_{i}^{k}(n)}} =&lt;br /&gt;
\begin{bmatrix}&lt;br /&gt;
x_{1}^{1}(0) &amp;amp; x_{1}^{1}(1) &amp;amp; \cdots &amp;amp; x_{1}^{1}(p-1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(0) &amp;amp; x_{1}^{l}(1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(p-1) \\&lt;br /&gt;
x_{2}^{1}(0) &amp;amp; x_{2}^{1}(1) &amp;amp; \cdots &amp;amp; x_{2}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{2}^{l}(0) &amp;amp; x_{2}^{l}(1) &amp;amp; \cdots &amp;amp; x_{2}^{l}(p-1) \\&lt;br /&gt;
\vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp;\vdots &amp;amp; \cdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp; \vdots \\&lt;br /&gt;
x_{m}^{1}(0) &amp;amp; x_{m}^{1}(1) &amp;amp; \cdots &amp;amp; x_{m}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{m}^{l}(0) &amp;amp; x_{m}^{l}(1) &amp;amp; \cdots &amp;amp; x_{m}^{l}(p-1) \\&lt;br /&gt;
\end{bmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; i = 1, 2, \ldots, m; &amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; k = 1, 2, \ldots, l; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; n = 0, 1, \ldots, p-1; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
being &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; the total number of observations (stimuli), &amp;lt;math&amp;gt; l &amp;lt;/math&amp;gt; the total number of channels, and &amp;lt;math&amp;gt; p = t*Fs &amp;lt;/math&amp;gt; the total number of samples recorded for each channel. &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; is the recording stimulus time, and &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt; is the sampling frequency.&lt;br /&gt;
&lt;br /&gt;
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word &amp;quot;SEND&amp;quot;, a total of 4 characters.&lt;br /&gt;
&lt;br /&gt;
[[Image:P3SpellerScreen.PNG|center|frame|A 6 by 6 speller matrix. Here, the user&#039;s task is to spell the word &amp;quot;SEND&amp;quot; (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]&lt;br /&gt;
&lt;br /&gt;
Assume that the data set is recorded from 8 channels at 256 Hz, the elapsed time from the start to the end of each intensification is 800 ms, and the [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Decimation Frequency&#039;&#039;&#039;]] provided by the investigator is 20 Hz.  For this example, &amp;lt;math&amp;gt; m = 12x15x4 = 720 &amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt; l = 8 &amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt; p = round(256 x 0.800) = 205 &amp;lt;/math&amp;gt;. The total number of columns (variables) of the above matrix is &amp;lt;math&amp;gt; 8 x 205 = 1640 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Get P300 Responses ==&lt;br /&gt;
&lt;br /&gt;
In this step, it is computed the corresponding time samples of a time [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Response Window&#039;&#039;&#039;]] &amp;lt;math&amp;gt; [t_{1}, t_{2}] &amp;lt;/math&amp;gt; in (ms). Following the above example, assume that the time Response Window specified by the investigator is [0 800] ms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{1} = round\left(\frac{t_{1}Fs}{1000}\right) = round\left(\frac{0*256}{1000}\right) = 0&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{2} = round\left(\frac{t_{2}Fs}{1000}\right) = round\left(\frac{800*256}{1000}\right) = 205&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals of interest are extracted from &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; and are defined&lt;br /&gt;
only for &amp;lt;math&amp;gt; n_{1}\le n &amp;lt; n_{2} &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The coefficients &amp;lt;math&amp;gt; b_{i} &amp;lt;/math&amp;gt; of the [http://en.wikipedia.org/wiki/Moving_average Moving Average (MA)] filter are found as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
b_{i} = \frac{1}{N+1}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; i = 0, 1, 2, \ldots, N &amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the filter order. The filter order can be computed from the sampling frequency &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt;  and the provided decimation frequency &amp;lt;math&amp;gt; Df &amp;lt;/math&amp;gt; as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; &lt;br /&gt;
N = \frac{Fs}{Df}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt; can be computed as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
h(n) = \frac{1}{N+1} \sum_{i=0}^{N-1} \delta(n-i).&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To filter the selected signals, each channel &amp;lt;math&amp;gt; k &amp;lt;/math&amp;gt; and each observation (stimulus) &amp;lt;math&amp;gt; i &amp;lt;/math&amp;gt; of the matrix &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; is convolved &amp;lt;math&amp;gt; (\star) &amp;lt;/math&amp;gt; with the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt;. The next equation shows how to filter a signal for channel &amp;lt;math&amp;gt; k = 1 &amp;lt;/math&amp;gt; and observation &amp;lt;math&amp;gt; i = 1 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
y_{1}^{1}(n) = x_{1}^{1}(n) \star h(n).&lt;br /&gt;
&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The output &amp;lt;math&amp;gt; y_{i}^{k}(n)&amp;lt;/math&amp;gt;, result of the convolution between all the extracted signals —for channels &amp;lt;math&amp;gt; k = 1, 2, \ldots, l &amp;lt;/math&amp;gt; and observations &amp;lt;math&amp;gt; i = 1, 2, \ldots, m &amp;lt;/math&amp;gt;— and the impulse response, is [http://en.wikipedia.org/wiki/Downsampling downsampled] by a factor &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA) ==&lt;br /&gt;
Consider a data vector &amp;lt;math&amp;gt; \mathbf {d} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; observations, a vector &amp;lt;math&amp;gt; \mathbf{w} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; n &amp;lt;/math&amp;gt; model parameters (weights) to estimate, and a matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt; representing the final linear model. This inverse problem can be written as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{G}\mathbf{w} = \mathbf{d}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An approximate solution to this problem can be found by minimizing the difference (residuals) between the actual data &amp;lt;math&amp;gt; \mathbf{d} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \mathbf{G}\mathbf{w} &amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{r} = \mathbf{d} - \mathbf{G}\mathbf{w}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The least squares or 2-norm solution has been adopted to minimize these residuals.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{w} = (\mathbf{G^{T}}\mathbf{G})^{-1}\mathbf{G^{T}}\mathbf{d}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The symbol &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; represents the transpose of the matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt;. Note that least squares solution is only valid for overdetermined systems (&amp;lt;math&amp;gt; m \le n &amp;lt;/math&amp;gt;); there must be in the model more observations than variables. If the residuals have a normal distribution, the least squares corresponds to the maximum likelihood criterion.&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5398</id>
		<title>UserReference:P300ClassifierMethods</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5398"/>
		<updated>2009-09-12T21:30:28Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Get P300 Responses */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Load BCI2000 Data Files ==&lt;br /&gt;
&lt;br /&gt;
Once the BCI2000 data files are check for compatibility, signals are extracted either from each training or testing data file and are arranged in a matrix form as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{\mathbf{X_{i}^{k}(n)}} =&lt;br /&gt;
\begin{bmatrix}&lt;br /&gt;
x_{1}^{1}(0) &amp;amp; x_{1}^{1}(1) &amp;amp; \cdots &amp;amp; x_{1}^{1}(p-1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(0) &amp;amp; x_{1}^{l}(1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(p-1) \\&lt;br /&gt;
x_{2}^{1}(0) &amp;amp; x_{2}^{1}(1) &amp;amp; \cdots &amp;amp; x_{2}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{2}^{l}(0) &amp;amp; x_{2}^{l}(1) &amp;amp; \cdots &amp;amp; x_{2}^{l}(p-1) \\&lt;br /&gt;
\vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp;\vdots &amp;amp; \cdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp; \vdots \\&lt;br /&gt;
x_{m}^{1}(0) &amp;amp; x_{m}^{1}(1) &amp;amp; \cdots &amp;amp; x_{m}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{m}^{l}(0) &amp;amp; x_{m}^{l}(1) &amp;amp; \cdots &amp;amp; x_{m}^{l}(p-1) \\&lt;br /&gt;
\end{bmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; i = 1, 2, \ldots, m; &amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; k = 1, 2, \ldots, l; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; n = 0, 1, \ldots, p-1; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
being &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; the total number of observations (stimuli), &amp;lt;math&amp;gt; l &amp;lt;/math&amp;gt; the total number of channels, and &amp;lt;math&amp;gt; p = t*Fs &amp;lt;/math&amp;gt; the total number of samples recorded for each channel. &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; is the recording stimulus time, and &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt; is the sampling frequency.&lt;br /&gt;
&lt;br /&gt;
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word &amp;quot;SEND&amp;quot;, a total of 4 characters.&lt;br /&gt;
&lt;br /&gt;
[[Image:P3SpellerScreen.PNG|center|frame|A 6 by 6 speller matrix. Here, the user&#039;s task is to spell the word &amp;quot;SEND&amp;quot; (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]&lt;br /&gt;
&lt;br /&gt;
Assume that the data set is recorded from 8 channels at 256 Hz, the elapsed time from the start to the end of each intensification is 800 ms, and the decimation frequency provided by the investigator is 20 Hz.  For this example, &amp;lt;math&amp;gt; m = 12x15x4 = 720 &amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt; l = 8 &amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt; p = round(256 x 0.800) = 205 &amp;lt;/math&amp;gt;. The total number of columns (variables) of the above matrix is &amp;lt;math&amp;gt; 8 x 205 = 1640 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Get P300 Responses ==&lt;br /&gt;
&lt;br /&gt;
In this step, it is computed the corresponding time samples of a time [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Response Window&#039;&#039;&#039;]] &amp;lt;math&amp;gt; [t_{1}, t_{2}] &amp;lt;/math&amp;gt; in (ms). Following the above example, assume that the time Response Window specified by the investigator is [0 800] ms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{1} = round\left(\frac{t_{1}Fs}{1000}\right) = round\left(\frac{0*256}{1000}\right) = 0&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{2} = round\left(\frac{t_{2}Fs}{1000}\right) = round\left(\frac{800*256}{1000}\right) = 205&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals of interest are extracted from &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; and are defined&lt;br /&gt;
only for &amp;lt;math&amp;gt; n_{1}\le n &amp;lt; n_{2} &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The coefficients &amp;lt;math&amp;gt; b_{i} &amp;lt;/math&amp;gt; of the [http://en.wikipedia.org/wiki/Moving_average Moving Average (MA)] filter are found as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
b_{i} = \frac{1}{N+1}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; i = 0, 1, 2, \ldots, N &amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the filter order. The filter order can be computed from the sampling frequency &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt;  and the provided decimation frequency &amp;lt;math&amp;gt; Df &amp;lt;/math&amp;gt; as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; &lt;br /&gt;
N = \frac{Fs}{Df}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt; can be computed as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
h(n) = \frac{1}{N+1} \sum_{i=0}^{N-1} \delta(n-i).&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To filter the selected signals, each channel &amp;lt;math&amp;gt; k &amp;lt;/math&amp;gt; and each observation (stimulus) &amp;lt;math&amp;gt; i &amp;lt;/math&amp;gt; of the matrix &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; is convolved &amp;lt;math&amp;gt; (\star) &amp;lt;/math&amp;gt; with the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt;. The next equation shows how to filter a signal for channel &amp;lt;math&amp;gt; k = 1 &amp;lt;/math&amp;gt; and observation &amp;lt;math&amp;gt; i = 1 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
y_{1}^{1}(n) = x_{1}^{1}(n) \star h(n).&lt;br /&gt;
&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The output &amp;lt;math&amp;gt; y_{i}^{k}(n)&amp;lt;/math&amp;gt;, result of the convolution between all the extracted signals —for channels &amp;lt;math&amp;gt; k = 1, 2, \ldots, l &amp;lt;/math&amp;gt; and observations &amp;lt;math&amp;gt; i = 1, 2, \ldots, m &amp;lt;/math&amp;gt;— and the impulse response, is [http://en.wikipedia.org/wiki/Downsampling downsampled] by a factor &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA) ==&lt;br /&gt;
Consider a data vector &amp;lt;math&amp;gt; \mathbf {d} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; observations, a vector &amp;lt;math&amp;gt; \mathbf{w} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; n &amp;lt;/math&amp;gt; model parameters (weights) to estimate, and a matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt; representing the final linear model. This inverse problem can be written as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{G}\mathbf{w} = \mathbf{d}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An approximate solution to this problem can be found by minimizing the difference (residuals) between the actual data &amp;lt;math&amp;gt; \mathbf{d} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \mathbf{G}\mathbf{w} &amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{r} = \mathbf{d} - \mathbf{G}\mathbf{w}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The least squares or 2-norm solution has been adopted to minimize these residuals.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{w} = (\mathbf{G^{T}}\mathbf{G})^{-1}\mathbf{G^{T}}\mathbf{d}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The symbol &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; represents the transpose of the matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt;. Note that least squares solution is only valid for overdetermined systems (&amp;lt;math&amp;gt; m \le n &amp;lt;/math&amp;gt;); there must be in the model more observations than variables. If the residuals have a normal distribution, the least squares corresponds to the maximum likelihood criterion.&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5397</id>
		<title>UserReference:P300ClassifierMethods</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5397"/>
		<updated>2009-09-12T21:27:23Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Load BCI2000 Data Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Load BCI2000 Data Files ==&lt;br /&gt;
&lt;br /&gt;
Once the BCI2000 data files are check for compatibility, signals are extracted either from each training or testing data file and are arranged in a matrix form as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{\mathbf{X_{i}^{k}(n)}} =&lt;br /&gt;
\begin{bmatrix}&lt;br /&gt;
x_{1}^{1}(0) &amp;amp; x_{1}^{1}(1) &amp;amp; \cdots &amp;amp; x_{1}^{1}(p-1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(0) &amp;amp; x_{1}^{l}(1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(p-1) \\&lt;br /&gt;
x_{2}^{1}(0) &amp;amp; x_{2}^{1}(1) &amp;amp; \cdots &amp;amp; x_{2}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{2}^{l}(0) &amp;amp; x_{2}^{l}(1) &amp;amp; \cdots &amp;amp; x_{2}^{l}(p-1) \\&lt;br /&gt;
\vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp;\vdots &amp;amp; \cdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp; \vdots \\&lt;br /&gt;
x_{m}^{1}(0) &amp;amp; x_{m}^{1}(1) &amp;amp; \cdots &amp;amp; x_{m}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{m}^{l}(0) &amp;amp; x_{m}^{l}(1) &amp;amp; \cdots &amp;amp; x_{m}^{l}(p-1) \\&lt;br /&gt;
\end{bmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; i = 1, 2, \ldots, m; &amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; k = 1, 2, \ldots, l; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; n = 0, 1, \ldots, p-1; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
being &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; the total number of observations (stimuli), &amp;lt;math&amp;gt; l &amp;lt;/math&amp;gt; the total number of channels, and &amp;lt;math&amp;gt; p = t*Fs &amp;lt;/math&amp;gt; the total number of samples recorded for each channel. &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; is the recording stimulus time, and &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt; is the sampling frequency.&lt;br /&gt;
&lt;br /&gt;
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word &amp;quot;SEND&amp;quot;, a total of 4 characters.&lt;br /&gt;
&lt;br /&gt;
[[Image:P3SpellerScreen.PNG|center|frame|A 6 by 6 speller matrix. Here, the user&#039;s task is to spell the word &amp;quot;SEND&amp;quot; (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]&lt;br /&gt;
&lt;br /&gt;
Assume that the data set is recorded from 8 channels at 256 Hz, the elapsed time from the start to the end of each intensification is 800 ms, and the decimation frequency provided by the investigator is 20 Hz.  For this example, &amp;lt;math&amp;gt; m = 12x15x4 = 720 &amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt; l = 8 &amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt; p = round(256 x 0.800) = 205 &amp;lt;/math&amp;gt;. The total number of columns (variables) of the above matrix is &amp;lt;math&amp;gt; 8 x 205 = 1640 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Get P300 Responses ==&lt;br /&gt;
&lt;br /&gt;
In this step, it is computed the corresponding time samples of a time [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Response Window&#039;&#039;&#039;]] &amp;lt;math&amp;gt; [t_{1}, t_{2}] &amp;lt;/math&amp;gt; in (ms) specified by the investigator.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{1} = round\left(\frac{t_{1}Fs}{1000}\right) = round\left(\frac{0*256}{1000}\right) = 0&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{2} = round\left(\frac{t_{2}Fs}{1000}\right) = round\left(\frac{800*256}{1000}\right) = 205&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals of interest are extracted from &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; and are defined&lt;br /&gt;
only for &amp;lt;math&amp;gt; n_{1}\le n &amp;lt; n_{2} &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The coefficients &amp;lt;math&amp;gt; b_{i} &amp;lt;/math&amp;gt; of the [http://en.wikipedia.org/wiki/Moving_average Moving Average (MA)] filter are found as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
b_{i} = \frac{1}{N+1}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; i = 0, 1, 2, \ldots, N &amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the filter order. The filter order can be computed from the sampling frequency &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt;  and the provided decimation frequency &amp;lt;math&amp;gt; Df &amp;lt;/math&amp;gt; as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; &lt;br /&gt;
N = \frac{Fs}{Df}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt; can be computed as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
h(n) = \frac{1}{N+1} \sum_{i=0}^{N-1} \delta(n-i).&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To filter the selected signals, each channel &amp;lt;math&amp;gt; k &amp;lt;/math&amp;gt; and each observation (stimulus) &amp;lt;math&amp;gt; i &amp;lt;/math&amp;gt; of the matrix &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; is convolved &amp;lt;math&amp;gt; (\star) &amp;lt;/math&amp;gt; with the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt;. The next equation shows how to filter a signal for channel &amp;lt;math&amp;gt; k = 1 &amp;lt;/math&amp;gt; and observation &amp;lt;math&amp;gt; i = 1 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
y_{1}^{1}(n) = x_{1}^{1}(n) \star h(n).&lt;br /&gt;
&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The output &amp;lt;math&amp;gt; y_{i}^{k}(n)&amp;lt;/math&amp;gt;, result of the convolution between all the extracted signals —for channels &amp;lt;math&amp;gt; k = 1, 2, \ldots, l &amp;lt;/math&amp;gt; and observations &amp;lt;math&amp;gt; i = 1, 2, \ldots, m &amp;lt;/math&amp;gt;— and the impulse response, is [http://en.wikipedia.org/wiki/Downsampling downsampled] by a factor &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA) ==&lt;br /&gt;
Consider a data vector &amp;lt;math&amp;gt; \mathbf {d} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; observations, a vector &amp;lt;math&amp;gt; \mathbf{w} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; n &amp;lt;/math&amp;gt; model parameters (weights) to estimate, and a matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt; representing the final linear model. This inverse problem can be written as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{G}\mathbf{w} = \mathbf{d}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An approximate solution to this problem can be found by minimizing the difference (residuals) between the actual data &amp;lt;math&amp;gt; \mathbf{d} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \mathbf{G}\mathbf{w} &amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{r} = \mathbf{d} - \mathbf{G}\mathbf{w}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The least squares or 2-norm solution has been adopted to minimize these residuals.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{w} = (\mathbf{G^{T}}\mathbf{G})^{-1}\mathbf{G^{T}}\mathbf{d}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The symbol &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; represents the transpose of the matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt;. Note that least squares solution is only valid for overdetermined systems (&amp;lt;math&amp;gt; m \le n &amp;lt;/math&amp;gt;); there must be in the model more observations than variables. If the residuals have a normal distribution, the least squares corresponds to the maximum likelihood criterion.&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5396</id>
		<title>UserReference:P300ClassifierMethods</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=UserReference:P300ClassifierMethods&amp;diff=5396"/>
		<updated>2009-09-12T20:25:28Z</updated>

		<summary type="html">&lt;p&gt;Cmpotes: /* Get P300 Responses */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Load BCI2000 Data Files ==&lt;br /&gt;
&lt;br /&gt;
Once the BCI2000 data files are check for compatibility, signals are extracted either from each training or testing data file and are arranged in a matrix form as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{\mathbf{X_{i}^{k}(n)}} =&lt;br /&gt;
\begin{bmatrix}&lt;br /&gt;
x_{1}^{1}(0) &amp;amp; x_{1}^{1}(1) &amp;amp; \cdots &amp;amp; x_{1}^{1}(p-1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(0) &amp;amp; x_{1}^{l}(1) &amp;amp; \cdots &amp;amp; x_{1}^{l}(p-1) \\&lt;br /&gt;
x_{2}^{1}(0) &amp;amp; x_{2}^{1}(1) &amp;amp; \cdots &amp;amp; x_{2}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{2}^{l}(0) &amp;amp; x_{2}^{l}(1) &amp;amp; \cdots &amp;amp; x_{2}^{l}(p-1) \\&lt;br /&gt;
\vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp;\vdots &amp;amp; \cdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \cdots &amp;amp; \vdots \\&lt;br /&gt;
x_{m}^{1}(0) &amp;amp; x_{m}^{1}(1) &amp;amp; \cdots &amp;amp; x_{m}^{1}(p-1) &amp;amp; \cdots &amp;amp;  x_{m}^{l}(0) &amp;amp; x_{m}^{l}(1) &amp;amp; \cdots &amp;amp; x_{m}^{l}(p-1) \\&lt;br /&gt;
\end{bmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; i = 1, 2, \ldots, m; &amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; k = 1, 2, \ldots, l; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; n = 0, 1, \ldots, p-1; &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
being &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; the total number of observations (stimuli), &amp;lt;math&amp;gt; l &amp;lt;/math&amp;gt; the total number of channels, and &amp;lt;math&amp;gt; p = t*Fs &amp;lt;/math&amp;gt; the total number of samples recorded for each channel. &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; is the recording stimulus time, and &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt; is the sampling frequency.&lt;br /&gt;
&lt;br /&gt;
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word &amp;quot;SEND&amp;quot;, a total of 4 characters.&lt;br /&gt;
&lt;br /&gt;
[[Image:P3SpellerScreen.PNG|center|frame|A 6 by 6 speller matrix. Here, the user&#039;s task is to spell the word &amp;quot;SEND&amp;quot; (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]&lt;br /&gt;
&lt;br /&gt;
The data set is recorded from 8 channels at 256 Hz, and the elapsed time from the start to the end of each intensification is 800 ms. For this example, &amp;lt;math&amp;gt; m = 12x15x4 = 720 &amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt; l = 8 &amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt; p = round(256 x 0.800) = 205 &amp;lt;/math&amp;gt;. The total number of columns (variables) of the above matrix is &amp;lt;math&amp;gt; 8 x 205 = 1640 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Get P300 Responses ==&lt;br /&gt;
&lt;br /&gt;
In this step, it is computed the corresponding time samples of a time [[User_Reference:P300_classifier#Parameters Pane|&#039;&#039;&#039;Response Window&#039;&#039;&#039;]] &amp;lt;math&amp;gt; [t_{1}, t_{2}] &amp;lt;/math&amp;gt; in (ms) specified by the investigator.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{1} = round\left(\frac{t_{1}Fs}{1000}\right) = round\left(\frac{0*256}{1000}\right) = 0&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{2} = round\left(\frac{t_{2}Fs}{1000}\right) = round\left(\frac{800*256}{1000}\right) = 205&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals of interest are extracted from &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; and are defined&lt;br /&gt;
only for &amp;lt;math&amp;gt; n_{1}\le n &amp;lt; n_{2} &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The coefficients &amp;lt;math&amp;gt; b_{i} &amp;lt;/math&amp;gt; of the [http://en.wikipedia.org/wiki/Moving_average Moving Average (MA)] filter are found as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
b_{i} = \frac{1}{N+1}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for &amp;lt;math&amp;gt; i = 0, 1, 2, \ldots, N &amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the filter order. The filter order can be computed from the sampling frequency &amp;lt;math&amp;gt; Fs &amp;lt;/math&amp;gt;  and the provided decimation frequency &amp;lt;math&amp;gt; Df &amp;lt;/math&amp;gt; as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; &lt;br /&gt;
N = \frac{Fs}{Df}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt; can be computed as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
h(n) = \frac{1}{N+1} \sum_{i=0}^{N-1} \delta(n-i).&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To filter the selected signals, each channel &amp;lt;math&amp;gt; k &amp;lt;/math&amp;gt; and each observation (stimulus) &amp;lt;math&amp;gt; i &amp;lt;/math&amp;gt; of the matrix &amp;lt;math&amp;gt; \mathbf{X_{i}^{k}(n)} &amp;lt;/math&amp;gt; is convolved &amp;lt;math&amp;gt; (\star) &amp;lt;/math&amp;gt; with the impulse response &amp;lt;math&amp;gt; h(n) &amp;lt;/math&amp;gt;. The next equation shows how to filter a signal for channel &amp;lt;math&amp;gt; k = 1 &amp;lt;/math&amp;gt; and observation &amp;lt;math&amp;gt; i = 1 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
y_{1}^{1}(n) = x_{1}^{1}(n) \star h(n).&lt;br /&gt;
&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The output &amp;lt;math&amp;gt; y_{i}^{k}(n)&amp;lt;/math&amp;gt;, result of the convolution between all the extracted signals —for channels &amp;lt;math&amp;gt; k = 1, 2, \ldots, l &amp;lt;/math&amp;gt; and observations &amp;lt;math&amp;gt; i = 1, 2, \ldots, m &amp;lt;/math&amp;gt;— and the impulse response, is [http://en.wikipedia.org/wiki/Downsampling downsampled] by a factor &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA) ==&lt;br /&gt;
Consider a data vector &amp;lt;math&amp;gt; \mathbf {d} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; m &amp;lt;/math&amp;gt; observations, a vector &amp;lt;math&amp;gt; \mathbf{w} &amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt; n &amp;lt;/math&amp;gt; model parameters (weights) to estimate, and a matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt; representing the final linear model. This inverse problem can be written as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{G}\mathbf{w} = \mathbf{d}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An approximate solution to this problem can be found by minimizing the difference (residuals) between the actual data &amp;lt;math&amp;gt; \mathbf{d} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \mathbf{G}\mathbf{w} &amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{r} = \mathbf{d} - \mathbf{G}\mathbf{w}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The least squares or 2-norm solution has been adopted to minimize these residuals.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{w} = (\mathbf{G^{T}}\mathbf{G})^{-1}\mathbf{G^{T}}\mathbf{d}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The symbol &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; represents the transpose of the matrix &amp;lt;math&amp;gt; \mathbf{G} &amp;lt;/math&amp;gt;. Note that least squares solution is only valid for overdetermined systems (&amp;lt;math&amp;gt; m \le n &amp;lt;/math&amp;gt;); there must be in the model more observations than variables. If the residuals have a normal distribution, the least squares corresponds to the maximum likelihood criterion.&lt;/div&gt;</summary>
		<author><name>Cmpotes</name></author>
	</entry>
</feed>