Home > data-import > create_dom_object_position.m

create_dom_object_position

PURPOSE ^

finds distance from center of frame to each dominant object, NaN otherwise

SYNOPSIS ^

function create_dom_object_position(IDs)

DESCRIPTION ^

finds distance from center of frame to each dominant object, NaN otherwise

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function create_dom_object_position(IDs)
0002 %finds distance from center of frame to each dominant object, NaN otherwise
0003 if numel(num2str(IDs(1))) > 2
0004     subs = IDs;
0005 else
0006     subs = list_subjects(IDs);
0007 end
0008 
0009 person = {'child' 'parent'};
0010 factor = {'big' 'dominant'};
0011 threshold = {'' '-2x'};
0012 for s = 1:numel(subs)
0013     for p = 1:numel(person)
0014         for f = 1:numel(factor)
0015             for t = 1:numel(threshold)
0016                 factor_name = sprintf('cevent_vision_size_obj-%s%s_%s', factor{f}, threshold{t}, person{p});
0017                 if has_variable(subs(s), factor_name)
0018                     factor_var = get_variable(subs(s), factor_name);
0019                     data_collection = [];
0020                     for o = 1:3
0021                         var = sprintf('cont_vision_min-dist_obj%d_%s', o, person{p});
0022                         if has_variable(subs(s), var)
0023                             var_data = get_variable(subs(s), var);
0024                             time_base = var_data(:,1);
0025                             cstr = cevent2cstream_v2(factor_var,[], [], time_base);
0026                             log = cstr(:,2) == o;
0027                             log_nan = log == 0;
0028                             var_data(log_nan,2) = NaN;
0029                             data_collection = cat(2, data_collection, var_data(:,2));
0030                         end
0031                     end
0032                     if ~isempty(data_collection)
0033                         %test to make sure there are 2 NaN values per row
0034                         log = isnan(data_collection);
0035                         log_not_nan = log == 0;
0036                         sum_log = sum(log_not_nan, 2);
0037                         all_nan = sum_log == 0;
0038                         log_multiple = sum_log > 1;
0039                         if sum(log_multiple) > 0
0040                             disp('warning, lines with more than 1 non-NaN values');
0041                             disp(subs(s));
0042                         else
0043                             %cat across
0044                             data_clone = data_collection;
0045                             data_clone(isnan(data_clone)) = 0;
0046                             final_data = sum(data_clone,2);
0047                             final_data(all_nan) = NaN;
0048                             final_data = [time_base final_data];
0049                             %record data
0050                             rec_name = sprintf('cont_vision_min-dist_obj-%s%s_%s', factor{f}, threshold{t}, person{p});
0051                             %                         disp(rec_name);
0052                             record_variable(subs(s), rec_name, final_data);
0053                         end
0054                     else
0055                         fprintf('Subject %d missing variable, cont_vision_min-dist\n', subs(s));
0056                     end
0057                 else
0058                     fprintf('Subject %d missing variable, %s\n', subs(s), factor_name);
0059                 end
0060             end
0061         end
0062     end
0063 end

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005