當前位置: 首頁>>代碼示例>>Python>>正文


Python pylsl.StreamOutlet方法代碼示例

本文整理匯總了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() 
開發者ID:kaczmarj,項目名稱:rteeg,代碼行數:30,代碼來源:utils.py

示例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 
開發者ID:openbci-archive,項目名稱:OpenBCI_Python,代碼行數:49,代碼來源:streamer_lsl.py

示例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())) 
開發者ID:eegsynth,項目名稱:eegsynth,代碼行數:47,代碼來源:outputlsl.py


注:本文中的pylsl.StreamOutlet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。