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()
评论列表
文章目录