本文整理汇总了Python中psychopy.iohub.EventConstants.getName方法的典型用法代码示例。如果您正苦于以下问题:Python EventConstants.getName方法的具体用法?Python EventConstants.getName怎么用?Python EventConstants.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psychopy.iohub.EventConstants
的用法示例。
在下文中一共展示了EventConstants.getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: printEventTypesWithDataDemo
# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getName [as 别名]
def printEventTypesWithDataDemo():
# Create an instance of the ExperimentDataAccessUtility class
# for the selected DataStore file. This allows us to access data
# in the file based on Device Event names and attributes.
#
experiment_data=ExperimentDataAccessUtility('..\hdf5_files' , 'events.hdf5')
# Get any event tables that have >=1 event saved in them
#
events_by_type=experiment_data.getEventsByType()
# print out info on each table
#
for event_id, event_gen in events_by_type.iteritems():
event_constant=EventConstants.getName(event_id)
print "{0} ({1}): {2}".format(event_constant,event_gen.table.nrows,event_gen)
# Close the HDF5 File
#
experiment_data.close()
示例2: _processDeviceEventIteration
# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getName [as 别名]
def _processDeviceEventIteration(self):
for device in self.devices:
try:
events=device._getNativeEventBuffer()
#if events and len(events)>0:
# ioHub.print2err("_processDeviceEventIteration.....", device._event_listeners)
while len(events)>0:
evt=events.popleft()
e=device._getIOHubEventObject(evt)
if e is not None:
for l in device._getEventListeners(e[DeviceEvent.EVENT_TYPE_ID_INDEX]):
l._handleEvent(e)
except:
printExceptionDetailsToStdErr()
print2err("Error in processDeviceEvents: ", device, " : ", len(events), " : ", e)
print2err("Event type ID: ",e[DeviceEvent.EVENT_TYPE_ID_INDEX], " : " , EventConstants.getName(e[DeviceEvent.EVENT_TYPE_ID_INDEX]))
print2err("--------------------------------------")
示例3: _processDeviceEventIteration
# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getName [as 别名]
def _processDeviceEventIteration(self):
for device in self.devices:
try:
events = device._getNativeEventBuffer()
while len(events) > 0:
evt = events.popleft()
e = device._getIOHubEventObject(evt)
if e is not None:
for l in device._getEventListeners(e[DeviceEvent.EVENT_TYPE_ID_INDEX]):
l._handleEvent(e)
filtered_events = []
for filter in device._filters.values():
filtered_events.extend(filter._removeOutputEvents())
for i in range(len(filtered_events)):
e = filtered_events[i]
for l in device._getEventListeners(e[DeviceEvent.EVENT_TYPE_ID_INDEX]):
l._handleEvent(e)
except:
printExceptionDetailsToStdErr()
print2err("Error in processDeviceEvents: ", device, " : ", len(events), " : ", e)
print2err("Event type ID: ",e[DeviceEvent.EVENT_TYPE_ID_INDEX], " : " , EventConstants.getName(e[DeviceEvent.EVENT_TYPE_ID_INDEX]))
print2err("--------------------------------------")
示例4: clearEvents
# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getName [as 别名]
# Redraw stim and window flip...
#
[s.draw() for s in STIM_LIST]
flip_time=window.flip()
# Update text fields based on all Keyboard Event types that have occurred
# since the last call to getEvents of clearEvents(). This means that the most
# recent event in the list of a given event type is what you will see.
#
for event in keyboard.getEvents():
key_text_stim.setText(event.key)
ucode_stim.setText('{0:#06x} = {1}'.format(event.ucode,unichr(event.ucode)))
modifiers_stim.setText(str(event.modifiers))
if event.type == EventConstants.KEYBOARD_CHAR:
keypress_duration_stim.setText("%.6f"%(event.duration))
event_type_stim.setText(EventConstants.getName(event.type))
if event.key.lower()=='q' and ('CONTROL_LEFT' in event.modifiers or 'CONTROL_LEFT' in event.modifiers):
QUIT_EXP=True
break
# Send a message to the iohub with the message text that a flip
# occurred and what the mouse position was. Since we know the
# psychopy-iohub time the flip occurred on, we can set that directly
# in the event.
#self.hub.sendMessageEvent("Flip %s"%(str(currentPosition),), sec_time=flip_time)
# Done demo loop, cleanup explicitly
#
io.quit()
示例5: dict
# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getName [as 别名]
import os
from common import openDataStoreReader, Picker
import numpy as np
SESSION_PATH = r'..\..\Results\Default_Experiment\s1'
FRAME_EVENT_FILE = r'session_vframe_events.npz'
FILTERS = dict(event_type=[EventConstants.MONOCULAR_EYE_SAMPLE,], video_id=[0,], filter_id=[23,])
BATCH_SIZE = 100
def getEventDetails(session_path, frame_event_lookup_file, filters, batch_size):
session_folder = os.path.normpath(os.path.abspath(session_path))
datastore_reader = openDataStoreReader(session_folder)
frame_events_lookup = np.load(os.path.join(session_folder, frame_event_lookup_file))['events']
event_types = filters.get('event_type', np.unique(frame_events_lookup['event_type']))
for etype in event_types:
filters['event_type'] = [etype,]
filtered_table_rows = Picker(frame_events_lookup).pick_data('event_table_row_index', **filters)
event_table = datastore_reader.getEventTable(etype)
while len(filtered_table_rows) > 0:
row_nums = [int(i) for i in filtered_table_rows[:batch_size]]
yield event_table[row_nums]
filtered_table_rows = filtered_table_rows[batch_size:]
datastore_reader.close()
if __name__ == '__main__':
for event_details_batch in getEventDetails(SESSION_PATH, FRAME_EVENT_FILE, FILTERS, BATCH_SIZE):
for event in event_details_batch:
print EventConstants.getName(event['type']), event['time'], event['filter_id']