示例#1
0
def beep():
    ns.sync()
    log_time = egi.ms_localtime()
    # logging.data('beep sent at local time: ' + str(egi.ms_localtime()))
    print "Beep logged at " + str(log_time)
    ns.sync()
    sent_time = egi.ms_localtime()
    ns.send_event(key='beep',
                  timestamp=None,
                  description='below is sample table',
                  table={
                      'abcd': 1,
                      'efgh': 2
                  },
                  pad=False)
    print "Beep sent at " + str(sent_time)
    diff = log_time - sent_time
    return diff
示例#2
0
 def send(self, ev):
     ns = self.ns
     timestamp = egi.ms_localtime()
     ns.send_event(ev,
                   label=ev,
                   timestamp=timestamp,
                   table={
                       'label': ev,
                       'timestamp': timestamp
                   })
    def send(self,ev):
        ns = self.ns
        # so - if you say 0 (i.e., the number, then EGI will just make it a string - easy.)
        # would make more sense within an inheritance model - or NOT, in this case.
        # because ONLY for EGI do you wish for a string.
        if not isinstance(ev,str):
            ev = str(ev)

        timestamp = egi.ms_localtime()
        
        ns.send_event( ev, label=ev, timestamp=timestamp, table = {'label' : ev, 'timestamp' : timestamp} ) 
示例#4
0
ns = egi.Netstation()
ns.connect('11.0.0.42', 55513) # sample address and port -- change according to your network settings
## ns.initialize('11.0.0.42', 55513)
ns.BeginSession()     

ns.sync()     

ns.StartRecording()



# >>> send many events here >>> 

## # optionally can perform additional synchronization     
## ns.sync()     
ns.send_event( 'evt_', label="event", timestamp=egi.ms_localtime(), table = {'fld1' : 123, 'fld2' : "abc", 'fld3' : 0.042} ) 



# >>> we have sent all we wanted, time to go home >>> 

ns.StopRecording()

ns.EndSession()     
ns.disconnect()

## ns.EndSession()     
## ns.finalize()     

# >>> that's it !
示例#5
0
# sample address and port; change according to your network settings
ns.connect('11.0.0.42', 55513)
# ns.initialize('11.0.0.42', 55513)

ns.BeginSession()
ns.sync()
ns.StartRecording()

# Send many events here:

# optionally can perform additional synchronization
# ns.sync()
ns.send_event('evt_',
              label="event",
              timestamp=egi.ms_localtime(),
              table={
                  'fld1': 123,
                  'fld2': "abc",
                  'fld3': 0.042
              })

# We have sent all we wanted, time to go home:
ns.StopRecording()
ns.EndSession()
ns.disconnect()

# ns.EndSession()
# ns.finalize()

# The contents of this file are in the public domain.
示例#6
0
time.sleep(0.1)  # force the events to arrive in the "correct" order

# log: tag in single quotes     
## timestamps : NS time since the moment of recording     

ns.send_event('evt2', label="event2")
time.sleep(0.1)  # force the events to arrive in the "correct" order

# log: label without quotes     

ns.send_event('evt3', label="event3", description="this will appear")
time.sleep(0.1)  # force the events to arrive in the "correct" order

# description on the next line     

ns.send_event('evt5', timestamp=egi.ms_localtime()) 
ns.send_event('evt6', description='back in time', timestamp=egi.ms_localtime() - 50)

time.sleep(0.1)  # force the events to arrive in the "correct" order

# appear in the order of posting, but with "correct" timestamps ( i.e. last has a timestamp that is 50 ms "earlier" than the previous )     


#
# two real-life examples 
#

ns.send_event( 'evt_', timestamp=egi.ms_localtime() ) 
time.sleep(0.1)  # force the events to arrive in the "correct" order

ns.send_event( 'evt_', timestamp=egi.ms_localtime(), table = {'fld1' : 123, 'fld2' : "abc", 'fld3' : 0.042} ) 
示例#7
0
# Log: (timestamp): event3 'evt3'
# Log: this will appear
ns.send_event('evt3', label="event3", description="this will appear")
# See Note 2 above.
time.sleep(0.1)

# # Sending events in NetStation with Pre-calculated timestamps
# # Note 3: Events will appear in the order sent, but with "altered" timestamps
# # (i.e. `evt5` has a timestamp that is 50 ms "earlier" than `evt4`)
# # Note 4: When sending events, if you don't list anything for `timestamp=` then the timestamp
# # will automatically be set to the time the event is sent. This is the preferred method.
# # (i.e. your timestamp is based on the time you run the line, not on the time you tell it)
# # NetStation Changes:
# Main Window: (Event flag listed in the events track)
# Log: (Event-sending PC's pre-calculated timestamp): 'evt4'
ns.send_event('evt4', timestamp=egi.ms_localtime())

# # NetStation Changes:
# Main Window: (Event flag listed in the events track)
# Log: (Event-sending PC's pre-calculated timestamp minus 50ms): 'evt5'
# Log: back in time
ns.send_event('evt5',
              description='back in time',
              timestamp=egi.ms_localtime() - 50)
# See Note 2 above.
time.sleep(0.1)

# # More realistic event-sending examples
# # NetStation Changes:
# Main Window: (Event flag listed in the events track)
# Log: (timestamp): 'evt_'
示例#8
0
# ms_localtime = egi.egi_internal.ms_localtime
ms_localtime = egi.ms_localtime

ns = egi.Netstation()

# sample address and port; change according to your network settings
ns.connect('11.0.0.42', 55513)
# ns.initialize('11.0.0.42', 55513)

ns.BeginSession()
ns.sync()
ns.StartRecording()

# Send many events here:

# optionally can perform additional synchronization
# ns.sync()
ns.send_event('evt_', label="event", timestamp=egi.ms_localtime(),
              table = {'fld1' : 123, 'fld2' : "abc", 'fld3' : 0.042} )

# We have sent all we wanted, time to go home:
ns.StopRecording()
ns.EndSession()
ns.disconnect()

# ns.EndSession()
# ns.finalize()


# The contents of this file are in the public domain.
 def send(self,ev):
     ns = self.ns
     timestamp = egi.ms_localtime()
     ns.send_event( ev, label=ev, timestamp=timestamp, table = {'label' : ev, 'timestamp' : timestamp} ) 
ns = egi.Netstation()
ns.connect('11.0.0.42', 55513) # sample address and port -- change according to your network settings
## ns.initialize('11.0.0.42', 55513)
ns.BeginSession()     

ns.sync()     

ns.StartRecording()



# >>> send many events here >>> 

## # optionally can perform additional synchronization     
## ns.sync()     
ns.send_event( 'evt_', label="event", timestamp=egi.ms_localtime(), table = {'fld1' : 123, 'fld2' : "abc", 'fld3' : 0.042} ) 



# >>> we have sent all we wanted, time to go home >>> 

ns.StopRecording()

ns.EndSession()     
ns.disconnect()

## ns.EndSession()     
## ns.finalize()     

# >>> that's it !
示例#11
0
s.setSound("./samples/13.wav")
while True:
	msg.draw()
	win.flip()
	k = event.getKeys()
	if len(k)>0:
		if 'q' in k:
			break
		ns.sync()
		s.play()
		ns.send_event('evt1')
		time.sleep(0.1)
	event.clearEvents()

ns.send_event('evt5', timestamp=egi.ms_localtime())

# for trial in trials:
# 	s.setSound(trial)
# 	while True:
# 		msg.draw()
# 		win.flip()
# 		if len(event.getKeys())>0:
# 			event.clearEvents()
# 			s.play()
# 			break
# 		event.clearEvents()

core.wait(1)
win.close()
示例#12
0
                      'abcd': 1,
                      'efgh': 2
                  },
                  pad=False)
    print "Beep sent at " + str(sent_time)
    diff = log_time - sent_time
    return diff


### Sample 10 incremental pulses sent to Netstation
k = 2
time.sleep(k)
for i in range(0, 5):
    ns.sync()
    #logging.data('auto: ' + str(egi.ms_localtime()))
    print "auto logged at " + str(egi.ms_localtime())
    ns.send_event(key='auto',
                  timestamp=None,
                  description='below is sample table',
                  table={
                      'indx': i,
                      'kinc': k
                  },
                  pad=False)
    autolog.append(egi.ms_localtime())
    print "auto sent at " + str(egi.ms_localtime())
    k += 1
    time.sleep(k)

np.savetxt('autolog.csv', autolog, delimiter=',', fmt='%d')