|
| 1 | +PyNeuro |
| 2 | +======= |
| 3 | + |
| 4 | +PyNeuro is designed to connect NeuroSky's MindWave EEG device to Python |
| 5 | +and provide Callback functionality to provide data to your application |
| 6 | +in real time. The library is tested with Mindwave Mobie2 Headset, and |
| 7 | +runs stably. |
| 8 | + |
| 9 | +Installation |
| 10 | +------------ |
| 11 | + |
| 12 | +Run the following command: ``pip install PyNeuro`` |
| 13 | + |
| 14 | +Usage |
| 15 | +----- |
| 16 | + |
| 17 | +1. Importing the module: ``from NeuroPy import NeuroPy`` |
| 18 | +2. Initializing: ``pn = PyNeuro()`` |
| 19 | +3. After initializing, if required the callbacks can be set |
| 20 | +4. Then call ``pn.connect()`` method, it will connect with TCP Socket |
| 21 | + server. |
| 22 | +5. Then call ``pn.start()`` method, it will be start fetching data. |
| 23 | +6. To stop call ``pn.close()`` |
| 24 | + |
| 25 | +Obtaining Data from Device |
| 26 | +~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 27 | + |
| 28 | +- **Obtaining value:** ``attention = pn.attention`` #to get value of |
| 29 | + attention\_ >\ **Other Variable** attention, meditation, |
| 30 | + blinkStrength, will be added more soon. |
| 31 | + |
| 32 | +- **Setting callback:** A call back can be associated with all the |
| 33 | + above variables so that a function is called when the variable is |
| 34 | + updated. Syntax: |
| 35 | + |
| 36 | + :: |
| 37 | + |
| 38 | + pn.set_attention_callback(callback_function1) |
| 39 | + pn.set_meditation_callback(callback_function2) |
| 40 | + pn.set_blinkStrength_callback(callback_function3) |
| 41 | + |
| 42 | + You can add any number of callback functions to a variable.. |
| 43 | + |
| 44 | +Sample Program 1 (Access via callback) |
| 45 | +-------------------------------------- |
| 46 | + |
| 47 | +.. code:: python |
| 48 | +
|
| 49 | + from PyNeuro import PyNeuro |
| 50 | + from time import sleep |
| 51 | +
|
| 52 | + pn = PyNeuro() |
| 53 | +
|
| 54 | + def attention_callback(attention_value): |
| 55 | + """this function will be called everytime NeuroPy has a new value for attention""" |
| 56 | + print ("Value of attention is: ", attention_value) |
| 57 | + return None |
| 58 | +
|
| 59 | + pn.set_attention_callback("attention", attention_callback) |
| 60 | + pn.connect() |
| 61 | + pn.start() |
| 62 | +
|
| 63 | + try: |
| 64 | + while True: |
| 65 | + sleep(0.2) |
| 66 | + finally: |
| 67 | + neuropy.close() |
| 68 | +
|
| 69 | +Sample Program 2 (Access via object) |
| 70 | +------------------------------------ |
| 71 | + |
| 72 | +.. code:: python |
| 73 | +
|
| 74 | + from PyNeuro import PyNeuro |
| 75 | + from time import sleep |
| 76 | +
|
| 77 | + pn = PyNeuro() |
| 78 | + pn.start() |
| 79 | +
|
| 80 | + while True: |
| 81 | + if pn.meditation > 70: # Access data through object |
| 82 | + pn.close() |
| 83 | + sleep(0.2) |
| 84 | +
|
| 85 | +Python Compatibility |
| 86 | +-------------------- |
| 87 | + |
| 88 | +- `Python <http://www.python.com>`__ -v3.\* |
| 89 | + |
| 90 | +Reference |
| 91 | +~~~~~~~~~ |
| 92 | + |
| 93 | +`lihas/NeuroPy <https://github.com/lihas/NeuroPy>`__ - A library based |
| 94 | +on native Bluetooth serial connection |
0 commit comments