DataHub: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
| (8 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{Infobox software | {{Infobox software | ||
| name = | | name = Lab Streaming Layer | ||
| developer = Christian Kothe; Chadwick Boulay. | | developer = Christian Kothe; Chadwick Boulay. | ||
| status = -in development- | | status = -in development- | ||
| Line 13: | Line 13: | ||
{{Infobox tsg | {{Infobox tsg | ||
| downloads = {{bulleted list | | downloads = {{bulleted list | ||
| | | {{Surfdrive|https://surfdrive.surf.nl/s/GLSnbBaYsbEWjPX|Viewer & Streamer}} | ||
}} | }} | ||
| manuals = {{bulleted list | | manuals = {{bulleted list | ||
| Line 21: | Line 21: | ||
}} | }} | ||
| templates = {{bulleted list | | templates = {{bulleted list | ||
| | | {{Surfdrive|https://surfdrive.surf.nl/s/gPenWNAqq8AXa7x|Example Scripts}} | ||
}} | }} | ||
}} | }} | ||
| Line 39: | Line 39: | ||
===Versions=== | ===Versions=== | ||
Pylsl version 1.16.2 is installed on our [[Lab Computer]]s. 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;">c:>python</code><br/> | ||
| Line 53: | Line 53: | ||
import time | import time | ||
import | import random | ||
import keyboard | import keyboard | ||
from pylsl import StreamInfo, StreamOutlet | |||
from pylsl import StreamInfo, StreamOutlet | |||
from pylsl import local_clock | |||
# | # --- Setup Marker Stream --- | ||
print("Setting up marker stream...") | |||
marker_info = StreamInfo( | marker_info = StreamInfo( | ||
name= | name="MarkerStream", | ||
type= | type="Markers", | ||
channel_count= | channel_count=1, | ||
nominal_srate= | nominal_srate=0, # Irregular sampling | ||
channel_format= | channel_format="string", | ||
source_id= | source_id="MarkerSource" | ||
) | ) | ||
marker_outlet = StreamOutlet(marker_info, chunk_size= | marker_outlet = StreamOutlet(marker_info, chunk_size=1) | ||
# --- Setup Data Stream --- | |||
print("Setting up data stream...") | |||
data_info = StreamInfo( | |||
name="TestStream", | |||
type="TestData", | |||
channel_count=4, | |||
nominal_srate=100, | |||
channel_format="float32", | |||
source_id="TestStream_Source" | |||
) | ) | ||
channels = data_info.desc().append_child("channels") | |||
data_info | for name in ["A", "B", "C", "D"]: | ||
chan = channels.append_child("channel") | |||
chan.append_child_value("name", name) | |||
chan.append_child_value("unit", "unitless") | |||
chan.append_child_value("type", "TestData") | |||
data_outlet = StreamOutlet(data_info, chunk_size=1) | |||
# --- Start Streaming --- | |||
print("Start streaming... Press 'q' to stop.") | print("Start streaming... Press 'q' to stop.") | ||
marker_outlet.push_sample(["Start"]) | |||
while not | while not keyboard.is_pressed('q'): | ||
random_numbers = [random.randint(1, 2) for _ in range(4)] | |||
random_numbers = [random.randint( | |||
data_outlet.push_sample(random_numbers) | data_outlet.push_sample(random_numbers) | ||
time.sleep(0.01) | |||
time.sleep( | |||
marker_outlet.push_sample(["Stop"]) | marker_outlet.push_sample(["Stop"]) | ||
print("Streaming stopped.") | |||
</syntaxhighlight> | </syntaxhighlight> | ||