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)
def analyse_button(trials, responses, title, inspect=False): positive_intervals, negative_intervals = get_trial_intervals(trials) button_rate_positive = rate_in(positive_intervals, responses) button_rate_negative = rate_in(negative_intervals, responses) button_relative_rate = relative_rate_from(button_rate_positive, button_rate_negative) # draw.rates([button_rate_positive, button_rate_negative], # title= title+'_absolute', # save= not inspect, # first_label='S+', # second_label='S-', # y_label= 'Button-pressing per seconds' # ) # draw.rates([button_relative_rate, []], # title= title+'_relative', # save= not inspect, # y_label='Button-pressing proportion', # single= True, # y_limit= [-0.1, 1.1], # ) return button_relative_rate
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
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
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)