Home > data-import > make_vision_inhand_big_held.m

make_vision_inhand_big_held

PURPOSE ^

finds moments when object is big in child view and also agent's hand

SYNOPSIS ^

function make_vision_inhand_big_held(IDs, dominantorbig, obj_list)

DESCRIPTION ^

finds moments when object is big in child view and also agent's hand

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function make_vision_inhand_big_held(IDs, dominantorbig, obj_list)
0002 %finds moments when object is big in child view and also agent's hand
0003 subs = cIDs(IDs);
0004 agents = {'child', 'parent'};
0005 for s = 1:numel(subs) % cycle through subjects
0006     for a = 1:2 % cycle through two agents
0007         agent = agents{a};
0008         if has_variable(subs(s), sprintf('cstream_vision_size_obj-%s_child', dominantorbig)) % check to see vars exist
0009             dom = get_variable(subs(s), sprintf('cstream_vision_size_obj-%s_child', dominantorbig)); % get dominant vision var
0010             var = sprintf('cstream_inhand_left-hand_obj-all_%s', agent); 
0011             left = get_variable(subs(s), var); % get left hand
0012             right = get_variable(subs(s), strrep(var, 'left', 'right')); % get right hand
0013             
0014             % check to see that cstream lengths are equal, if not, convert
0015             %to cevents then back to cstreams with a set timebase. The
0016             %timebase is arbitrarly set to the be timeseries for left hand.
0017             if ~isequal(size(dom,1), size(left,1), size(right,1))
0018                 fprintf('%d: cstreams not of equal length\n', subs(s));
0019                 all = {dom, left, right};
0020                 timebase = left(:,1);
0021                 cstreams = cell(3,1);
0022                 for f = 1:3
0023                     cev = cstream2cevent(all{f});
0024                     cstreams{f,1} = cevent2cstream_v2(cev, [], [], timebase);
0025                 end
0026                 dom = cstreams{1};
0027                 left = cstreams{2};
0028                 right = cstreams{3};
0029             else
0030                 timebase = left(:,1);
0031             end
0032             fcev = cell(length(obj_list),1);
0033             
0034             for o = obj_list % cycle through each object
0035                 log_dom = dom(:,2) == o; % when object o is big
0036                 log_left = left(:,2) == o; % when in left hand
0037                 log_right = right(:,2) == o; % when in right hand
0038                 together = log_dom & (log_left | log_right); % when big and in either hand
0039                 part = zeros(length(together),1);
0040                 part(together) = o; % now reassign the ones to o
0041                 fcst = [timebase part]; % put the timebase back with the category column
0042                 fcev{o,1} = cstream2cevent(fcst); % convert this to cevents
0043             end
0044             cev = vertcat(fcev{:}); % put all cevents together
0045             cev = sortrows(cev, [1 2 3]); % sort all of the cevents based on time
0046             rname = sprintf('cevent_vision-inhand_obj-%s-%s-held_child', dominantorbig, agent); % save
0047             record_variable(subs(s), rname, cev);
0048             cst = cevent2cstream_v2(cev, [], [], timebase); % convert to cstream
0049             record_variable(subs(s), strrep(rname, 'cevent' ,'cstream'), cst); % save
0050         end
0051     end
0052 end
0053 
0054 end

Generated on Wed 24-May-2017 00:00:56 by m2html © 2005