The BCI source in C++

The BCI module uses many functions that are actually written in C++ and implemented using a module called bci_source, generated with SWIG. In this chapter these functions are documented. If you are interested to develop the C++ part of the BCI, feel free to download the source code. The complete source code is explained in-code, with its documentation here.

void start_bci(int argc, char** argv, unsigned int modus, unsigned int channum, signed int level)

Function to start the BCI. Has to be called in an seperate thread.

Parameters:
  • argv – Name of the server (if the software is not running on the same computer that is receiving the data; otherwise skip)
  • mode – Sign mode. 0 or SIGNS_UNAVAILABLE if no signs are to be shown and 1 or SIGNS_AVAILABLE if you want to trigger signs.
  • channum – Number of channels to evaluate. Channel labels are by default from 1 to channum-1, eog channel is channum. Use change_channellabels to change that.
  • level – Speed levels from -9 (very slow) to 9 (very fast) are possible, with possible exceptions of level -10 (slowest level that is possible) and 10 (as fast as possible). The speed is set on a pretty fast value (8) by default.
void end_bci(void)
Function to be called to end bci, close the server connection and delete allocated memory.
unsigned int get_blocksize(void)
May be used to check the number of samples in one data block, that is sent (to the server).
unsigned long get_numof_samples(void)
May be used to check the number of samples in one data array, storing the data.
void set_security_mode(bool mode)

Sets the security mode.

Parameter:mode (true or false(default)) – A warning is raised if the number of returned blocks is not equal to the received ones. That may be useful if you want to be sure not to miss samples/data blocks or to avoid reading blocks twice.
void reset_security_mode(void)
Resets the counters for read and returned data arrays.

This may be useful if you do not want to have all the data be returned since the Recorder is running and still be sure not to miss data while requesting it.

void set_returning_speed(signed int level)

Resets the returning speed of data arrays.

Parameter:level – Speed levels from -9 (very slow) to 9 (very fast) are possible, with possible exceptions of level -10 (slowest level that is possible) and 10 (as fast as possible). The speed is set on a pretty fast value by default.
char check_readingstate(void)

May be used to check if the Recorder is running (just in that case data may be available to be returned) externally.

Rytpe:1 (running), otherwise 0
int demanding_access(void)

Returns with 1 if data is available for returning and with 2 to ‘sign’ a stopped Recorder.

Note

Attention: This function has to be called before collecting data by return_samples. Otherwise you cannot be sure if a data array is filled ans therewith ready to be returned. When this function has returned you should call exactly every sample in one data array, that is, calling return_samples up to the number of samples in one data array as first argument.

short return_samples(unsigned long n, unsigned int channel, bool lastone)

Function to be called to get available data. Returns sample n from channel channel (range from 1 to numof_channels is possible).

Note

Attention: Call demanding_access first to make sure that there is data available for returning. The maximum value of n is numof_samples (consider calling get_numof_samples if unsure...).

Note

To ensure a working security mode, you have to collect at least the last sample point (this is numof_samples) of any channel and set lastone to True when you access the current data array for the last time.

void give_sign(int form, int col, unsigned long time, double size, unsigned int texture)

Triggers a sign on a white background for the time time (milliseconds) in the shape form when mode is **signs_enabled’*. When the sign is shown a trigger (‘5’) is sent via the parallel port.

param time:Time to show the sign in milliseconds
param form:1 or TRIANGLES for triangles, 2 or QUADS for quads, 3 or FONT for text and 4 or BMP for bitmaps
param col:color (0 for black, 1 for white, 2 for grey)
param size:size of the sign
type size:from 0 to 1
param texture:0 (‘R’), 1(‘L’), 2(‘r’), 3 (‘l’) or 4 (grey background)
void set_trigger_size(double size)
Sets the size of the trigger, with the size in the range from 1 to 10, when mode is **signs_enabled_c’*. .

Previous topic

Frequency Ticker

Next topic

The complete C++ BCI code

This Page