Difference between revisions of "DataHub"
Wiki-admin (talk | contribs) (Created page with "{{Infobox software | name = DataHub | logo = | screenshot = | caption = | developer = Christian...") |
Wiki-admin (talk | contribs) (→Matlab) |
||
(35 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
| screenshot = | | screenshot = | ||
| caption = | | caption = | ||
− | | developer = Christian Kothe; | + | | developer = Christian Kothe; Chadwick Boulay. |
| released = <!-- {{Start date and age|YYYY|MM|DD|df=yes}} --> | | released = <!-- {{Start date and age|YYYY|MM|DD|df=yes}} --> | ||
| discontinued = | | discontinued = | ||
Line 13: | Line 13: | ||
| installed version = | | installed version = | ||
| installed version date = <!-- {{Start date and age|YYYY|MM|DD|df=yes}} --> | | installed version date = <!-- {{Start date and age|YYYY|MM|DD|df=yes}} --> | ||
− | | status = in development | + | | status = -in development- |
| programming language = C, C++, Python, Java, C#, MATLAB | | programming language = C, C++, Python, Java, C#, MATLAB | ||
| operating system = Windows, Linux, MacOS, Android, iOS | | operating system = Windows, Linux, MacOS, Android, iOS | ||
Line 21: | Line 21: | ||
| genre = Data collection | | genre = Data collection | ||
| license = Open source | | license = Open source | ||
− | | website = [https:// | + | | website = [https://labstreaminglayer.readthedocs.io/info/intro.html LSL webpage] |
| resources = | | resources = | ||
{{Infobox tsg | {{Infobox tsg | ||
Line 27: | Line 27: | ||
| downloads = | | downloads = | ||
| manuals = {{bulleted list | | manuals = {{bulleted list | ||
− | | [https://docs. | + | | [https://docs.openbci.com/ Documentation] |
+ | | [https://sccn.ucsd.edu/~mgrivich/LSL_Validation.html LSL Validation] | ||
+ | | [https://labstreaminglayer.readthedocs.io/info/supported_devices.html Supported Devices and Tools] | ||
+ | }} | ||
+ | | header2 = Templates | ||
+ | | data2 = {{bulleted list | ||
+ | | [https://surfdrive.surf.nl/files/index.php/s/qggfMMKsnUIDO0k example scripts (zip)] | ||
}} | }} | ||
}} | }} | ||
}} | }} | ||
− | + | 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. | |
<!-- Table of Contents will be generated here --> | <!-- Table of Contents will be generated here --> | ||
==Installation== | ==Installation== | ||
− | + | Our support for LSL is mainly done in python. Download python here: [https://www.python.org/downloads/release/python-376/ 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:<br/> | ||
+ | <code style="background-color:#000; color:#fff; padding:1px 3px;">c:>python -m pip install --upgrade pip</code><br/> | ||
+ | Then:<br/> | ||
+ | <code style="background-color:#000; color:#fff; padding:1px 3px;">c:>pip install pylsl</code> | ||
+ | |||
+ | more info: [https://github.com/labstreaminglayer/liblsl-Python cross platform pylsl] | ||
===Versions=== | ===Versions=== | ||
− | + | The TSG uses the version 1.15.0. Open a command and type the following to find the version used: | |
+ | |||
+ | <code style="background-color:#000; color:#fff; padding:1px 3px;">c:>python</code><br/> | ||
+ | <code style="background-color:#000; color:#fff; padding:1px 3px;">>>> import pylsl</code><br/> | ||
+ | <code style="background-color:#000; color:#fff; padding:1px 3px;">>>> print(pylsl.__version__)</code><br/> | ||
==Usage== | ==Usage== | ||
− | ''( | + | === 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 receiving lsl data: | ||
+ | <syntaxhighlight lang="python" line> | ||
+ | #!/usr/bin/env python | ||
+ | |||
+ | from pylsl import StreamInlet, resolve_stream | ||
+ | |||
+ | streams = resolve_stream('name', 'MyStream') | ||
+ | #streams = resolve_streams() | ||
+ | |||
+ | inlet = StreamInlet(streams[0]) | ||
+ | while True: | ||
+ | sample, timestamp = inlet.pull_sample() | ||
+ | print(timestamp, sample) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Matlab === | ||
+ | Please, read the instructions on the GitHub labstreaminglayer website (https://github.com/labstreaminglayer/liblsl-Matlab) on how to prepare Matlab to work with LSL. You can either use the latest release for your Matlab version, or if that doesn't workout well, build it from the source files. Make sure to add the liblsl-Matlab folder to your path recursively to make it available to your own scripts. | ||
+ | |||
+ | A short example for sending lsl streaming data: | ||
+ | <syntaxhighlight lang="matlab" line> | ||
+ | %% instantiate the library | ||
+ | disp('Loading library...'); | ||
+ | lib = lsl_loadlib(); | ||
+ | |||
+ | % make a new stream outlet | ||
+ | disp('Creating a new streaminfo...'); | ||
+ | info = lsl_streaminfo(lib,'BioSemi','EEG',8,100,'cf_float32','sdfwerr32432'); | ||
+ | |||
+ | disp('Opening an outlet...'); | ||
+ | outlet = lsl_outlet(info); | ||
+ | |||
+ | % send data into the outlet, sample by sample | ||
+ | disp('Now transmitting data...'); | ||
+ | while true | ||
+ | outlet.push_sample(randn(8,1)); | ||
+ | pause(0.01); | ||
+ | end | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | A short example for receiving lsl streaming data: | ||
+ | <syntaxhighlight lang="matlab" line> | ||
+ | %% instantiate the library | ||
+ | disp('Loading the library...'); | ||
+ | lib = lsl_loadlib(); | ||
− | == | + | % resolve a stream... |
− | + | disp('Resolving an EEG stream...'); | |
+ | result = {}; | ||
+ | while isempty(result) | ||
+ | result = lsl_resolve_byprop(lib,'type','EEG'); end | ||
− | = | + | % create a new inlet |
− | + | disp('Opening an inlet...'); | |
+ | inlet = lsl_inlet(result{1}); | ||
− | = | + | disp('Now receiving data...'); |
− | + | while true | |
− | + | % get data from the inlet | |
+ | [vec,ts] = inlet.pull_sample(); | ||
+ | % and display it | ||
+ | fprintf('%.2f\t',vec); | ||
+ | fprintf('%.5f\n',ts); | ||
+ | end</syntaxhighlight> |
Latest revision as of 13:09, 23 January 2023
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 receiving lsl data:
1#!/usr/bin/env python
2
3from pylsl import StreamInlet, resolve_stream
4
5streams = resolve_stream('name', 'MyStream')
6#streams = resolve_streams()
7
8inlet = StreamInlet(streams[0])
9while True:
10 sample, timestamp = inlet.pull_sample()
11 print(timestamp, sample)
Matlab
Please, read the instructions on the GitHub labstreaminglayer website (https://github.com/labstreaminglayer/liblsl-Matlab) on how to prepare Matlab to work with LSL. You can either use the latest release for your Matlab version, or if that doesn't workout well, build it from the source files. Make sure to add the liblsl-Matlab folder to your path recursively to make it available to your own scripts.
A short example for sending lsl streaming data:
1%% instantiate the library
2disp('Loading library...');
3lib = lsl_loadlib();
4
5% make a new stream outlet
6disp('Creating a new streaminfo...');
7info = lsl_streaminfo(lib,'BioSemi','EEG',8,100,'cf_float32','sdfwerr32432');
8
9disp('Opening an outlet...');
10outlet = lsl_outlet(info);
11
12% send data into the outlet, sample by sample
13disp('Now transmitting data...');
14while true
15 outlet.push_sample(randn(8,1));
16 pause(0.01);
17end
A short example for receiving lsl streaming data:
1%% instantiate the library
2disp('Loading the library...');
3lib = lsl_loadlib();
4
5% resolve a stream...
6disp('Resolving an EEG stream...');
7result = {};
8while isempty(result)
9 result = lsl_resolve_byprop(lib,'type','EEG'); end
10
11% create a new inlet
12disp('Opening an inlet...');
13inlet = lsl_inlet(result{1});
14
15disp('Now receiving data...');
16while true
17 % get data from the inlet
18 [vec,ts] = inlet.pull_sample();
19 % and display it
20 fprintf('%.2f\t',vec);
21 fprintf('%.5f\n',ts);
22end