예제 #1
0
def analyse_excluded(feature_degree):
    positive = []
    negative = []

    positive_button = []
    negative_button = []

    positive_latency = []
    negative_latency = []
    for path in PATHS_DESTIN:
        i = PATHS_DESTIN.index(path)
        if not p[i]['excluded']:
            continue

        data_files = get_data_files(path,
                                    gaze_file_filter=p[i]['gaze_file_filter'])
        info_file = load_yaml_data(data_files[0])
        if not ((info_file['group'] == 'positive') or
                (info_file['group'] == 'negative')):
            continue

        if info_file['feature_degree'] == feature_degree:
            looking_rate, button_rate, latencies = analyse(
                i, inspect=False, data_files=data_files)

            if info_file['group'] == 'positive':
                positive.append(np.array(looking_rate))
                positive_button.append(np.array(button_rate))
                positive_latency.append(np.array(latencies))

            elif info_file['group'] == 'negative':
                negative.append(np.array(looking_rate))
                negative_button.append(np.array(button_rate))
                negative_latency.append(np.array(latencies))
예제 #2
0
def analyse(i, factor='donut_slice', inspect=False, data_files=None):
    print('\nRunning analysis for session:')
    print('\t', PATHS_DESTIN[i])
    print('\t', PATHS_SOURCE[i])
    parameters = p[i]
    if not data_files:
        data_files = get_data_files(
            PATHS_DESTIN[i], gaze_file_filter=parameters['gaze_file_filter'])

    info_file = load_yaml_data(data_files[0])
    ini_file = load_ini_data(data_files[1])
    time_file = load_fpe_timestamps(data_files[2])
    all_gaze_data = load_gaze_data(data_files[3])
    title = ' - '.join([
        '%02d' % i,
        '%02d' % info_file['feature_degree'], info_file['group'],
        info_file['nickname'],
        str(factor)
    ])

    time_data = zip(time_file['time'], time_file['bloc'], time_file['trial'],
                    time_file['event'])
    ini_data = zip(ini_file['trial'], ini_file['contingency'],
                   ini_file['feature'])
    trials = get_events_per_trial(ini_data, time_data)
    responses = get_responses(time_file)
    button_proportion = analyse_button(trials, responses, title, inspect)

    features = ini_file['feature']
    trial_intervals = get_trial_intervals(trials, uncategorized=True)

    gaze_rate_per_trial, gaze_rate_mirror = get_gaze_rate_per_trial(
        trial_intervals,
        all_gaze_data,
        factor=factor,
        inspect=inspect,
        min_block_size=parameters['min_block_size'],
        do_correction=parameters['do_correction'],
        do_remove_outside_screen=parameters['do_remove_outside_screen'],
        do_remove_outside_session_time=parameters[
            'do_remove_outside_session_time'],
        do_manual_correction=parameters['do_manual_correction'],
        do_confidence_threshold=parameters['confidence_threshold'])
    gaze_proportion = get_relative_gaze_rate(ini_file['feature'],
                                             gaze_rate_per_trial,
                                             gaze_rate_mirror)

    # draw.rates([gaze_proportion, []],
    #     title= title,
    #     save= not inspect,
    #     y_label='Looking proportion',
    #     single= True,
    #     first_label= 'feature fp',
    #     y_limit= [-0.1, 1.1],
    #     )

    return gaze_proportion, button_proportion, latency(trials)
예제 #3
0
def analyse_excluded(feature_degree):
    fp_positivex, fp_positivey = [], []
    fp_negativex, fp_negativey = [], []

    fn_positivex, fn_positivey = [], []
    fn_negativex, fn_negativey = [], []

    fp_pdispersion, fp_ndispersion = [], []
    fn_pdispersion, fn_ndispersion = [], []
    a, b = 0, 0
    for path in PATHS_DESTIN:
        i = PATHS_DESTIN.index(path)
        parameters = PARAMETERS[i]
        if not parameters['excluded']:
            continue

        data_files = get_data_files(path,
            gaze_file_filter=parameters['gaze_file_filter'])
        info_file = load_yaml_data(data_files[0])
        if not ((info_file['group'] == 'positive') or (info_file['group'] == 'negative')):
            continue

        if info_file['feature_degree'] == feature_degree:
            gaze, gaze_dispersion = analyse(i, 
                inspect= False,
                data_files= data_files)

            (positive_gaze, negative_gaze) = gaze
            (pdispersion, ndispersion) = gaze_dispersion
            if info_file['group'] == 'positive': 
                a += 1   

            if info_file['group'] == 'negative':
                b += 1

    print('positive:', a)
    print('negative:', b)
예제 #4
0
def analyse_experiment_intrasubject(feature_degree=9, factor='donut_slice'):
    positive_gaze = []
    negative_gaze = []

    positive_button = []
    negative_button = []

    positive_latency = []
    negative_latency = []

    sex = []
    age = []

    preference_xs = []
    preference_sq = []
    preference_na = []

    # no_conditional_discrimination = [
    #     '2017_12_18_001_BRE', '2017_12_15_001_KAR', '2017_12_14_001_JUL',
    #     '2017_12_14_000_TAT', '2017_12_13_004_ANT',
    #     '2017_12_18_000_MAR', '2017_12_13_003_JOE'
    # ]

    for path in PATHS_DESTIN:
        i = PATHS_DESTIN.index(path)
        if p[i]['excluded']:
            continue

        data_files = get_data_files(path,
                                    gaze_file_filter=p[i]['gaze_file_filter'])
        info_file = load_yaml_data(data_files[0])
        if not info_file['group'] == 'fp-square/fn-x':
            continue

        # if info_file['nickname'] in no_conditional_discrimination:
        #     continue

        if info_file['feature_degree'] == feature_degree:
            if cache_exists(info_file['nickname']):
                looking_rate, button_rate, latencies = load_from_cache(
                    info_file['nickname'])
            else:
                button_rate, looking_rate, latencies = analyse_intra_subject(
                    i, factor, inspect=False, data_files=data_files)
                save_to_cache(info_file['nickname'],
                              (looking_rate, button_rate, latencies))
            print(info_file['nickname'])
            (fp_button, fn_button) = button_rate
            (fp_gaze, fn_gaze) = looking_rate
            (fp_latency, fn_latency) = latencies
            positive_button.append(np.array(fp_button))
            negative_button.append(np.array(fn_button))

            positive_gaze.append(np.array(fp_gaze))
            negative_gaze.append(np.array(fn_gaze))

            positive_latency.append(np.array(fp_latency))
            negative_latency.append(np.array(fn_latency))

            sex.append(info_file['sex'])
            age.append(info_file['age'])

            preference_xs.append(info_file['nickname'] + ' ' +
                                 info_file['after_the_fact_preference'])

    print('male: %02d' % sex.count('m'))
    print('fema: %02d' % sex.count('f'))
    print('age min. %.2f, avg. %.2f, max. %.2f' %
          (np.min(age), np.mean(age), np.max(age)))

    print(preference_xs)

    # draw.all_proportions_intra(
    #     gaze_proportion=(positive_gaze, negative_gaze),
    #     button_proportion=(positive_button, negative_button)
    # )

    positive, negative, positive_error, negative_error = statistics(
        positive_button, negative_button, [
            str(feature_degree) + '_intra_button_positive_relative_rate.txt',
            str(feature_degree) + '_intra_button_negative_relative_rate.txt'
        ], True)
    draw.rates(data=[positive, negative],
               error=[positive_error, negative_error],
               title=' - '.join([
                   'average button-pressing proportion', 'intra-subject',
                   'fp %i°' % feature_degree,
                   str(factor)
               ]),
               save=True,
               y_label='Proporção média de R durante S+',
               single=False,
               first_label='Aspecto Positivo',
               second_label='Aspecto Negativo',
               y_limit=[-0.1, 1.1])

    positive, negative, positive_error, negative_error = statistics(
        positive_gaze, negative_gaze, [
            str(feature_degree) + '_intra_gaze_positive_relative_rate.txt',
            str(feature_degree) + '_intra_gaze_negative_relative_rate.txt'
        ], True)
    draw.rates(data=[positive, negative],
               error=[positive_error, negative_error],
               title=' - '.join([
                   'average looking proportion', 'intra-subject',
                   'fp %i°' % feature_degree,
                   str(factor)
               ]),
               save=True,
               y_label='Proporção média de olhar ao estímulo distintivo',
               single=False,
               first_label='Aspecto Positivo',
               second_label='Aspecto Negativo',
               y_limit=[-0.1, 1.1])

    positive, negative, positive_error, negative_error = statistics(
        positive_latency, negative_latency, [
            str(feature_degree) + '_intra_latency_positive_relative_rate.txt',
            str(feature_degree) + '_intra_latency_negative_relative_rate.txt'
        ])
    draw.rates(data=[positive, negative],
               error=[positive_error, negative_error],
               title=' - '.join([
                   'average latency', 'intra-subject',
                   'fp %i°' % feature_degree,
                   str(factor)
               ]),
               save=True,
               y_label='Latência média (s)',
               single=False,
               first_label='Aspecto Positivo',
               second_label='Aspecto Negativo')
예제 #5
0
def analyse_intra_subject(i,
                          factor='donut_slice',
                          inspect=False,
                          data_files=None):
    print('\nRunning analysis for session:')
    print('\t', PATHS_DESTIN[i])
    print('\t', PATHS_SOURCE[i])
    parameters = p[i]
    if not data_files:
        data_files = get_data_files(PATHS_DESTIN[i],
                                    gaze_file_filter=p[i]['gaze_file_filter'])

    info_file = load_yaml_data(data_files[0])
    fp_ini_file, fn_ini_file = load_ini_data_intrasubject(data_files[1])
    time_file = load_fpe_timestamps(data_files[2])

    responses = get_responses(time_file)

    title = ' - '.join(
        ['%02d' % i, info_file['nickname'], 'square (FP)',
         str(factor)])
    time_data = zip(time_file['time'], time_file['bloc'], time_file['trial'],
                    time_file['event'])
    fp_ini_data = zip(fp_ini_file['trial'], fp_ini_file['contingency'],
                      fp_ini_file['feature'])
    fp_trials = get_events_per_trial(fp_ini_data, time_data)
    fp_button_proportion = analyse_button(fp_trials, responses, title)

    title = ' - '.join(
        ['%02d' % i, info_file['nickname'], 'X (FN)',
         str(factor)])
    time_data = zip(time_file['time'], time_file['bloc'], time_file['trial'],
                    time_file['event'])
    fn_ini_data = zip(fn_ini_file['trial'], fn_ini_file['contingency'],
                      fn_ini_file['feature'])
    fn_trials = get_events_per_trial(fn_ini_data, time_data)
    fn_button_proportion = analyse_button(fn_trials, responses, title)

    all_gaze_data = load_gaze_data(data_files[3])
    all_trial_intervals = get_trial_intervals({
        **fp_trials,
        **fn_trials
    },
                                              uncategorized=True)
    gaze_rate_per_trial, gaze_rate_mirror = get_gaze_rate_per_trial(
        all_trial_intervals,
        all_gaze_data,
        factor=factor,
        inspect=False,
        min_block_size=parameters['min_block_size'],
        do_correction=parameters['do_correction'],
        do_remove_outside_screen=parameters['do_remove_outside_screen'],
        do_remove_outside_session_time=parameters[
            'do_remove_outside_session_time'],
        do_manual_correction=parameters['do_manual_correction'],
        do_confidence_threshold=parameters['confidence_threshold'])
    fp_gaze_rate = get_relative_gaze_rate(
        fp_ini_file['feature'], gaze_rate_per_trial[fp_ini_file['trial']],
        gaze_rate_mirror[fp_ini_file['trial']])

    fn_gaze_rate = get_relative_gaze_rate(
        fn_ini_file['feature'], gaze_rate_per_trial[fn_ini_file['trial']],
        gaze_rate_mirror[fn_ini_file['trial']])

    title = ' - '.join(
        ['%02d' % i, info_file['nickname'], 'square(FP)_X(FN)',
         str(factor)])
    draw.rates(
        [fp_gaze_rate, fn_gaze_rate],
        title,
        save=not inspect,
        y_label='Proporção média de olhar estímulo distintivo',
        single=False,
        first_label='Aspecto Positivo',
        second_label='Aspecto Negativo',
        y_limit=[-0.1, 1.1],
    )
    title = ' - '.join([
        '%02d' % i, info_file['nickname'], 'square(FP)_X(FN)',
        str(factor), 'button'
    ])
    draw.rates(
        [fp_button_proportion, fn_button_proportion],
        title,
        save=not inspect,
        y_label='Proporção média de R durante o S+',
        single=False,
        first_label='Aspecto Positivo',
        second_label='Aspecto Negativo',
        y_limit=[-0.1, 1.1],
    )
    latencies = (latency(fp_trials), latency(fn_trials))
    button = (fp_button_proportion, fn_button_proportion)
    gaze = (fp_gaze_rate, fn_gaze_rate)
    return button, gaze, latencies
예제 #6
0
def analyse_experiment(feature_degree, factor):
    positive = []
    negative = []

    positive_button = []
    negative_button = []

    positive_latency = []
    negative_latency = []

    positive_sex = []
    negative_sex = []

    positive_age = []
    negative_age = []

    looking_output = [
        str(feature_degree) + '_looking_positive_relative_rate.txt',
        str(feature_degree) + '_looking_negative_relative_rate.txt'
    ]

    button_output = [
        str(feature_degree) + '_button_positive_relative_rate.txt',
        str(feature_degree) + '_button_negative_relative_rate.txt'
    ]

    latency_output = [
        str(feature_degree) + '_latency_positive_relative_rate.txt',
        str(feature_degree) + '_latency_negative_relative_rate.txt'
    ]

    for path in PATHS_DESTIN:
        i = PATHS_DESTIN.index(path)
        if p[i]['excluded']:
            continue

        data_files = get_data_files(path,
                                    gaze_file_filter=p[i]['gaze_file_filter'])
        info_file = load_yaml_data(data_files[0])
        if not ((info_file['group'] == 'positive') or
                (info_file['group'] == 'negative')):
            continue

        if info_file['feature_degree'] == feature_degree:
            if cache_exists(info_file['nickname']):
                gaze_proportion, button_proportion, latencies = load_from_cache(
                    info_file['nickname'])
            else:
                gaze_proportion, button_proportion, latencies = analyse(
                    i, factor, inspect=False, data_files=data_files)
                save_to_cache(info_file['nickname'],
                              (gaze_proportion, button_proportion, latencies))
            print(info_file['nickname'])
            # draw.rates([button_proportion, gaze_proportion],
            #     title = ' - '.join(['%02d'%i, '%02d'%info_file['feature_degree'], info_file['group'], info_file['nickname'], str(factor)]),
            #     save= True,
            #     y_label='Proporção',
            #     single= False,
            #     first_label= 'Pressionar botão durante S+',
            #     second_label='Olhar estímulo distintivo',
            #     y_limit= [-0.1, 1.1],
            #     )
            if info_file['group'] == 'positive':
                positive_sex.append(info_file['sex'])
                positive_age.append(info_file['age'])
                # wrong size
                if '2017_11_13_000_GAB' in info_file['nickname']:
                    positive.append(np.array(gaze_proportion)[:27])
                    positive_button.append(np.array(button_proportion)[:27])
                    positive_latency.append(np.array(latencies)[:27])
                    continue

                positive.append(np.array(gaze_proportion))
                positive_button.append(np.array(button_proportion))
                positive_latency.append(np.array(latencies))

            elif info_file['group'] == 'negative':
                negative_sex.append(info_file['sex'])
                negative_age.append(info_file['age'])

                negative.append(np.array(gaze_proportion))
                negative_button.append(np.array(button_proportion))
                negative_latency.append(np.array(latencies))

    print('positive male: %02d' % positive_sex.count('m'))
    print('positive fema: %02d' % positive_sex.count('f'))
    print('negative male: %02d' % negative_sex.count('m'))
    print('negative fema: %02d' % negative_sex.count('f'))

    print('positive age min. %.2f, avg. %.2f, max. %.2f' %
          (np.min(positive_age), np.mean(positive_age), np.max(positive_age)))
    print('negative age min. %.2f, avg. %.2f, max. %.2f' %
          (np.min(negative_age), np.mean(negative_age), np.max(negative_age)))

    # draw.all_proportions(
    #     gaze_proportion=(positive, negative),
    #     button_proportion=(positive_button, negative_button),
    #     factor=factor
    # )

    positive, negative, positive_error, negative_error = statistics(
        positive, negative, looking_output, True)
    draw.rates(data=[positive, negative],
               error=[positive_error, negative_error],
               title=' - '.join([
                   'average looking proportion',
                   'fp %i°' % feature_degree,
                   str(factor)
               ]),
               save=True,
               y_label='Proporção média de olhar ao estímulo distintivo',
               single=False,
               first_label='Aspecto Positivo',
               second_label='Aspecto Negativo',
               y_limit=[-0.1, 1.1])

    positive, negative, positive_error, negative_error = statistics(
        positive_button, negative_button, button_output, True)
    draw.rates(data=[positive, negative],
               error=[positive_error, negative_error],
               title=' - '.join([
                   'average button-pressing proportion',
                   'fp %i°' % feature_degree,
                   str(factor)
               ]),
               save=True,
               y_label='Proporção média de R durante o S+',
               single=False,
               first_label='Aspecto Positivo',
               second_label='Aspecto Negativo',
               y_limit=[-0.1, 1.1])

    positive, negative, positive_error, negative_error = statistics(
        positive_latency, negative_latency, latency_output)
    draw.rates(data=[positive, negative],
               error=[positive_error, negative_error],
               title=' - '.join(
                   ['average latency',
                    'fp %i°' % feature_degree,
                    str(factor)]),
               save=True,
               y_label='Latência média (s)',
               single=False,
               first_label='Aspecto Positivo',
               second_label='Aspecto Negativo')
예제 #7
0
def analyse_experiment_intrasubject(feature_degree):
    fp_positivex, fp_positivey = [], []
    fp_negativex, fp_negativey = [], []

    fn_positivex, fn_positivey = [], []
    fn_negativex, fn_negativey = [], []

    fp_pdispersion, fp_ndispersion = [], []
    fn_pdispersion, fn_ndispersion = [], []
    for path in PATHS_DESTIN:
        i = PATHS_DESTIN.index(path)
        parameters = PARAMETERS[i]
        if parameters['excluded']:
            continue

        data_files = get_data_files(path,
            gaze_file_filter=parameters['gaze_file_filter'])
        info_file = load_yaml_data(data_files[0])
        if not info_file['group'] == 'fp-square/fn-x':
            continue
            
        if info_file['feature_degree'] == feature_degree:
            if cache_exists_i(info_file['nickname']):
                gaze, gaze_dispersion = load_from_cache_i(info_file['nickname'])            
            else:
                gaze, gaze_dispersion = analyse_intrasubject(i, inspect= False,data_files= data_files)
                save_to_cache_i(info_file['nickname'],(gaze, gaze_dispersion))
  
            (fp_posgaze, fp_neggaze, fn_posgaze, fn_neggaze) = gaze
            (fp_pdisp, fp_ndisp, fn_pdisp, fn_ndisp) = gaze_dispersion

            fp_positivex.append(fp_posgaze['x_norm'])
            fp_positivey.append(fp_posgaze['y_norm'])

            fp_negativex.append(fp_neggaze['x_norm'])
            fp_negativey.append(fp_neggaze['y_norm'])
            
            fp_pdispersion.append(fp_pdisp)
            fp_ndispersion.append(fp_ndisp)

            fn_positivex.append(fn_posgaze['x_norm'])
            fn_positivey.append(fn_posgaze['y_norm'])

            fn_negativex.append(fn_neggaze['x_norm'])
            fn_negativey.append(fn_neggaze['y_norm'])

            fn_pdispersion.append(fn_pdisp)
            fn_ndispersion.append(fn_ndisp)

    fp_positivex = np.hstack(fp_positivex)
    fp_positivey = np.hstack(fp_positivey)
    fp_negativex = np.hstack(fp_negativex)
    fp_negativey = np.hstack(fp_negativey)

    fn_positivex = np.hstack(fn_positivex)
    fn_positivey = np.hstack(fn_positivey)
    fn_negativex = np.hstack(fn_negativex)
    fn_negativey = np.hstack(fn_negativey)

    dt = {'names':['x_norm', 'y_norm'], 'formats':[np.float64, np.float64]}
    fp_negative = np.zeros(fp_negativex.shape[0], dtype=dt)
    fp_negative['x_norm'] = fp_negativex
    fp_negative['y_norm'] = fp_negativey
    fp_positive = np.zeros(fp_positivex.shape[0], dtype=dt)
    fp_positive['x_norm'] = fp_positivex
    fp_positive['y_norm'] = fp_positivey

    fn_negative = np.zeros(fn_negativex.shape[0], dtype=dt)
    fn_negative['x_norm'] = fn_negativex
    fn_negative['y_norm'] = fn_negativey
    fn_positive = np.zeros(fn_positivex.shape[0], dtype=dt)
    fn_positive['x_norm'] = fn_positivex
    fn_positive['y_norm'] = fn_positivey

    # np.savetxt('positive%i.txt'%feature_degree, positive)
    # np.savetxt('negative%i.txt'%feature_degree, negative)

    d1, d2, e1, e2 = statistics(fp_pdispersion, fp_ndispersion)
    d3, d4, e3, e4 = statistics(fn_pdispersion, fn_ndispersion)

    labels = [
        'Média do desvio padrão do ângulo de visão (RMS)',
        'Tentativas',
        'AP',
        'AN',
        'distintivo',
        'comum'
    ]
    draw.rates_double(
        (d1, d4, d2, d3),
        (e1, e4, e2, e3),
        title= 'comparing FP and FN looking dispersion - '+str(feature_degree)+'_intra',
        labels= labels,
        y_limit=[6., 16.]
    )
예제 #8
0
def analyse_intrasubject(i, inspect=False, data_files=None):
    parameters = PARAMETERS[i]
    print('\nRunning analysis for session:')
    print('\t', PATHS_DESTIN[i])
    print('\t', PATHS_SOURCE[i])
    if not data_files:
        data_files = get_data_files(PATHS_DESTIN[i],
            gaze_file_filter=parameters['gaze_file_filter'])
          
    info_file = load_yaml_data(data_files[0])
    fp_ini_file, fn_ini_file = load_ini_data_intrasubject(data_files[1])
    time_file = load_fpe_timestamps(data_files[2])
    all_gaze_data = load_gaze_data(data_files[3])

    time_data = zip(time_file['time'], time_file['bloc'], time_file['trial'], time_file['event'])
    fp_ini_data = zip(fp_ini_file['trial'], fp_ini_file['contingency'], fp_ini_file['feature'])
    fp_trials = get_events_per_trial(fp_ini_data, time_data)
    
    time_data = zip(time_file['time'], time_file['bloc'], time_file['trial'], time_file['event'])
    fn_ini_data = zip(fn_ini_file['trial'], fn_ini_file['contingency'], fn_ini_file['feature'])
    fn_trials = get_events_per_trial(fn_ini_data, time_data)    

    fp_positive_intervals, fp_negative_intervals = get_trial_intervals(fp_trials)
    fn_positive_intervals, fn_negative_intervals = get_trial_intervals(fn_trials)


    title = ' - '.join(('%02d'%i, str(info_file['feature_degree']), info_file['nickname'], 'FP'))
    titlea = title + '_fp_positive'
    titleb = title + '_fp_negative'

    title = ' - '.join(('%02d'%i, str(info_file['feature_degree']), info_file['nickname'], 'FN'))
    titlec = title + '_fn_positive'
    titled = title + '_fn_negative'

    all_gaze_data = load_gaze_data(data_files[3])
    all_trial_intervals = get_trial_intervals({**fp_trials, **fn_trials}, uncategorized=True)   
    all_gaze_data = clean_gaze_data(all_gaze_data, 
        do_remove_outside_session_time=all_trial_intervals,        
        do_correction=parameters['do_correction'],
        do_remove_outside_screen=parameters['do_remove_outside_screen'],
        do_manual_correction=parameters['do_manual_correction'],
        do_confidence_threshold=parameters['confidence_threshold'],
        min_block_size=parameters['min_block_size'],
        inspect=False)

    mask = remove_outside_session_time(all_gaze_data['time'], fp_positive_intervals)
    fp_positive_gaze_data = all_gaze_data[mask]      
    fp_pdispersion = dispersion(fp_positive_gaze_data, fp_positive_intervals, titlea)

    mask = remove_outside_session_time(all_gaze_data['time'], fp_negative_intervals)
    fp_negative_gaze_data = all_gaze_data[mask]        
    fp_ndispersion = dispersion(fp_negative_gaze_data, fp_negative_intervals, titleb)

    mask = remove_outside_session_time(all_gaze_data['time'], fn_positive_intervals)
    fn_positive_gaze_data = all_gaze_data[mask]
    fn_pdispersion = dispersion(fn_positive_gaze_data, fn_positive_intervals, titlec)

    mask = remove_outside_session_time(all_gaze_data['time'], fn_negative_intervals)
    fn_negative_gaze_data = all_gaze_data[mask]
    fn_ndispersion = dispersion(fn_negative_gaze_data, fn_negative_intervals, titled)

    # title = ' - '.join(('%02d'%i, str(info_file['feature_degree']), info_file['nickname'], 'distinctive'))
    # draw.rates(
    #     [fp_pdispersion, fn_pdispersion],
    #     title= title+'_pdispersion',
    #     save= not inspect,
    #     y_label='Graus do ângulo de visão (RMS)',
    #     single=False,
    #     first_label='AP',
    #     second_label='AN',
    #     y_limit= [1., 15.]       
    # )

    # title = ' - '.join(('%02d'%i, str(info_file['feature_degree']), info_file['nickname'], 'common'))   
    # draw.rates(
    #     [fp_ndispersion, fn_ndispersion],
    #     title= title+'_ndispersion',
    #     save= not inspect,
    #     y_label='Graus do ângulo de visão (RMS)',
    #     single=False,
    #     first_label='AP',
    #     second_label='AN',
    #     y_limit= [1., 15.]       
    # )

    # title = ' - '.join(('heat', '%02d'%i, str(info_file['feature_degree']), info_file['nickname'], 'distinctive-common'))   
    # imgs, y_max = custom_heatmap([fp_positive_gaze_data,fn_negative_gaze_data,
    #                        fp_negative_gaze_data,fn_positive_gaze_data])
    # scale_path = heatmap_scale(size=368., title= title, y_max= y_max)
    # plot_path = draw.images_four(
    #     imgs,
    #     title=title,
    #     save= not inspect)
    
    # draw.join_images(plot_path, scale_path)

    gaze = (fp_positive_gaze_data, fp_negative_gaze_data, fn_positive_gaze_data, fn_negative_gaze_data)
    disp = (fp_pdispersion, fp_ndispersion, fn_pdispersion, fn_ndispersion)
    return gaze, disp
예제 #9
0
def analyse(i, inspect=False, data_files=None):
    parameters = PARAMETERS[i]
    print('\nRunning analysis for session:')
    print('\t', PATHS_DESTIN[i])
    print('\t', PATHS_SOURCE[i])
    if not data_files:
        data_files = get_data_files(PATHS_DESTIN[i],
            gaze_file_filter=parameters['gaze_file_filter'])
          
    info_file = load_yaml_data(data_files[0])
    ini_file = load_ini_data(data_files[1])
    time_file = load_fpe_timestamps(data_files[2])
    all_gaze_data = load_gaze_data(data_files[3])

    title = ' - '.join(('%02d'%i, str(info_file['feature_degree']), info_file['nickname'], info_file['group']))

    time_data = zip(time_file['time'], time_file['bloc'], time_file['trial'], time_file['event'])
    ini_data = zip(ini_file['trial'], ini_file['contingency'], ini_file['feature'])
    trials = get_events_per_trial(ini_data, time_data)
    positive_intervals, negative_intervals = get_trial_intervals(trials)
    # trial_intervals = get_trial_intervals(trials, uncategorized=True)  

    titlea = title + '_positive'
    titleb = title + '_negative'

    positive_gaze_data = clean_gaze_data(all_gaze_data, 
        do_remove_outside_session_time=positive_intervals,        
        do_correction=parameters['do_correction'],
        do_remove_outside_screen=parameters['do_remove_outside_screen'],
        do_manual_correction=parameters['do_manual_correction'],
        do_confidence_threshold=parameters['confidence_threshold'],
        min_block_size=parameters['min_block_size'],
        inspect=False)
    pdispersion = dispersion(positive_gaze_data, positive_intervals, titlea)

    negative_gaze_data = clean_gaze_data(all_gaze_data, 
        do_remove_outside_session_time=negative_intervals,        
        do_correction=parameters['do_correction'],
        do_remove_outside_screen=parameters['do_remove_outside_screen'],
        do_manual_correction=parameters['do_manual_correction'],
        do_confidence_threshold=parameters['confidence_threshold'],
        min_block_size=parameters['min_block_size'],
        inspect=False)
    ndispersion = dispersion(negative_gaze_data, negative_intervals, titleb)

    # draw.rates(
    #     [pdispersion, ndispersion],
    #     title= title+'_dispersion',
    #     save= not inspect,
    #     y_label='2d dispersion (RMS) in deggres of visual angle',
    #     single=False,
    #     first_label='S+',
    #     second_label='S-',
    #     y_limit= [1., 15.]       
    # )
    # title = ' - '.join(('heat', '%02d'%i, str(info_file['feature_degree']), info_file['group'], info_file['nickname'], 'S+ S-')) 
    # imgs, y_max = custom_heatmap([positive_gaze_data, negative_gaze_data])
    # scale_path = heatmap_scale(size=371., title= title, y_max= y_max)
    # plot_path = draw.images(
    #     imgs,
    #     (sw, sh),
    #     save=not inspect,
    #     title=title)

    # draw.join_images(plot_path, scale_path)

    return (positive_gaze_data, negative_gaze_data), (pdispersion, ndispersion)