data_file_path = data_file_path[0] dpath,dfile=os.path.split(data_file_path) # Lets time how long processing takes # start_time=getTime() # 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, as well # as access the experiment session metadata saved with each session run. dataAccessUtil=ExperimentDataAccessUtility(dpath,dfile, experimentCode=None,sessionCodes=[]) # Get a dict of all event types -> DataStore table info # for the selected DataStore file. eventTableMappings=dataAccessUtil.getEventMappingInformation() # Get event tables that have data... # events_with_data=dataAccessUtil.getEventsByType() duration=getTime()-start_time # Select which event table to output by displaying a list of # Event Class Names that have data available to the user... event_class_selection=displayEventTableSelectionDialog("Select Event Type to Save", "Event Type:", [eventTableMappings[event_id].class_name.decode('utf-8') for event_id in list(events_with_data.keys())]) if event_class_selection is None: print("Event table Selection Cancelled, exiting...") dataAccessUtil.close() sys.exit(0)
def convertToText(self, dir, name, localtime): # Select the hdf5 file to process. #data_file_path= displayDataFileSelectionDialog(psychopy.iohub.module_directory(writeOutputFileHeader)) print(' this is dir') print(dir) data_file_path = dir + '\events.hdf5' if data_file_path is None: print("File Selection Cancelled, exiting...") sys.exit(0) dpath, dfile = os.path.split(data_file_path) print('dpath') print(dpath) print('dfile') print(dfile) # Lets time how long processing takes # start_time = getTime() # 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, as well # as access the experiment session metadata saved with each session run. dataAccessUtil = ExperimentDataAccessUtility(dpath, dfile, experimentCode=None, sessionCodes=[]) print('this is dataaccessutil:') print(dataAccessUtil) # Get a dict of all event types -> DataStore table info # for the selected DataStore file. eventTableMappings = dataAccessUtil.getEventMappingInformation() # Get event tables that have data... # events_with_data = dataAccessUtil.getEventsByType() duration = getTime() - start_time # Select which event table to output by displaying a list of # Event Class Names that have data available to the user... #event_class_selection=displayEventTableSelectionDialog("Select Event Type to Save", "Event Type:", # [eventTableMappings[event_id].class_name for event_id in events_with_data.keys()]) event_class_selection = 'BinocularEyeSampleEvent' print('event_class_selection') print(event_class_selection) if event_class_selection == None: print("Event table Selection Cancelled, exiting...") dataAccessUtil.close() sys.exit(0) # restart processing time calculation... # start_time = getTime() # Lookup the correct event iterator fiven the event class name selected. # event_iterator_for_output = [] for event_id, mapping_info in eventTableMappings.items(): if mapping_info.class_name == event_class_selection: event_iterator_for_output = events_with_data[event_id] break # Read the session metadata table for all sessions saved to the file. # session_metadata = dataAccessUtil.getSessionMetaData() print('this is dataaccessutil getsession metadata') print(session_metadata) sesion_meta_data_dict = dict() # Create a session_id -> session metadata mapping for use during # file writing. # session_metadata_columns = [] if len(session_metadata): session_metadata_columns = list(session_metadata[0]._fields[:-1]) session_uservar_columns = list( session_metadata[0].user_variables.keys()) for s in session_metadata: sesion_meta_data_dict[s.session_id] = s # Open a file to save the tab delimited ouput to. # #log_file_name="%s.%s.txt"%(dfile[:-5],event_class_selection) log_file_name = name + '_EyeSample' + localtime + '.txt' with open(dir + '\\Exp Results\\' + log_file_name, 'w') as output_file: # write column header # writeOutputFileHeader( output_file, session_metadata_columns, dataAccessUtil.getEventTable( event_class_selection).cols._v_colnames[3:]) print('Writing Data to %s:\n' % (dir + log_file_name)), i = 0 for i, event in enumerate(event_iterator_for_output): # write out each row of the event data with session # data as prepended columns..... # writeDataRow(output_file, sesion_meta_data_dict[event['session_id']], session_uservar_columns, event[:][3:]) if i % 100 == 0: print('.'), duration = duration + (getTime() - start_time) #print print( '\nOutput Complete. %d Events Saved to %s in %.3f seconds (%.2f events/seconds).\n' % (i, log_file_name, duration, i / duration)) print('%s will be in the same directory as the selected .hdf5 file' % (log_file_name))
# Lets time how long processing takes # start_time = getTime() # 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, as well # as access the experiment session metadata saved with each session run. dataAccessUtil = ExperimentDataAccessUtility(dpath, dfile, experimentCode=None, sessionCodes=[]) # Get a dict of all event types -> DataStore table info # for the selected DataStore file. eventTableMappings = dataAccessUtil.getEventMappingInformation() # Get event tables that have data... # events_with_data = dataAccessUtil.getEventsByType() duration = getTime() - start_time # Select which event table to output by displaying a list of # Event Class Names that have data available to the user... event_class_selection = displayEventTableSelectionDialog( "Select Event Type to Save", "Event Type:", [ eventTableMappings[event_id].class_name for event_id in list(events_with_data.keys()) ]) if event_class_selection is None: