Home > data-import > make_vision_joint_obj_size_dist.m

make_vision_joint_obj_size_dist

PURPOSE ^

finds moments when child and parent are both looking at the largest object

SYNOPSIS ^

function test = make_vision_joint_obj_size_dist(IDs)

DESCRIPTION ^

finds moments when child and parent are both looking at the largest object
in both views as well as most centered object in both views
subexpID is list of experiments or subjects

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function test = make_vision_joint_obj_size_dist(IDs)
0002 %finds moments when child and parent are both looking at the largest object
0003 %in both views as well as most centered object in both views
0004 %subexpID is list of experiments or subjects
0005 
0006 subs = cIDs(IDs);
0007 
0008 %keep the order of these names
0009 variable_list = {'cont_vision_size' 'cont_vision_min-dist'};
0010 rec_var_names = {'cstream_vision_joint-obj-size_both' 'cstream_vision_joint-obj-dist_both'};
0011 
0012 %all data goes into test structure that will be returned by function
0013 test = cell(1,numel(subs)*numel(variable_list));
0014 for s = 1:numel(subs)
0015     for v = 1: numel(variable_list)
0016         all_data_c = [];
0017         all_data_p = [];
0018         for o = 1:5
0019             varname_c = sprintf('%s_obj%d_child', variable_list{v}, o);
0020             varname_p = sprintf('%s_obj%d_parent', variable_list{v}, o);
0021             if has_variable(subs(s), varname_c) && has_variable(subs(s), varname_p)
0022                 data_c = get_variable(subs(s), varname_c);
0023                 data_p = get_variable(subs(s), varname_p);
0024                 %check cstream alignment
0025                 if size(data_c, 1) ~= size(data_p, 1)
0026                     %convert to cevent then back to cstream
0027                     p_cev = cstream2cevent(data_p);
0028                     data_p = cevent2cstream_v2(p_cev, 1, [1 2], data_c(:,1));
0029                 end
0030                 if o == 1
0031                     all_data_c = data_c;
0032                     all_data_p = data_p;
0033                 else
0034                     all_data_c = cat(2, all_data_c, data_c(:,2));
0035                     all_data_p = cat(2, all_data_p, data_p(:,2));
0036                 end
0037             end
0038         end
0039         if ~isempty(all_data_c) && ~isempty(all_data_p)
0040             if ~isempty(strfind(varname_c, 'min'))
0041                 [~, index_c] = min(all_data_c(:,2:end), [], 2);
0042                 [~, index_p] = min(all_data_p(:,2:end), [], 2);
0043             else
0044                 [~, index_c] = max(all_data_c(:,2:end), [], 2);
0045                 [~, index_p] = max(all_data_p(:,2:end), [], 2);
0046             end
0047             log = sum(all_data_c(:,2:end),2) == 0;
0048             index_c(log) = 0;
0049             log = sum(all_data_p(:,2:end),2) == 0;
0050             index_p(log) = 0;
0051             combined = [index_c index_p]; %tests cstream alignment, error if not aligned
0052             same = index_c ~= index_p;
0053             combined(same,1) = 0;
0054             log = index_c == 0;
0055             combined(log,1) = 0;
0056             recdata = [all_data_c(:,1) combined(:,1)];
0057             test{(s-1)*numel(variable_list) + v} = recdata;
0058             recname = rec_var_names{v};
0059             record_variable(subs(s), recname, recdata);
0060             %convert to cevent
0061             recdata = cstream2cevent(recdata);
0062             recname = strrep(recname, 'cstream', 'cevent');
0063             record_variable(subs(s), recname, recdata);
0064         end
0065     end
0066 end
0067 end

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