Jump to content

Contributions:CommunicationTask

From BCI2000 Wiki
Revision as of 16:03, 12 July 2023 by Lingling (talk | contribs) (Example)

Synopsis

The hyperScanning task is a turn-based communication game that is played between two clients. The two clients exchange information through the hyperScanning backend which uses a client-server model to share the states. Each client has a separate state machine, the server only forwards the information between two clients. Shared states are converted to BCI2000 states asynchronously through events using the HyperscanningApplicationBase class which is the parent class of the application module. For more information, please refer to the hyperScanning back end wiki page: https://www.bci2000.org/mediawiki/index.php/BCI2000_Hyperscanning.

Timeline

Visual Representation

Versioning

Authors

Huiling Huang (huiling@neurotechcenter.org) Max Marcus (bigmaxmarcus@gmail.com)

Parameters

There are two kinds of parameters: shared and local. The shared parameter is the one you want to synchronize between two clients, like the stimulus sequence, the value of slider, etc. It should be saved on the server and downloaded by the clients. The local parameter is the one you want to locally customize your GUI, like the screen size, the color of the text, etc. The local parameter is the normal BCI2000 parameter file that is saved under the local BCI2000 project folder.

StimuliMatrix

Matrix of images path, options, dimensions, duration of jitter, etc.

StimuliWidth

StimulusWidth in percent of screen width (zero for original pixel size).

InstructionImagesSeque

The sequence of instruction images path.

InstructionWidth

Instruction width in percent of screen width (zero for original pixel size).

BreakTrialSequece

The sequence of break trials, a break will happen after the break trial.

FeedbackDuration

Duration of feedback(ITI).

SliderWidth

SliderWidth in percent of screen width (zero for original pixel size).

BarColor

Color of the slider bar.

AxeActiveColor

Color of active slider axe.

AxeInActiveColor

Color of inactive slider axe.

DimensionFontColor

Color of the text under the slider.

DimensionHeight

Height of text in percent of the screen height.

OptionFontActiveColor

Color of the active options.

OptionFontInActiveColor

Color of the inactive options.

OptionHeight

Height of text in percent of the screen height.

RoleFontColor

Color of the role text.

RoleHeight

Height of text in percent of the screen height.

FeedbackWidth

Width of feedback in percent of screen width.

PhotoDiodePatch

Display a photodiode patch on the stimulus window. Recording from a photodiode located on that patch will allow triggering on actual stimulus delivery (see User_Reference: P3TemporalFilter#OnsetExpression).

PhotoDiodePatchHeight, PhotoDiodePatchWidth

Photodiode patch height/width in relative coordinates (between 0 and 1).

PhotoDiodePatchLeft, PhotoDiodePatchTop

Photodiode patch left/top position in relative coordinates (between 0 and 1).

PhotoDiodePatchShape

Photodiode patch shape: 0 rectangle, 1 ellipse.

PhotoDiodePatchActiveColor

Photodiode patch color when active (RGB color in format 0xrrggbb).

PhotoDiodePatchInactiveColor

Photodiode patch color when inactive, (RGB color in format 0xrrggbb, use 0xff000000 for transparent).

States

Shared states are converted to BCI2000 states asynchronously through events using the HyperscanningApplicationBase class. We declared shared states in the batch file as "--SharedStates=state1_name,state1_size&state2_name,state2_size&...", which is appended to the end of the application module.

PhaseNumber

The index of phase in each trial. (8 bits) 0: instruction; 1: wait_to_begin; 2: role_text; 3: image_present; 4: feedback; 5: break; 6: end.

TrialNumber

Index of trials. (8 bits)

BarOneValue

Value of slider#1. (32 bits)

BarTwoValue

Value of slider#2. (32 bits)

BarOneActive, BarTwoActive

0: slider is not selected. 1: slider is selected. (8 bits)

ResponseValue

1: object. 2: animal. (8 bits)

SenderLock, ReceiverLock

0: client has locked the answer. 1: client is moving the slider/making choose. (8 bits)

isReadyStart0, isReadyStart1

0: client isn't ready to start/resume/continue the game. 1: client is ready to start/resume/continue the game. (8 bits)

ClientNumber

Client index, either 0 or 1. (8 bits)


Example

The hyperscanning application module is almost the same as a BCI2000 application module, except that the typical BCI2000 module is inherited from ApplicationBase, and the hyperscanning application module is inherited from HyperscanningApplicationBase. Basically, the HyperscanningApplicationBase class is the same as ApplicationBase class with adding the communication with the server. So instead of using Publish, Preflight, Process, etc. We are using SharedPublish, SharedPreflight, SharedProcess, etc. These methods behave in the exact same way, except they also call the client loops which interact with the server.


Communication_task_dualTask.cpp:

#include "ApplicationBase.h"
#include "Slider.h"
#include <map>
#include <vector>
#include <string>
#include "TextStimulus.h"
#include "ImageStimulus.h"
#include "Shapes.h"
#include "HyperscanningApplicationBase.h"

class Communication_task_dualTask : public HyperscanningApplicationBase
{
 public:
  Communication_task_dualTask();
  ~Communication_task_dualTask();
  void SharedPublish() override;
  void SharedPreflight( const SignalProperties& Input, SignalProperties& Output ) const override;
  void SharedInitialize( const SignalProperties& Input, const SignalProperties& Output ) override;
  void SharedAutoConfig( const SignalProperties& Input ) override;
  void SharedStartRun() override;
  void SharedProcess( const GenericSignal& Input, GenericSignal& Output ) override;
  void SharedStopRun() override;
  void SharedHalt() override;

 private:
   //define your own private members here
   ApplicationWindow& mrDisplay;

   //define your own private methods here

};