Home > data-vis > draw_motion_scatter.m

draw_motion_scatter

PURPOSE ^

IDs can be experiment IDs or a list of subjects

SYNOPSIS ^

function draw_motion_scatter(IDs, plane)

DESCRIPTION ^

 IDs can be experiment IDs or a list of subjects
 plane is a 2 point vector:
 bird's eye view is [4,3] z,y
 from door perspective [4,2] z,x
 from experimenter perspective [3,2] y,x

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function draw_motion_scatter(IDs, plane)
0002 % IDs can be experiment IDs or a list of subjects
0003 % plane is a 2 point vector:
0004 % bird's eye view is [4,3] z,y
0005 % from door perspective [4,2] z,x
0006 % from experimenter perspective [3,2] y,x
0007 %
0008 %
0009 
0010 if ~exist('plane', 'var') || isempty(plane)
0011     plane = [4,3];
0012 end
0013 
0014 subs = cIDs(IDs);
0015 var_list_all = {'cont3_motion_pos_head_child', 'cont3_motion_pos_head_parent',...
0016     'cont3_motion_pos_left-hand_child', 'cont3_motion_pos_right-hand_child',...
0017     'cont3_motion_pos_left-hand_parent','cont3_motion_pos_right-hand_parent'};
0018 colors = 'rybgcm';
0019 legend_names = {'child-head','parent-head','left-hand child','right-hand child', 'left-hand parent', 'right-hand parent'};
0020 for s = 1:numel(subs)
0021     fprintf('%d\n',subs(s));
0022     figure;
0023     log = cellfun(@(A) has_variable(subs(s), A), var_list_all);
0024     if sum(log) > 0
0025         var_list = var_list_all(log);
0026         all = cell(numel(var_list));
0027         for v = 1:numel(var_list)
0028             data = get_variable_by_trial_cat(subs(s), var_list{v});
0029             data(:,5) = v;
0030             all{v} = data;
0031         end
0032         all = vertcat(all{:});
0033         all = downsample(all, 2);
0034         gscatter(all(:,plane(1)),all(:,plane(2)), all(:,5), colors(log),[],5);
0035 %         ylim([-30 30]);xlim([-15 15]);
0036         legend(legend_names(log));
0037         legend('location', 'northeastoutside');
0038         title(sprintf('%d',subs(s)));
0039         set(gcf, 'position', [100 100 1200 800]);
0040         ff = getframe(gcf);
0041         path = fullfile(get_multidir_root, sprintf('experiment_%d',sub2exp(subs(s))),'included','data_vis','motion');
0042         if ~exist(path, 'dir')
0043             mkdir(path);
0044         end
0045         imwrite(ff.cdata, fullfile(path, sprintf('%d_motion_yz.png', subs(s))), 'png');
0046         close gcf
0047     end
0048 end

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