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

From BCI2000 Wiki
Jump to: navigation, search
(Initialize() method)
Line 54: Line 54:
   p->mBackground = RGBColor(Parameter("VisImageBackground"));
   p->mBackground = RGBColor(Parameter("VisImageBackground"));
   p->mDecimation = Parameter("VisImageDecimation");
   p->mDecimation = Parameter("VisImageDecimation");
  // Set the image's width and height.
   GUI::DrawContext c = { 0 };
   GUI::DrawContext c = { 0 };
   c.rect.right = p->mWidth;
   c.rect.right = p->mWidth;

Revision as of 16:57, 7 February 2019




The VisualizationDemo signal processing module demonstrates how to send 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 VisualizationDemoFilter signal processing filter derives from GenericFilter.


The VisualizationDemoFilter computes the determination coefficient (squared correlation, r^2 values) between its first and second input channel. The determination coefficient is visualized in form of a pie chart, and the pie chart is sent to the operator module as bitmap visualization data.

For various values of the r^2 value, the operator visualization window appears as follows:


A BitmapVisualization object is used to send visualization window configuration, and bitmap data to the operator module. In the filter's Initialize() method, the bitmap visualization object's SendReferenceFrame() method is called to set an anchor for further visualization data. In the filter's Process() method, rendered visualization data is sent to the operator module using the bitmap visualization object's SendDifferenceFrame method as an update to existing image data.

Declaration of internal variables

struct VisualizationDemoFilter::Private
  double computeCorrelation(const GenericSignal&, int idx1, int idx2);

  RGBColor mBackground;
  int mHeight, mWidth, mDecimation;
  int mDecimationCounter;

  // Object used to send visualization data to the operator
  BitmapVisualization mVis;

  // Object that holds image contents
  GUI::GraphDisplay mImage;
  // Objects that populate the image
  PieShape* mpShape;
  TextField* mpValueField;

Initialize() method

void VisualizationDemoFilter::Initialize(
  const SignalProperties& Input,
  const SignalProperties& Output)
  // Initialize properties from parameters.
  p->mWidth = Parameter("VisImageWidth");
  p->mHeight = Parameter("VisImageHeight");
  p->mBackground = RGBColor(Parameter("VisImageBackground"));
  p->mDecimation = Parameter("VisImageDecimation");
  // Set the image's width and height.
  GUI::DrawContext c = { 0 };
  c.rect.right = p->mWidth;
  c.rect.bottom = p->mHeight;

  // Set visualization window properties.
  p->mVis.Send(CfgID::Left, 50);
  p->mVis.Send(CfgID::Top, 50);
  p->mVis.Send(CfgID::Width, p->mWidth);
  p->mVis.Send(CfgID::Height, p->mHeight);
  p->mVis.Send(CfgID::WindowTitle, "Visualization Demo");
  // Setting WindowFrame to false will hide title bar and window frame.
  p->mVis.Send(CfgID::WindowFrame, true);
  p->mVis.Send(CfgID::Visible, true);

  // Send an initial reference frame.
  // Render the image.
  // Send the image's bitmap data to the operator as a reference frame.



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.

See also

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