Guest User

Untitled

a guest
Oct 18th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Wed Sep 20 11:08:36 2017
  5.  
  6. @author: jscastanoc
  7. """
  8.  
  9. from pylsl import StreamInlet, resolve_stream
  10. import matplotlib.pyplot as plt
  11.  
  12. print("looking for a stream...")
  13.  
  14. streams = resolve_stream()
  15.  
  16. stream_dict = dict()
  17.  
  18. fig_imu, ax_imu = plt.subplots()
  19. fig_ecog, ax_ecog = plt.subplots()
  20. plt.ion()
  21.  
  22. for stream in streams:
  23. print('found stream with name %s' % (stream.name()))
  24. if stream.name() == u'ecog':
  25. inlet_ecog = StreamInlet(stream)
  26. elif stream.name() == u'imu':
  27. inlet_imu = StreamInlet(stream)
  28. else:
  29. print('Dont know what to do with stream with name %s ' % (stream.name()))
  30.  
  31. while True:
  32. chunk_imu, timestamps_imu = inlet_imu.pull_chunk()
  33. chunk_ecog, timestamps_ecog = inlet_ecog.pull_chunk()
  34.  
  35. if timestamps_imu:
  36. ax_imu.plot(timestamps_imu, chunk_imu)
  37. if timestamps_ecog:
  38. ax_ecog.plot(timestamps_ecog, chunk_ecog)
  39. plt.pause(0.05)
Add Comment
Please, Sign In to add comment