本文整理匯總了Python中pylsl.StreamInfo方法的典型用法代碼示例。如果您正苦於以下問題:Python pylsl.StreamInfo方法的具體用法?Python pylsl.StreamInfo怎麽用?Python pylsl.StreamInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pylsl
的用法示例。
在下文中一共展示了pylsl.StreamInfo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import pylsl [as 別名]
# 或者: from pylsl import StreamInfo [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: __init__
# 需要導入模塊: import pylsl [as 別名]
# 或者: from pylsl import StreamInfo [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()
示例3: activate
# 需要導入模塊: import pylsl [as 別名]
# 或者: from pylsl import StreamInfo [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
示例4: _start
# 需要導入模塊: import pylsl [as 別名]
# 或者: from pylsl import StreamInfo [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()))