本文整理汇总了Python中pylsl.StreamInlet方法的典型用法代码示例。如果您正苦于以下问题:Python pylsl.StreamInlet方法的具体用法?Python pylsl.StreamInlet怎么用?Python pylsl.StreamInlet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylsl
的用法示例。
在下文中一共展示了pylsl.StreamInlet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_stream_inlet
# 需要导入模块: import pylsl [as 别名]
# 或者: from pylsl import StreamInlet [as 别名]
def _get_stream_inlet(lsl_predicate):
"""Return the stream that fits the given predicate. Raise ValueError if
multiple streams or zero streams match the predicate.
Parameters
----------
lsl_predicate : str
Predicate used to find LabStreamingLayer stream. See
`default_predicates.py` for more info.
Returns
-------
inlet : pylsl.StreamInlet
The LSL stream that matches the given predicate.
"""
stream = resolve_bypred(lsl_predicate) # Times out after ~ 1 year.
if len(stream) == 1:
inlet = StreamInlet(stream[0])
logger.info("Connected to stream.")
else:
msg = ("Multiple streams match the given predicate. Only one "
"stream must match the predicate.")
logger.error(msg)
raise ValueError(msg)
return inlet
示例2: test_BaseStream_record_data_indefinitely
# 需要导入模块: import pylsl [as 别名]
# 或者: from pylsl import StreamInlet [as 别名]
def test_BaseStream_record_data_indefinitely():
"""Test rteeg.base.BaseStream"""
# Start a LabStreamingLayer stream of synthetic data.
eeg_out = SyntheticData("EEG", 32, 100, send_data=True)
inlet = StreamInlet(resolve_streams(wait_time=1.)[0])
base = BaseStream()
# Check that length of base.data increases.
len_0 = len(base.data)
t = threading.Thread(target=base._record_data_indefinitely, args=(inlet,))
t.daemon = True
t.start()
time.sleep(2.)
len_1 = len(base.data)
assert len_1 > len_0, "Data not being recorded."
# Clean up.
base._kill_signal.set()
eeg_out.stop()
示例3: test_get_stream_inlet
# 需要导入模块: import pylsl [as 别名]
# 或者: from pylsl import StreamInlet [as 别名]
def test_get_stream_inlet():
eeg_1 = SyntheticData("EEG", 32, 100, send_data=False)
eeg_2 = SyntheticData("EEG", 32, 100, send_data=False)
# Check for error if multiple matching streams exist.
with pytest.raises(ValueError, message='Error on multiple streams'):
_get_stream_inlet("type='EEG'")
eeg_2.stop() # Remove one LSL stream.
# Check that inlet is of type pylsl.StreamInlet.
inlet = _get_stream_inlet("type='EEG'")
assert isinstance(inlet, StreamInlet), "Not pylsl.StreamInlet"
eeg_1.stop() # Clean up remaining LSL stream.
示例4: __init__
# 需要导入模块: import pylsl [as 别名]
# 或者: from pylsl import StreamInlet [as 别名]
def __init__(self, info: pylsl.StreamInfo):
# create an inlet and connect it to the outlet we found earlier.
# max_buflen is set so data older the plot_duration is discarded
# automatically and we only pull data new enough to show it
# Also, perform online clock synchronization so all streams are in the
# same time domain as the local lsl_clock()
# (see https://labstreaminglayer.readthedocs.io/projects/liblsl/ref/enums.html#_CPPv414proc_clocksync)
# and dejitter timestamps
self.inlet = pylsl.StreamInlet(info, max_buflen=plot_duration,
processing_flags=pylsl.proc_clocksync | pylsl.proc_dejitter)
# store the name and channel count
self.name = info.name()
self.channel_count = info.channel_count()
示例5: _start
# 需要导入模块: import pylsl [as 别名]
# 或者: from pylsl import StreamInlet [as 别名]
def _start():
'''Start the module
This uses the global variables from setup and adds a set of global variables
'''
global parser, args, config, r, response, patch, name
global monitor, delay, timeout, lsl_name, lsl_type, lsl_format, output_prefix, start, selected, streams, stream, inlet, type, source_id, match, lsl_id
# this can be used to show parameters that have changed
monitor = EEGsynth.monitor(name=name, debug=patch.getint('general', 'debug'))
# get the options from the configuration file
delay = patch.getfloat('general', 'delay')
timeout = patch.getfloat('lsl', 'timeout', default=30)
lsl_name = patch.getstring('lsl', 'name')
lsl_type = patch.getstring('lsl', 'type')
lsl_format = patch.getstring('lsl', 'format')
output_prefix = patch.getstring('output', 'prefix')
monitor.info("looking for an LSL stream...")
start = time.time()
selected = []
while len(selected) < 1:
if (time.time() - start) > timeout:
monitor.error("Error: timeout while waiting for LSL stream")
raise SystemExit
# find the desired stream on the lab network
streams = lsl.resolve_streams()
for stream in streams:
inlet = lsl.StreamInlet(stream)
name = inlet.info().name()
type = inlet.info().type()
source_id = inlet.info().source_id()
# determine whether this stream should be further processed
match = True
if len(lsl_name):
match = match and lsl_name == name
if len(lsl_type):
match = match and lsl_type == type
if match:
# select this stream for further processing
selected.append(stream)
monitor.info('-------- STREAM(*) ------')
else:
monitor.info('-------- STREAM ---------')
monitor.info("name = " + name)
monitor.info("type = " + type)
monitor.info('-------------------------')
# create a new inlet from the first (and hopefully only) selected stream
inlet = lsl.StreamInlet(selected[0])
# give some feedback
lsl_name = inlet.info().name()
lsl_type = inlet.info().type()
lsl_id = inlet.info().source_id()
monitor.success('connected to LSL stream %s (type = %s, id = %s)' % (lsl_name, lsl_type, lsl_id))
# there should not be any local variables in this function, they should all be global
if len(locals()):
print('LOCALS: ' + ', '.join(locals().keys()))