Home > data-import > gaze > preprocess_gather_eye_var_stats.m

preprocess_gather_eye_var_stats

PURPOSE ^

SYNOPSIS ^

function [sub_list_has_var, range_w, range_h] = preprocess_gather_eye_var_stats(exp_id, agent)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [sub_list_has_var, range_w, range_h] = preprocess_gather_eye_var_stats(exp_id, agent)
0002 
0003 sub_list = list_subjects(exp_id);
0004 
0005 var_name_eye_x = ['cont_eye_x_' agent];
0006 var_name_eye_y = ['cont_eye_y_' agent];
0007 var_name_eye_xy = ['cont2_eye_xy_' agent];
0008 has_all_eye_vars = false(length(sub_list), 1);
0009 
0010 var_data_eye_x = cell(length(sub_list), 1);
0011 var_data_eye_y = cell(length(sub_list), 1);
0012 is_xy2_match_xy = false(length(sub_list), 1);
0013 
0014 for sidx = 1:length(sub_list)
0015 % sidx = 2;
0016     sub_id = sub_list(sidx);
0017     
0018     has_all_vars = true;
0019     
0020     if ~has_variable(sub_id, var_name_eye_x)
0021         has_all_vars = false;
0022         fprintf('\n%s does not exist for sub %d\n', var_name_eye_x, sub_id);
0023     end
0024     
0025     if ~has_variable(sub_id, var_name_eye_y)
0026         has_all_vars = false;
0027         fprintf('\n%s does not exist for sub %d\n', var_name_eye_y, sub_id);
0028     end
0029     
0030     if ~has_variable(sub_id, var_name_eye_xy)
0031         has_all_vars = false;
0032         fprintf('\n%s does not exist for sub %d\n', var_name_eye_xy, sub_id);
0033     end
0034     
0035     if has_all_vars
0036         has_all_eye_vars(sidx) = true;
0037         
0038         data_x_one = get_variable(sub_id, var_name_eye_x);
0039         data_y_one = get_variable(sub_id, var_name_eye_y);
0040         data_xy_one = get_variable(sub_id, var_name_eye_xy);
0041 
0042     %     is_match_one = true;
0043 
0044         mask_match_x = data_x_one(:,2) == data_xy_one(:,2);
0045         mask_match_y = data_y_one(:,2) == data_xy_one(:,3);
0046         is_match_x = (sum(mask_match_x) + sum(isnan(data_x_one(:,2) ))) == length(mask_match_x);
0047         is_match_y = (sum(mask_match_y) + sum(isnan(data_y_one(:,2) ))) == length(mask_match_y);
0048         if is_match_x && is_match_y
0049             is_xy2_match_xy(sidx) = true;
0050         else
0051             fprintf('\neye xy data doesnot match x y data sub %d\n', sub_id);
0052         end
0053         
0054         if max(data_x_one(:,2)) <= 640
0055             fprintf('\ncont2_eye_x <= 640 %d\n', sub_id);
0056         end
0057 
0058         var_data_eye_x{sidx} = data_x_one;
0059         var_data_eye_y{sidx} = data_y_one;
0060     end
0061 end
0062 
0063 var_data_eye_x = var_data_eye_x(has_all_eye_vars);
0064 var_data_eye_y = var_data_eye_y(has_all_eye_vars);
0065 
0066 results_x = cont_cal_stats(var_data_eye_x);
0067 results_y = cont_cal_stats(var_data_eye_y);
0068 
0069 sub_list_has_var = sub_list(has_all_eye_vars);
0070 range_w = [results_x.individual_min results_x.individual_max];
0071 range_h = [results_y.individual_min results_y.individual_max];

Generated on Tue 23-May-2017 20:00:55 by m2html © 2005