Home > data-import > make_gaze_to_center.m

make_gaze_to_center

PURPOSE ^

finds the centroid of a cluster of gaze data points, and then calcuates

SYNOPSIS ^

function make_gaze_to_center(subexpID, corp)

DESCRIPTION ^

finds the centroid of  a cluster of gaze data points, and then calcuates
the distance from that center to each data point.
subexpID can be a subject list for experiment list
corp is [1 2] or [1] or [2] where 1 is child and 2 is parent
maxx is x resolution, default is 720
maxy is y resolution, default is 480

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function make_gaze_to_center(subexpID, corp)
0002 %finds the centroid of  a cluster of gaze data points, and then calcuates
0003 %the distance from that center to each data point.
0004 %subexpID can be a subject list for experiment list
0005 %corp is [1 2] or [1] or [2] where 1 is child and 2 is parent
0006 %maxx is x resolution, default is 720
0007 %maxy is y resolution, default is 480
0008 
0009 person = {'child' 'parent'};
0010 
0011 if numel(num2str(subexpID(1))) > 2
0012     subs = subexpID;
0013 elseif numel(num2str(subexpID(1))) == 2
0014     subs = list_subjects(subexpID);
0015 end
0016 
0017 %uncommenting these will override any subexpID input
0018 %subs = [3201 3203 3204 3205 3206 3207 3208 3210 3211 3212 3213 ...
0019 %            3214 3215 3216 3217 3218]'; % 32 child
0020 %subs = [3201 3203 3204 3205 3206 3207 3208 3210 3212 3213 ...
0021 %           3214 3215 3216 3218]; % 32 parent
0022 %subs = [3403 3404 3405  3409 3410 3413 ...
0023 %            3414 3415 3416 3417]'; % 34 child
0024 % subs = [3401 3402 3404 3406 3407 3408 3409 3410 3413 ...
0025 %             3414 3415 3416 3417 3418]'; % 34 parent
0026                                         %sub_list = 3402;
0027 
0028 for s = 1:numel(subs)
0029     for p = 1:numel(corp)
0030         personID = person{corp(p)};
0031         if has_variable(subs(s), ['cont_eye_x_' personID]);
0032             chunks_x = get_variable_by_trial(subs(s), ['cont_eye_x_' personID]);
0033             chunks_y = get_variable_by_trial(subs(s), ['cont_eye_y_' personID]);
0034             
0035             new_data = [];
0036             if ~isempty(chunks_x) && ~isempty(chunks_y)
0037                 cont_x =  cat(1, chunks_x{:});
0038                 cont_y =  cat(1, chunks_y{:});
0039                 new_data(:,1) = cont_x(:,1);
0040                 
0041                 center_x = nanmedian(cont_x);
0042                 center_y = nanmedian(cont_y);
0043 %                 [center_x(:,2) center_y(:,2)]
0044                 data = [cont_x(:,2) cont_y(:,2)];
0045                 new_data(:,2) = distances(data, [center_x(:,2) center_y(:,2)]);
0046 %                 size(new_data);
0047 %                 nanmedian(new_data(:,2));
0048                 
0049                 % generate a new variable
0050                 file_name = sprintf('cont_eye_dist-to-center_%s', personID);
0051                 record_variable(subs(s),file_name,new_data);
0052             end
0053         else
0054             fprintf('Subject %d did not have the "cont_eye_x_%s" variable\n', subs(s), personID)
0055         end
0056     end
0057 end
0058 
0059 end

Generated on Tue 23-May-2017 02:00:59 by m2html © 2005