本文整理汇总了Python中pylsl.StreamOutlet方法的典型用法代码示例。如果您正苦于以下问题:Python pylsl.StreamOutlet方法的具体用法?Python pylsl.StreamOutlet怎么用?Python pylsl.StreamOutlet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylsl
的用法示例。
在下文中一共展示了pylsl.StreamOutlet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pylsl [as 别名]
# 或者: from pylsl import StreamOutlet [as 别名]
def __init__(self, type_, n_chs, sfreq, send_data=False):
"""Add docstring here."""
if type_ not in ["Markers", "EEG"]:
raise ValueError("`type_` must be 'Markers' or 'EEG'.")
self.type_ = type_
self.n_chs = n_chs
self.sfreq = sfreq
self.send_data = send_data
self.stream_name = "test_{}_{}".format(self.type_, randint(1, 100))
self.stream_type = 'float32' if self.type_ == "EEG" else 'int32'
info = StreamInfo(self.stream_name, self.type_, self.n_chs, self.sfreq,
self.stream_type, self.stream_name + '_1234')
# Add metadata.
info.desc().append_child_value("nominal_srate", str(self.sfreq))
if self.type_ == "EEG":
ch_names = ['ch{}'.format(x) for x in range(1, self.n_chs + 1)]
for c in ch_names:
info.desc().append_child("channel")\
.append_child_value("name", c)\
.append_child_value("unit", "volts")\
.append_child_value("type", "EEG")
self.outlet = StreamOutlet(info)
if self.send_data:
self.event = Event()
self.thread = Thread(target=self._send_data)
self.thread.start()
示例2: activate
# 需要导入模块: import pylsl [as 别名]
# 或者: from pylsl import StreamOutlet [as 别名]
def activate(self):
eeg_stream = "OpenBCI_EEG"
eeg_id = "openbci_eeg_id1"
aux_stream = "OpenBCI_AUX"
aux_id = "openbci_aux_id1"
imp_stream = "OpenBCI_Impedance"
imp_id = "openbci_imp_id1"
if len(self.args) > 0:
eeg_stream = self.args[0]
if len(self.args) > 1:
eeg_id = self.args[1]
if len(self.args) > 2:
aux_stream = self.args[2]
if len(self.args) > 3:
aux_id = self.args[3]
if len(self.args) > 4:
imp_stream = self.args[4]
if len(self.args) > 5:
imp_id = self.args[5]
# Create a new streams info, one for EEG values, one for AUX (eg, accelerometer) values
print("Creating LSL stream for EEG. Name:" + eeg_stream + "- ID:" + eeg_id +
"- data type: float32." + str(self.eeg_channels) +
"channels at" + str(self.sample_rate) + "Hz.")
info_eeg = StreamInfo(eeg_stream, 'EEG', self.eeg_channels,
self.sample_rate, 'float32', eeg_id)
# NB: set float32 instead of int16 so as OpenViBE takes it into account
print("Creating LSL stream for AUX. Name:" + aux_stream + "- ID:" + aux_id +
"- data type: float32." + str(self.aux_channels) +
"channels at" + str(self.sample_rate) + "Hz.")
info_aux = StreamInfo(aux_stream, 'AUX', self.aux_channels,
self.sample_rate, 'float32', aux_id)
# make outlets
self.outlet_eeg = StreamOutlet(info_eeg)
self.outlet_aux = StreamOutlet(info_aux)
if self.imp_channels > 0:
print("Creating LSL stream for Impedance. Name:" + imp_stream + "- ID:" +
imp_id + "- data type: float32." + str(self.imp_channels) +
"channels at" + str(self.sample_rate) + "Hz.")
info_imp = StreamInfo(imp_stream, 'Impedance', self.imp_channels,
self.sample_rate, 'float32', imp_id)
self.outlet_imp = StreamOutlet(info_imp)
# send channels values
示例3: _start
# 需要导入模块: import pylsl [as 别名]
# 或者: from pylsl import StreamOutlet [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, debug, lsl_name, lsl_type, lsl_id, lsl_format, info, outlet, trigger, item, lock, thread, previous_val
# 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
debug = patch.getint('general', 'debug')
lsl_name = patch.getstring('lsl', 'name', default='eegsynth')
lsl_type = patch.getstring('lsl', 'type', default='Markers')
lsl_id = patch.getstring('lsl', 'id', default=randomStringDigits())
lsl_format = patch.getstring('lsl', 'format')
# create an outlet stream
info = StreamInfo(lsl_name, lsl_type, 1, 0, 'string', lsl_id)
outlet = StreamOutlet(info)
# create the background threads that deal with the triggers
trigger = []
monitor.info("Setting up threads for each trigger")
for item in config.items('trigger'):
trigger.append(TriggerThread(item[1], item[0]))
monitor.debug(str(item[0]) + " " + str(item[1]) + " OK")
# this is to prevent two messages from being sent at the same time
lock = threading.Lock()
# start the thread for each of the triggers
for thread in trigger:
thread.start()
previous_val = {}
for item in config.items('control'):
key = item[0]
previous_val[key] = None
# there should not be any local variables in this function, they should all be global
if len(locals()):
print('LOCALS: ' + ', '.join(locals().keys()))