PyBCI

class PyBCI(dataStreams=None, markerStream=None, streamTypes=None, markerTypes=None, loggingLevel=Logger.INFO, globalEpochSettings=Global EpochSettings(), custom EpochSettings={}, streamChsDropDict={}, streamCustomFeatureExtract={}, minimum EpochsRequired=10, createPseudoDevice=False, pseudoDeviceArgs=None, clf=None, model=None, torchModel=None)

The PyBCI object is the main controller for interfacing with all relevant threads. When initialised, it sets up the main operation of the BCI and can be queried for relevant information.

Parameters:
  • dataStreams – list(str) or None: Allows the user to set custom acceptable EEG stream definitions. Defaults to streamTypes scan if None.

  • markerStream – str or None: Allows the user to set custom acceptable Marker stream definition. Defaults to markerTypes scan if None.

  • streamTypes – list(str) or None: Allows the user to set custom acceptable EEG type definitions, ignored if dataStreams is not None.

  • markerTypes – list(str) or None: Allows the user to set custom acceptable Marker type definitions, ignored if markerStream is not None.

  • loggingLevel – string: Sets PyBCI print level. Options are ‘INFO’, ‘WARNING’, ‘TIMING’, and ‘NONE’.

  • EpochSettings (custom) – Global EpochSettings: Sets global timing settings for epochs.

  • EpochSettings – dict: Sets individual timing settings for epochs.

  • streamChsDropDict – dict: Specifies which channels to drop for each data stream.

  • streamCustomFeatureExtract – dict: Allows a custom feature extractor class for each data stream.

  • EpochsRequired (minimum) – int: Minimum number of required epochs before model fitting begins.

  • createPseudoDevice – bool: If True, auto-generates LSL marker and LSL data.

  • pseudoDeviceArgs – dict: Dictionary of arguments to initialize pseudo device.

  • clf – sklearn.base.ClassifierMixin or None: Allows custom Sklearn model to be passed.

  • model – tf.keras.model or None: Allows custom TensorFlow model to be passed.

  • torchModel – custom def or None: Custom torch function should be passed with 4 inputs.

Note

For more information on epoch settings, see Global EpochSettings() and Individual EpochSettings().

__enter__()

Connects to the BCI. Same as __init__.

__exit__(exc_type, exc_val, exc_tb)

Stops all threads of the BCI.

Connect()

Checks for valid data and marker streams, sets self.connected. Returns boolean indicating connection status.

TrainMode()

Sets mode to Train. Tries to connect if not already connected.

TestMode()

Sets mode to Test. Tries to connect if not already connected.

CurrentClassifierInfo()
Returns:

Dictionary containing “clf”, “model,” “torchModel,” and “accuracy.” If not connected, returns {“Not Connected”: None}.

CurrentClassifierMarkerGuess()
Returns:

Integer or None. Returns integer corresponding to value of key from ReceivedMarkerCount() dictionary. Returns None if in Train mode.

CurrentFeaturesTargets()
Returns:

Dictionary containing “features” and “targets.” If not connected, returns {“Not Connected”: None}.

ReceivedMarkerCount()
Returns:

Dictionary where each key is a received marker string and the value is a list. The list contains the marker ID and received count for that marker type.