matplotlib_standalone.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:esys-pbi 作者: fsxfreak 项目源码 文件源码
def _graph_lsl(self):
    print('checking if stream has be initialized')
    self.streams = resolve_byprop('name', 'bci', timeout=2.5)
    try:
      self.inlet = StreamInlet(self.streams[0])
    except IndexError:
      raise ValueError('Make sure stream name=bci is opened first.')
    while self.running:
      # initial run
      self.sample, self.timestamp = self.inlet.pull_sample(timeout=5)
    # time correction to sync to local_clock()
      try:
        if self.timestamp is not None and self.sample is not None:
          self.timestamp = self.timestamp + self.inlet.time_correction(timeout=5) 

      except TimeoutError:
        pass
      self.SecondTimes.append(self.sample[1])                         #add time stamps to array 'timeValSeconds'
      self.ProcessedSig.append(self.sample[0])                           #add processed signal values to 'processedSig'

      self.count = self.count + 1

      if((self.count % 20 == 0) and (self.count != 0)):   #every 20 samples (ie ~ 0.10 s) is when plot updates
    self.lineHandle[0].set_ydata(self.ProcessedSig)
    self.lineHandle[0].set_xdata(self.SecondTimes)
    #plt.xlim(0, 5)
    plt.xlim(self.SecondTimes[0], self.SecondTimes[-1])
    plt.ylim(0, 10)
    plt.pause(0.01)

      if(self.count >= 399): 
        self.ProcessedSig.pop(0)    
        self.SecondTimes.pop(0)

    plt.pause(0.01)
    print('closing graphing utility')
    self.inlet.close_stream()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号