Introduction

A python module called bitalino-lsl to stream BITalino data though the Lab Streaming Layer (LSL). This module gets data from the BITalino device through the bitalino python api and uses the Lab Stream Layer to stream the data.

The module should work with python versions >= 2.7 although it has only been tested for:

  • Python 2.7.15
  • Python 3.6.5

Getting started

You can install the module with pip:

$ pip install bitalino_lsl

This examples streams BITalino data through the LSL and reads it from the stream for 5 seconds:

import bitalino_lsl
from pylsl import StreamInlet, resolve_stream
import time

# MAC address of the BITalino device
MAC_ADDRESS_BITALINO_DEVICE = "20:17:11:20:51:60"

# List with channels of the BITalino device to be streamed to the LSL
# This channels can be specified as a list or as a dictionary with their
# position in the 10-20 system. BITalino uses bipolar electrodes so the
# position will be defined by two points
# CHANNELS = {0: 'Fp1-Fp2', 1: 'P3-T5'}
CHANNELS = [0,1]

# Connect with the BITalino device
device = bitalino_lsl.BitalinoLSL(MAC_ADDRESS_BITALINO_DEVICE)

# Create the Stream with the channels information
device.create_lsl_EEG(CHANNELS)

# Start the stream getting data from the BITalino device
device.start()

# Get the Stream to read the data from
inlet = StreamInlet(resolve_stream('type', 'EEG')[0])

# Read the BITalino data for 5 seconds
t_end = time.time() + 5
while time.time() < t_end:
  sample, timestamp = inlet.pull_sample()
  print(sample)

# Stop the device
device.stop()

# Close the connection with the BITalino device
device.close()