OpenBCI Consumer

class openbci_stream.acquisition.consumer.OpenBCIConsumer(mode: Optional[Literal['serial', 'wifi', None]] = None, endpoint: Optional[str] = None, daisy: Literal['auto', True, False] = 'auto', montage: Optional[Union[list, dict]] = None, streaming_package_size: Optional[int] = 250, host: Optional[str] = 'localhost', topics: Optional[List[str]] = ['eeg', 'aux', 'marker', 'annotation'], auto_start: Optional[bool] = True, *args, **kwargs)[source]

Kafka consumer for read data streamed. This class can start the acquisition if the respective parameter are specified. For just connect with an existing stream only needs the host, argument, the others one are used for start one.

Connect with an existing stream:

>>> whith OpenBCIConsumer() as stream:
        for message in stream:
            ...

Starts serial acquisition, create a stream and it connects with it:

>>> whith OpenBCIConsumer('serial', '/dev/ttyUSB0') as stream:
        for message in stream:
            ...

Connect with a remote existing stream:

>>> whith OpenBCIConsumer(host='192.168.1.113') as stream:
        for message in stream:
            ...

For examples and descriptions refers to documentation: Controlled execution with OpenBCIConsumer()

Parameters
  • mode – If specified, will try to start streaming with this connection mode.

  • endpoint – Serial port for RFduino or IP address for WiFi module.

  • daisy – Daisy board can be detected on runtime or declare it specifically.

  • montage – A list means consecutive channels e.g. [‘Fp1’, ‘Fp2’, ‘F3’, ‘Fz’, ‘F4’] and a dictionary means specific channels {1: ‘Fp1’, 2: ‘Fp2’, 3: ‘F3’, 4: ‘Fz’, 5: ‘F4’}.

  • streaming_package_size – The streamer will try to send packages of this size, this is NOT the sampling rate for data acquisition.

  • host – IP address for the server that has the OpenBCI board attached, by default its assume that is the same machine where is it executing, this is the localhost.

  • topics – List of topics to listen.

  • auto_start – If mode and endpoint are passed, then start the stream automatically.

__enter__() Tuple[kafka.KafkaConsumer, Optional[openbci_stream.acquisition.cyton.Cyton]][source]

Start stream and create consumer.

__exit__(exc_type: str, exc_val: str, exc_tb: str) None[source]

Stop stream and close consumer.