Пример #1
0
    output_file.write('\n')

def writeDataRow(output_file,session_info,session_uservar_names,event_data):
    """
    Save a row of data to the output file, in tab delimited format. See comment
    for writeOutputFileHeader function for order of saved columns.
    """
    session_data=[str(i) for i in session_info[:-1]]
    session_user_data=[session_info.user_variables[sud_name] for sud_name in session_uservar_names]
    all_data= session_data+session_user_data+[str(e) for e in event_data]+session_user_data
    output_file.write('\t'.join(all_data))
    output_file.write('\n')

if __name__ == '__main__':
    # Select the hdf5 file to process.
    data_file_path= displayDataFileSelectionDialog(psychopy.iohub.module_directory(writeOutputFileHeader))
    if data_file_path is None:
        print("File Selection Cancelled, exiting...")
        sys.exit(0)
    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=[])
import sys
import os
from psychopy.iohub.constants import EventConstants
from psychopy.iohub.datastore.util import displayDataFileSelectionDialog
from psychopy.iohub.datastore.util import ExperimentDataAccessUtility

SAVE_EVENT_TYPE = EventConstants.MONOCULAR_EYE_SAMPLE
SAVE_EVENT_FIELDS = ['time', 'gaze_x', 'gaze_y', 'pupil_measure1', 'status']

#SAVE_EVENT_TYPE = EventConstants.BINOCULAR_EYE_SAMPLE
#SAVE_EVENT_FIELDS = ['time', 'left_gaze_x', 'left_gaze_y', 'left_pupil_measure1',
#                     'right_gaze_x', 'right_gaze_y', 'right_pupil_measure1', 'status']

if __name__ == '__main__':
    # Select the hdf5 file to process.
    data_file_path = displayDataFileSelectionDialog(
        os.path.dirname(os.path.abspath(__file__)))
    if data_file_path is None:
        print("File Selection Cancelled, exiting...")
        sys.exit(0)
    data_file_path = data_file_path[0]
    dpath, dfile = os.path.split(data_file_path)

    datafile = ExperimentDataAccessUtility(dpath, dfile)

    events_by_trial = datafile.getEventAttributeValues(
        SAVE_EVENT_TYPE,
        SAVE_EVENT_FIELDS,
        startConditions={'time': ('>=', '@TRIAL_START@')},
        endConditions={'time': ('<=', '@TRIAL_END@')})

    ecount = 0
Пример #3
0
def writeDataRow(output_file,*args):
    """
    Save a row of data to the output file, in tab delimited format. See comment
    for writeOutputFileHeader function for order of saved columns.
    """
    all_data=[]
    for cvals in args:
        all_data.extend([str(cv) for cv in cvals])
    output_file.write('\t'.join(all_data))
    output_file.write('\n')

if __name__ == '__main__':
    # Select the hdf5 file to process.
    data_file_path= displayDataFileSelectionDialog(
                                        starting_dir=os.path.join(
                                            module_directory(
                                                writeOutputFileHeader),
                                            'results'))
    if data_file_path is None:
        print("File Selection Cancelled, exiting...")
        sys.exit(0)

    dpath,dfile=os.path.split(data_file_path)

    # Lets time how long it takes to read and save to .txt format
    #
    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
Пример #4
0
    for writeOutputFileHeader function for order of saved columns.
    """
    session_data = [str(i) for i in session_info[:-1]]
    session_user_data = [
        session_info.user_variables[sud_name]
        for sud_name in session_uservar_names
    ]
    all_data = session_data + session_user_data + [str(e) for e in event_data
                                                   ] + session_user_data
    output_file.write('\t'.join(all_data))
    output_file.write('\n')


if __name__ == '__main__':
    # Select the hdf5 file to process.
    data_file_path = displayDataFileSelectionDialog(
        psychopy.iohub.module_directory(writeOutputFileHeader))
    if data_file_path is None:
        print("File Selection Cancelled, exiting...")
        sys.exit(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,
Пример #5
0
def writeDataRow(output_file, *args):
    """
    Save a row of data to the output file, in tab delimited format. See comment
    for writeOutputFileHeader function for order of saved columns.
    """
    all_data = []
    for cvals in args:
        all_data.extend([str(cv) for cv in cvals])
    output_file.write('\t'.join(all_data))
    output_file.write('\n')


if __name__ == '__main__':
    # Select the hdf5 file to process.
    data_file_path = displayDataFileSelectionDialog(starting_dir=os.path.join(
        module_directory(writeOutputFileHeader), 'results'))
    if data_file_path is None:
        print("File Selection Cancelled, exiting...")
        sys.exit(0)

    dpath, dfile = os.path.split(data_file_path)

    # Lets time how long it takes to read and save to .txt format
    #
    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,