Jump to content

Technical Reference:Core Modules: Difference between revisions

From BCI2000 Wiki
Mellinger (talk | contribs)
Mellinger (talk | contribs)
 
(5 intermediate revisions by the same user not shown)
Line 15: Line 15:
.dat
.dat
format, together with the raw digitized data.
format, together with the raw digitized data.
===Data Acquisition and Storage Loop===
During normal operation (''Running''  is 1), the Signal Source module
During normal operation (''Running''  is 1), the Signal Source module
runs in a data acquisition loop that basically reads
runs a data acquisition and storage loop that has the following structure:
<pre>
<pre>
1: While Running
1: While Running
Line 25: Line 27:
6:  Save A/D data to file
6:  Save A/D data to file
</pre>
</pre>
Note that statement 3 as well as statement 5 are blocking operations,
 
i.e.,
===Real-Time Constraint===
the module will wait for A/D data as well as for the state vector data
Note that statement 3 as well as statement 5 are blocking operations, i.e., the module will wait for A/D data as well as for the state vector data
coming in from the Application module.
coming in from the Application module.
This mode of operation requires a sufficiently fast system to work
This mode of operation imposes a real-time constraint on signal processing, and therefore requires a "sufficiently fast" system to work properly.
properly.
For our purposes, a "sufficiently fast" system is a system where
For our purposes, a "fast" system is a system where
    
    
*synchronous I/O operations (2, 4, 5, and 6) require an execution time that is small compared to the duration of a data block (as given by the sampling rate and the sample block size), and  
*synchronous I/O operations (2, 4, 5, and 6) require an execution time that is small compared to the duration of a data block (as given by the sampling rate and the sample block size), and  
Line 44: Line 45:
statements will reduce the waiting interval occurring in statement 3.
statements will reduce the waiting interval occurring in statement 3.


''Note:'' For the data in the file, the state vector which results from processing a data block <math>n</math> is saved together with the following block, <math>n+1</math>. For the first block, a state vector is saved that contains initial values.
===State Vector Storage===
For the data in the file, the state vector which results from processing a data block <math>n</math> is saved together with the following block, <math>n+1</math>. For the first block, a state vector is saved that contains initial values.
Note that the ''SourceTime'' state is an exception insofar as it matches the acquisition time of the current block.
As a result, the ''StimulusTime'' state (and similar states) will always have a smaller value than the ''SourceTime'' state, and needs to be referenced to the ''SourceTime'' state of the previous block in order to obtain processing delay.


==Signal Processing Module==
==Signal Processing Module==
===Overview===
Signal Processing acts like a black box to the rest of the system - it receives brain signals from the Signal Source and sends control signals on to the Application.  
Signal Processing acts like a black box to the rest of the system - it receives EEG signals from the Data Acquisition and sends control signals on to the Application.  


The data flow in a typical implementation is as follows:
The data flow in a typical implementation is as follows:
Line 60: Line 63:
For each input block of data, there must be a resulting output block.
For each input block of data, there must be a resulting output block.


===Goals===
==Module Independence==
One of the goals for BCI2000 is for each module to be as independent of the others as possible.  
One of the goals for BCI2000 is for each module to be as independent of the others as possible.  
For example, Signal Processing should not have to take the type of data collection
For example, Signal Processing should not have to take the type of data collection
Line 69: Line 72:
Application can be minimized.
Application can be minimized.


===Assumptions and Dependencies===
==Assumptions and Dependencies==
Signal Processing can contain instances of multiple filter classes.
BCI2000 core modules can contain instances of multiple filter classes.
These filter
These filter classes cannot assume any specific values for system-wide parameters such as
classes cannot assume any specific values for
''SampleBlockSize'',
''SampleBlockSize'',
''SamplingRate'', or ''TransmitCh''. They have to be able to
''SamplingRate'', or ''TransmitCh''. Rather, they have to be able to
adapt their functionality according to these three parameters -- they might
adapt their functionality according to these three parameters -- they might
not only be used in scenarios with varying parameters, but they might also have
not only be used in scenarios with varying parameters, but they might also have
to work together with other filters. Therefore, hard coded assumptions about
to work together with other filters. Therefore, hard coded assumptions about
these three parameters have to be avoided.
system-wide parameters have to be avoided.


==Application Module==
==Application Module==
Line 89: Line 91:
completely encapsulate each module and separate it from others.
completely encapsulate each module and separate it from others.
In order to minimize inter-dependence, duties should be performed by the module that is conceptually defining the feature. For example, task paradigm and timing are, conceptually, parts of a task and should therefore be handled by the user application module.
In order to minimize inter-dependence, duties should be performed by the module that is conceptually defining the feature. For example, task paradigm and timing are, conceptually, parts of a task and should therefore be handled by the user application module.
[[User Reference:CursorTask]] an implementation of a such a user task - a simple cursor task - that complies with the idea of minimal inter-dependence.
[[User Reference:CursorTask]] is an implementation of a such a user task - a simple cursor task - that complies with the idea of minimal inter-dependence.


==See also==
==See also==

Latest revision as of 12:48, 4 March 2022

Of the four BCI2000 modules, three make up the Core Modules: Data Acquisition, Signal Processing, and User Application. Between core modules, data flow in a closed loop, clocked by data acquisition hardware.

Signal Source Module

The role of the Signal Source module is to wait for data blocks coming in from the A/D hardware, and to send these blocks of data on to Signal Processing, thus acting as the on-line system's "metronome" synchronized to the A/D hardware clock. At the same time, it receives state vector information from the Application module, and saves this state vector information to a file in BCI2000 .dat format, together with the raw digitized data.

Data Acquisition and Storage Loop

During normal operation (Running is 1), the Signal Source module runs a data acquisition and storage loop that has the following structure:

1: While Running
2:   Save state vector to file
3:   Wait for A/D data
4:   Send A/D data to Signal Processing
5:   Wait for state vector from Application
6:   Save A/D data to file

Real-Time Constraint

Note that statement 3 as well as statement 5 are blocking operations, i.e., the module will wait for A/D data as well as for the state vector data coming in from the Application module. This mode of operation imposes a real-time constraint on signal processing, and therefore requires a "sufficiently fast" system to work properly. For our purposes, a "sufficiently fast" system is a system where

  • synchronous I/O operations (2, 4, 5, and 6) require an execution time that is small compared to the duration of a data block (as given by the sampling rate and the sample block size), and
  • the time required by the Signal Processing and Application modules for processing the data sent out in statement 4 is small compared to the duration of a data block.

In an on-line system, the time between sampling of a data block, and display of the resulting feedback information to the subject, is critical. Given a "sufficiently fast" system as defined above, only statement 4 will enter into this critical time path, while the time spent on execution of the remaining statements will reduce the waiting interval occurring in statement 3.

State Vector Storage

For the data in the file, the state vector which results from processing a data block n is saved together with the following block, n+1. For the first block, a state vector is saved that contains initial values. Note that the SourceTime state is an exception insofar as it matches the acquisition time of the current block. As a result, the StimulusTime state (and similar states) will always have a smaller value than the SourceTime state, and needs to be referenced to the SourceTime state of the previous block in order to obtain processing delay.

Signal Processing Module

Signal Processing acts like a black box to the rest of the system - it receives brain signals from the Signal Source and sends control signals on to the Application.

The data flow in a typical implementation is as follows:

selected channels from data acquisition -> [Spatial Filter] -> spatially filtered signal
-> [Temporal Filter] -> temporally filtered signal -> [Classifier] -> control signal
-> [Normalizer] -> normalized control signal to go to application

There are basically 4 main filters (Spatial Filter, Temporal Filter, Classifier, and Normalizer) connected in form of a pipe: Each filter's output is the input to the next filter, and all filters act on each input block of data in sequence. For each input block of data, there must be a resulting output block.

Module Independence

One of the goals for BCI2000 is for each module to be as independent of the others as possible. For example, Signal Processing should not have to take the type of data collection hardware into account. For the same reason, Application should (ideally) not have to know about the signal processing method used. While in real-world situations this will not be possible, control signals shall be zero mean (to the extent that this is possible), shall be normalized to unit gain, and each value shall be equally accessible by the user's brain signals. In this fashion, the interdependence between Signal Processing and Application can be minimized.

Assumptions and Dependencies

BCI2000 core modules can contain instances of multiple filter classes. These filter classes cannot assume any specific values for system-wide parameters such as SampleBlockSize, SamplingRate, or TransmitCh. Rather, they have to be able to adapt their functionality according to these three parameters -- they might not only be used in scenarios with varying parameters, but they might also have to work together with other filters. Therefore, hard coded assumptions about system-wide parameters have to be avoided.

Application Module

One major goal for BCI2000 system design is the independence between modules. In most BCI systems, however, some parts of the applied signal processing module (i.e., the device-dependent part of signal processing) depend on the feedback to the user - a feature provided by the user application module. This inter-dependence between the signal processing and the user application modules poses severe problems to the system design, because it is not possible to completely encapsulate each module and separate it from others. In order to minimize inter-dependence, duties should be performed by the module that is conceptually defining the feature. For example, task paradigm and timing are, conceptually, parts of a task and should therefore be handled by the user application module. User Reference:CursorTask is an implementation of a such a user task - a simple cursor task - that complies with the idea of minimal inter-dependence.

See also

Technical Reference:System Design, User Reference:Timing