Difference between revisions of "Programming Reference:ComplexVisualizationDemo Signal Processing"

From BCI2000 Wiki
Jump to: navigation, search
(BCI2000 GraphDisplay vs. QPainter rendering)
Line 29: Line 29:
the main GUI thread.
the main GUI thread.
In the ''VisualizationDemo'' source code, <tt>QPainter</tt>-based rendering is available through a compiler switch.
In the ''ComplexVisualizationDemo'' source code, <tt>QPainter</tt>-based rendering is available through a compiler switch.

Revision as of 15:30, 8 February 2019




The ComplexVisualizationDemo signal processing module demonstrates how to send a large number of visualizations with arbitrary pixel content to the operator module. Two rendering methods are provided: Native Qt QPainter-based rendering, and BCI2000's own GraphDisplay based rendering.


The ComplexVisualizationDemoFilter signal processing filter derives from GenericFilter.


The ComplexVisualizationDemoFilter computes pairwise determination coefficients (squared correlation, r^2 values) between its input channels. Determination coefficients are visualized in form of pie charts, and pie charts are sent to the operator module as bitmap visualization data.

Operator visualization windows have no frames or title bars, and are arranged in form of a lower triangular matrix, with each window appearing at the place of its associated correlation matrix element: ComplexVisualizationDemo.PNG


Each visualization window is implemented as a VisualizationObject that contains a BitmapVisualization object, a WorkerThread object, and a Computation object. Whenever a new block of data arrives, computation is done for the individual window's pair of channels in the main thread. Then, visualization bitmap data are produced and sent to the operator module inside the worker thread, to avoid blocking the main thread. Inside the worker thread, the BitmapVisualization's SendDifferenceFrame() function is called to update the visualization display in the operator module.

BCI2000 GraphDisplay vs. QPainter rendering

The code presented here is using the BCI2000 GraphDisplay class.

GraphDisplay is a layer of abstraction that allows to render shapes and text objects into a normalized coordinate system. Code that uses GraphDisplay is most likely to survive breaking changes in the drawing backend (currently Qt) and BCI2000 dependencies.

In contrast, QPainter-based rendering provides access to more complex drawing functions but suffers from a limitation in Qt which makes text rendering impossible outside the main GUI thread.

In the ComplexVisualizationDemo source code, QPainter-based rendering is available through a compiler switch.



Native image width in pixels.


Native image height in pixels.


The images' background color, in hexadecimal notation.


A positive integer that indicates how often images are refreshed. 1 means every refresh on every signal packet.


The maximum number of visualization windows created, or 0 for any number of windows.

See also

Programming Reference:GraphDisplay Class, Programming Reference:GenericVisualization Class, Programming Reference:VisualizationDemo Signal Processing