| Line 47: |
Line 47: |
| | ==Usage== | | ==Usage== |
| | === Python === | | === Python === |
| − | A short example for sending lsl streaming data:
| + | Example demonstrating how to send LSL stream and marker data: |
| | <syntaxhighlight lang="python" line> | | <syntaxhighlight lang="python" line> |
| | #!/usr/bin/env python3.10 | | #!/usr/bin/env python3.10 |
| Line 109: |
Line 109: |
| | marker_outlet.push_sample(["Stop"]) | | marker_outlet.push_sample(["Stop"]) |
| | | | |
| | + | </syntaxhighlight> |
| | + | |
| | + | |
| | + | the settings.py file for LSL: |
| | + | <syntaxhighlight lang="python" line> |
| | + | # settings.py |
| | + | |
| | + | class BaseSettings: |
| | + | """Basisklasse met standaardinstellingen voor een LSL stream.""" |
| | + | def __init__(self): |
| | + | self.stream_name = "BaseStream" |
| | + | self.stream_type = "Unknown" |
| | + | self.channel_count = 1 |
| | + | self.sample_rate = 0 |
| | + | self.channel_format = "float32" |
| | + | self.source_id = "BaseSource" |
| | + | |
| | + | self.channel_names = [] |
| | + | self.push_chunk_size = 1 |
| | + | self.push_interval = 0.001 |
| | + | |
| | + | self.use_random_data = False |
| | + | self.dummy_string = "Test" |
| | + | self.random_string_options = ["A", "B", "C"] |
| | + | |
| | + | self.verbose = True |
| | + | self.quit_method = "psychopy" |
| | + | self.user_stop_message = "Press ENTER/RETURN to stop acquisition." |
| | + | |
| | + | self.default_buffer = ["Test"] |
| | + | |
| | + | # the scope is not implemented yet |
| | + | self.scope = "lan" |
| | + | |
| | + | def get_stream_options(self): |
| | + | if self.scope in ["local", "lan", "internet"]: |
| | + | return dict() |
| | + | else: |
| | + | raise ValueError(f"Unknown scope: {self.scope}") |
| | + | |
| | + | |
| | + | class DynamicMultiChannelStreamSettings(BaseSettings): |
| | + | def __init__( |
| | + | self, |
| | + | n_channels=8, |
| | + | stream_name="DynamicStream", |
| | + | stream_type="EEG", |
| | + | sample_rate=256, |
| | + | channel_format="float32", |
| | + | channel_names=None |
| | + | ): |
| | + | super().__init__() |
| | + | self.stream_name = stream_name |
| | + | self.stream_type = stream_type |
| | + | self.channel_count = n_channels |
| | + | self.sample_rate = sample_rate |
| | + | self.channel_format = channel_format |
| | + | self.source_id = f"{stream_name}_Source" |
| | + | |
| | + | if channel_names is not None: |
| | + | if len(channel_names) != n_channels: |
| | + | raise ValueError(f"Number of channel names ({len(channel_names)}) does not match n_channels ({n_channels})") |
| | + | self.channel_names = channel_names |
| | + | else: |
| | + | self.channel_names = [f"Chan{i+1}" for i in range(n_channels)] |
| | + | |
| | + | self.default_buffer = [0.0 for _ in range(n_channels)] |
| | + | |
| | + | class MarkerStreamSettings(BaseSettings): |
| | + | def __init__(self): |
| | + | super().__init__() |
| | + | self.stream_name = "MarkerStream" |
| | + | self.stream_type = "Markers" |
| | + | self.channel_count = 1 |
| | + | self.sample_rate = 0 # 0 Hz = irregular sampling |
| | + | self.channel_format = "string" |
| | + | self.source_id = "MarkerSource" |
| | + | |
| | + | self.channel_names = [] # niet nodig voor markers |
| | + | self.default_buffer = ["TestMarker"] |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |