Problem with getting timestamp data using pyliblo


#1

Hi!

I’ve found the only mentioning about timestamps here. But still I can’t understand how to grep them.

Could anyone explain me how to get timestamp data using pyliblo?


#2

If you use the --osc-timestamp flag with MuseIO, timestamp information will be appended to the /muse/eeg messages. From the developer site (https://sites.google.com/a/interaxon.ca/muse-developer-site/museio/osc-paths/osc-paths---v3-6-0#TOC-muse-eeg):

If the --osc_timestamp option is used, there are 2 extra fields appended to these messages:

  • integer: Number of seconds since 1970 when this event occurred
  • integer: Number of microseconds within that second

Then, in pyliblo, it’s a matter of parsing that message. So, working from the dev site’s Getting Started example:

 
from liblo import *
  import sys 
  import time
 
  class MuseServer(ServerThread):
      #listen for messages on port 5001
      def __init__(self):
          ServerThread.__init__(self, 5001)
 
      #receive EEG data with timestamp info
      @make_method('/muse/eeg', 'ffffii')
      def eeg_callback(self, path, args):
          l_ear, l_forehead, r_forehead, r_ear, seconds, microseconds = args
          print "%s %f %f %f %f %i %i" \
                % (path, l_ear, l_forehead, r_forehead, r_ear, seconds, microseconds)
 
      #handle unexpected messages
      @make_method(None, None)
      def fallback(self, path, args, types, src):
          print "Unknown message \
          
	 Source: '%s' \
          
	 Address: '%s' \
          
	 Types: '%s ' \
          
	 Payload: '%s'" \
          % (src.url, path, types, args)
   
  try:
      server = MuseServer()
  except ServerError, err:
      print str(err)
      sys.exit()
   
  server.start()
   
  if __name__ == "__main__":
      while 1:
          time.sleep(1)
 








#3

Thanks a lot!