part_name = []

    for folder in folders:

        part_name.append(folder[1:])

    #Variable where the number of trials that have at least a percentage of valid data are stored:
    #0 - Participant
    #1-5:  40, 60, 80, 90
    #Number of trials with more than: 40, 60, 80 and 90% of valid samples.
    number_trials_valid_data = np.zeros((len(part_name), 5), dtype=float)

    for j, participant in enumerate(folders):
        print "participant", participant
        part_path = main_path + sep + participant
        onset_file_name = find_files(part_path, 'onset_stimuli')
        gaze_data_name = find_files(part_path, 'GazeData')

        #Raise exception and continue with the next participant if the file is not in the folder
        if onset_file_name == '':
            print "the participant " + participant + "does not have the onset_video file required"
            number_trials_valid_data[j] = -1
            continue

        if gaze_data_name == '':
            print "the participant " + participant + "does not have the gaze_data file required"
            number_trials_valid_data[j] = -1
            continue

        if len(onset_file_name) > 1:
            print 'More than one onset file for participant ' + str(
Exemplo n.º 2
0
f = open(results_path + sep + 'percentage_data.txt', 'w')
f.write('Participant' + '\t' + 'Perc valid' + '\t' + 'Perc inside' + '\t' +
        'Perc outside' + '\t' + 'Perc outliers'
        '\t' + 'Perc valid video' + '\t'
        'Perc inside video' + '\t' + 'Perc outside video' + '\t' +
        'Perc outliers video' + '\t' + 'Per valid erp' + '\t' +
        'Perc inside erp' + '\t' + 'Perc outside erp' + '\t' +
        'Perc outliers erp' + '\n')
folders = listdir(main_path)
part_name = []
percentage_data = np.zeros((len(part_name), 6), dtype=float)

for j, participant in enumerate(folders):
    print "participant", participant
    part_path = main_path + sep + participant
    onset_file_name = find_files(part_path, 'onset_stimuli')
    onset_video_name = find_files(part_path, 'onset_video', '.txt')
    gaze_data_name = find_files(part_path, 'GazeData')

    #Raise exception and continue with the next participant if the file is not in the folder
    if onset_file_name == '':
        print "the participant " + participant + "does not have the onset_video file required"
        percentage_data[j] = -1
        continue

    if gaze_data_name == '':
        print "the participant " + participant + "does not have the gaze_data file required"
        percentage_data[j] = -1
        continue

    if len(onset_file_name) > 1:
Exemplo n.º 3
0
def load_indexes(path, file_starts):
    in_file = find_files(path, file_starts)
    return np.loadtxt(path + sep + in_file[0], delimiter='\t', skiprows=1)
Exemplo n.º 4
0
def load_et_data(path, file_starts):
    gd_file = find_files(path, file_starts)
    return open_gaze_data(path + sep + gd_file[0])
        ''' Participant info'''
        print participant
        part_path = general_path + os.sep + participant
        f = open(part_path + os.sep + participant + '_new_eeg_video_events.txt', 'w')


        #Calculate A or B sequence
        cond = calculate_condition(participant)
        if cond:
            print 'Condition B'
        else:
            print 'Condition A'

        ''' Load Files '''
        #EEG events
        eeg_events_path = part_path + os.sep + find_files(part_path, 'CM_', '.txt')[0]
        eeg_all_events = np.loadtxt(eeg_events_path, dtype=np.dtype([('event', (np.str, 20)), ('timestamp', np.int)]))
        eeg_events = []
        eeg_times = []
        for event in eeg_all_events:
            if event['event'].startswith('v'):
                eeg_events.append(event['event'])
                eeg_times.append(event['timestamp'])
        #et events
        et_events_path = part_path + os.sep + find_files(part_path, 'onset_video', 'txt')[0]
        et_events = np.loadtxt(et_events_path, dtype=np.dtype([('video', np.float_), ('timestamp', np.float_)]))

        ''' split events in videos '''
        #Videos order
        video_order = unique_values(et_events['video'])
        #ET events split
Exemplo n.º 6
0
def load_indexes(path, file_starts):
    in_file = find_files(path, file_starts)
    return np.loadtxt(path + sep + in_file[0], delimiter='\t', skiprows=1)
Exemplo n.º 7
0
def load_et_data(path, file_starts):
    gd_file = find_files(path, file_starts)
    return open_gaze_data(path + sep + gd_file[0])