Programming Reference:ApplicationBase Class
Location
BCI2000/src/shared/modules/application
Synopsis
The ApplicationBase class bundles base functionality which is useful for any BCI2000 application module. This base functionality comprises
- generation of random numbers,
- maintaining an application log file, and application log messages to the operator user,
- parameterization of application screen position and dimensions,
- display of a small copy of the application screen in an operator visualization window.
Usage
An application module uses the ApplicationBase class by deriving its task filter from ApplicationBase rather than GenericFilter directly. It has then access to the facilities explained below.
RandomNumberGenerator
The ApplicationBase class provides an object of type RandomGenerator which may be used to obtain integer pseudo-random numbers uniformly distributed over a specified range:
int rnd = RandomNumberGenerator(10);
will assign a number between 0 and 9 to the variable named "rnd". Compared with other options to obtain pseudo-random numbers, the advantage of using ApplicationBase::RandomNumberGenerator object is that its behavior is governed by a global random seed value; this allows consistent, predictable BCI2000 behavior, e.g. for testing purposes. For more information, refer to the RandomGenerator reference page.
Application Log
Typically, a BCI2000 application module displays messages to the operator user to indicate that a new trial has started, a target has been hit or missed, or to display statistics about the current run. Often, this is information, in conjunction with additional, more detailed information is written into a log file, and that log file is maintained side-by-side with recorded data in the current session directory.
The ApplicationBase class provides an object named AppLog as a convenient interface to write messages to screen, log file, or both at the same time. That AppLog object uses a LogFile object to write into a log file; it uses a GenericVisualization object to write messages into an operator window.
The AppLog object is a <std::ostream>, and may be used as in the following examples:
// Write a message to the log file only AppLog.File << "This message goes into the log file." << endl;
// Write a message to the screen only AppLog.Screen << "This message goes into an operator window." << endl;
// Write a message to both screen and file: AppLog << "This message is displayed by the operator module, and written into the log file." << endl;
The application log file is located in the current session directory, and named after the current session; it carries an .applog extension.
Operator log window messages have APLG as their visualization source ID.
Display Parameterization and Visualization
Typically, a BCI2000 application module displays feedback or other stimuli in an application window. In the GUI abstraction layer of the BCI2000 framework, the application window's drawing area is represented as an object that inherits the GUI::GraphDisplay interface.
When a derived class provides its underlying ApplicationBase with a GUI::GraphDisplay pointer at construction time, the ApplicationBase class will handle display visualization transparently. The ApplicationBase class uses the GraphDisplay's BitmapData method to obtain a copy of its contents, and to send these to the operator module for display in a visualization window using a message source ID of APSC.
Parameters
Application Window Properties
Template:ApplicationBaseParams
Application Window Visualization
Visualization parameters are available only if the descendant class provides a GUI::GraphDisplay pointer at construction time.
VisualizeApplicationWindow
Switches visualization display of a miniature copy of the application window on or off.
AppWindowSpatialDecimation
A factor that determines resolution of visualized data in relation to the original window's size. Enlarging the factor reduces the visualization window's resolution, and its initial size, and improves system timing by reducing the amount of data transferred.
AppWindowTemporalDecimation
A factor that determines the visualization window's update rate. A value of n results in each nth sample being transferred.
Remarks
Typically, a BCI2000 application module will implement a paradigm that belongs to one of two categories:
- evoking responses using stimulus presentation,
- continuously presenting feedback of brain activity.
A BCI2000 task filter implementing one of these paradigms will not inherit from the ApplicationBase directly but either from the StimulusTask or FeedbackTask. Still, such a task filter has access to all functionality provided by ApplicationBase.
See also
Programming Reference:StimulusTask Class, Programming Reference:FeedbackTask Class