Home > data-import > create_dom_vars.m

create_dom_vars

PURPOSE ^

SYNOPSIS ^

function create_dom_vars(subexpIDs, rel_prop, threshold, obj_list, max_threshold)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function create_dom_vars(subexpIDs, rel_prop, threshold, obj_list, max_threshold)
0002 
0003 subs = subexpIDs;
0004 
0005 person = {'child' 'parent'};
0006 if ~exist('obj_list', 'var') || isempty(obj_list)
0007     obj = {'obj1', 'obj2', 'obj3'};
0008 else
0009     obj = {};
0010     for j = obj_list
0011         obj{j} = sprintf('obj%d',j);
0012     end
0013 end
0014 
0015 for p = 1 : numel(person)
0016     for o = 1 : numel(obj)
0017         names{o} = ['cont_vision_size_' obj{o} '_' person{p}];
0018     end
0019     for s = 1 : numel(subs)
0020         vars = cellfun(@(a) get_variable(subs(s), a), names, 'un', 0);
0021         for t = 1 : numel(threshold)
0022             for r = 1:numel(rel_prop)
0023                 if exist('max_threshold', 'var')
0024                     z = cont_dominant(vars, rel_prop(r), threshold(t), max_threshold);
0025                 else
0026                     z = cont_dominant(vars, rel_prop(r), threshold(t));
0027                 end
0028                 cevent_dom = cstream2cevent(z);
0029                 if isempty(cevent_dom)
0030                     continue
0031                 end
0032                 cevent_dom = cevent_merge_segments(cevent_dom, 0.31);
0033                 cevent_dom = cevent_remove_small_segments(cevent_dom, 0.11);
0034                 %                 cevent_dom = cevent_merge_segments(cevent_dom, 0.31);
0035                 %             cevent_dom = cleanup_dom(cevent_dom);
0036                 if threshold(t) == 5
0037                     if rel_prop(r) == 2/3
0038                         record_variable(subs(s), sprintf('%s_%s', 'cevent_vision_size_obj-dominant-2x',...
0039                             person{p}), cevent_dom);
0040                         record_variable(subs(s), sprintf('%s_%s', 'cstream_vision_size_obj-dominant-2x',...
0041                             person{p}),z);
0042                     elseif rel_prop(r) == 1/2
0043                         record_variable(subs(s), sprintf('%s_%s', 'cevent_vision_size_obj-dominant',...
0044                             person{p}), cevent_dom);
0045                         record_variable(subs(s), sprintf('%s_%s', 'cstream_vision_size_obj-dominant',...
0046                             person{p}),z);
0047                     end
0048                 elseif threshold(t) == 3
0049                     if rel_prop(r) == 2/3
0050                         record_variable(subs(s), sprintf('%s_%s', 'cevent_vision_size_obj-big-2x',...
0051                             person{p}), cevent_dom);
0052                         record_variable(subs(s), sprintf('%s_%s', 'cstream_vision_size_obj-big-2x',...
0053                             person{p}),z);
0054                     elseif rel_prop(r) == 1/2
0055                         record_variable(subs(s), sprintf('%s_%s', 'cevent_vision_size_obj-big',...
0056                             person{p}), cevent_dom);
0057                         record_variable(subs(s), sprintf('%s_%s', 'cstream_vision_size_obj-big',...
0058                             person{p}),z);
0059                     end
0060                 end
0061             end
0062             
0063         end
0064     end
0065 end
0066 
0067 
0068     function cevent = cleanup_dom(var)
0069         cevent_size = size(var, 1);
0070         cevent = cevent_merge_segments(var, 0.21);
0071         merge_size = size(cevent, 1);
0072         while cevent_size ~= merge_size
0073             cevent = cevent_merge_segments(cevent, 0.21);
0074             cevent_size = merge_size;
0075             merge_size = size(cevent, 1);
0076             fprintf('cevent is %d and merge is %d\n', cevent_size, merge_size);
0077         end
0078         
0079         
0080         %filter out small duration events
0081         dur = cevent(:,2) - cevent(:,1);
0082         cevent(dur < .15, :) = [];
0083         cevent = cevent_merge_segments(cevent, 0.21);
0084     end
0085 
0086 
0087     function has = has_all_vars(variables, subject_id)
0088         % returns true if the subject has all of the requested variables available
0089         
0090         has = [];
0091         for i = 1:length(variables)
0092             has(i) = has_variable(subject_id, variables{i});
0093         end
0094         has = prod(has) > 0;
0095         
0096     end
0097 end

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