openbci-archive / OpenBCI_Python

The Python software library designed to work with OpenBCI hardware.
MIT License
506 stars 207 forks source link

Implement Analog data parsing in Python SDK #109

Open daniellasry opened 5 years ago

daniellasry commented 5 years ago

This was brought up in issue: OpenBCI/OpenBCI_WIFI#86 When switching to analog mode, no data is streaming from the Cyton. Example code:

from openbci import wifi as bci
shield = bci.OpenBCIWiFi(ip_address = '192.168.1.141', log=True, high_speed=True)
shield.wifi_write('/2')

def printData(sample):
    print(sample.sample_number)
    print(sample.channel_data)

shield.start_streaming(printData)
shield.loop()

This will print a whole bunch of zeroes.

This is because there is no analog data parsing in the Python SDK. See the empty function here: https://github.com/OpenBCI/OpenBCI_Python/blob/069bbcb9167261d687ec37206d1d2f59ace137d8/openbci/utils/parse.py#L140-L141

The implementation should be similar to the one in the NodeJS code. See here, and here

wjcroft commented 5 years ago

Daniel, thanks for looking into this. Mentioning @omarclaflin .

andrewjaykeller commented 5 years ago

The API for this should look something like

from openbci import wifi as bci
# for analog
shield = bci.OpenBCIWiFi(ip_address = '192.168.1.141', log=True, high_speed=True, aux_mode='analog')

# for digital
shield = bci.OpenBCIWiFi(ip_address = '192.168.1.141', log=True, high_speed=True, aux_mode='digital')

def printData(sample):
    print(sample.sample_number)
    print(sample.channel_data)
    print(sample.analog_data)

shield.start_streaming(printData)
shield.loop()
daniellasry commented 5 years ago

hey @omarclaflin, it's not implemented yet, but it will be by next week. I'll keep you posted.

daniellasry commented 5 years ago

hey @omarclaflin , thanks for testing it out. hang tight, the code is still a work in progress!