Difference between revisions of "DataHub"
Wiki-admin (talk | contribs) (→Python) |
Wiki-admin (talk | contribs) (→Python) |
||
| Line 54: | Line 54: | ||
==Usage== | ==Usage== | ||
=== Python === | === Python === | ||
| + | A short example for sending lsl streaming data: | ||
| + | <syntaxhighlight lang="python" line> | ||
| + | #!/usr/bin/env python | ||
| + | |||
| + | import threading | ||
| + | from pylsl import StreamInfo, StreamOutlet | ||
| + | |||
| + | def getData(): | ||
| + | while running: | ||
| + | buffer_in = getSensorData() | ||
| + | send_data = True | ||
| + | time.sleep(0.001) | ||
| + | |||
| + | info = StreamInfo( | ||
| + | name='MyStream', | ||
| + | type='COP', | ||
| + | channel_count=4, | ||
| + | nominal_srate = 200, | ||
| + | source_id='BalanceBoard_stream' | ||
| + | ) | ||
| + | outlet = StreamOutlet(info) | ||
| + | |||
| + | threading.Thread(target=getData).start() | ||
| + | while running == True: | ||
| + | if send_data: | ||
| + | outlet.push_chunk(buffer_in) | ||
| + | send_data = False | ||
| + | </syntaxhighlight> | ||
| + | |||
A short example for sending lsl streaming data: | A short example for sending lsl streaming data: | ||
<syntaxhighlight lang="python" line> | <syntaxhighlight lang="python" line> | ||
Revision as of 10:14, 1 February 2022
| Developer(s) | Christian Kothe; Chadwick Boulay. | ||||
|---|---|---|---|---|---|
| Development status | -in development- | ||||
| Written in | C, C++, Python, Java, C#, MATLAB | ||||
| Operating system | Windows, Linux, MacOS, Android, iOS | ||||
| Type | Data collection | ||||
| License | Open source | ||||
| Website | LSL webpage | ||||
| |||||
The DataHub Makes use of the lab streaming layer. The lab streaming layer (LSL) is a system for the unified collection of measurement time series in research experiments that handles both the networking, time-synchronization, (near-) real-time access as well as optionally the centralized collection, viewing and disk recording of the data.
Installation
Our support for LSL is mainly done in python. Download python here: Please choose a 64 bit version.. Run the installer and make sure to add Python to the file path (it's an option in the installer).
Open a command prompt, start with upgrading the pip installer by typing:
c:>python -m pip install --upgrade pip
Then:
c:>pip install pylsl
more info: cross platform pylsl
Versions
The TSG uses the version 1.15.0. Open a command and type the following to find the version used:
c:>python
>>> import pylsl
>>> print(pylsl.__version__)
Usage
Python
A short example for sending lsl streaming data:
1#!/usr/bin/env python
2
3import threading
4from pylsl import StreamInfo, StreamOutlet
5
6def getData():
7 while running:
8 buffer_in = getSensorData()
9 send_data = True
10 time.sleep(0.001)
11
12info = StreamInfo(
13 name='MyStream',
14 type='COP',
15 channel_count=4,
16 nominal_srate = 200,
17 source_id='BalanceBoard_stream'
18 )
19outlet = StreamOutlet(info)
20
21threading.Thread(target=getData).start()
22while running == True:
23 if send_data:
24 outlet.push_chunk(buffer_in)
25 send_data = False
A short example for sending lsl streaming data:
1#!/usr/bin/env python
2
3import threading
4from pylsl import StreamInfo, StreamOutlet
5
6def getData():
7 while running:
8 buffer_in = getSensorData()
9 send_data = True
10 time.sleep(0.001)
11
12info = StreamInfo(
13 name='MyStream',
14 type='COP',
15 channel_count=4,
16 nominal_srate = 200,
17 source_id='BalanceBoard_stream'
18 )
19outlet = StreamOutlet(info)
20
21threading.Thread(target=getData).start()
22while running == True:
23 if send_data:
24 outlet.push_chunk(buffer_in)
25 send_data = False
References