Home > data-vis > supporting_functions > load_motion_data.m

load_motion_data

PURPOSE ^

SYNOPSIS ^

function mosdata = load_motion_data(subid, sensors)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mosdata = load_motion_data(subid, sensors)
0002 sensor_names = {
0003     'head_child' % 1 2 3
0004     'head_parent' % 4 5 6
0005     'left-hand_child' % 7 8 9
0006     'right-hand_child' % 10 11 12
0007     'left-hand_parent' % 13 14 15
0008     'right-hand_parent'}; % 16 17 18
0009 mosdata_x =[];
0010 mosdata_y = [];
0011 mosdata_z = [];
0012 validsensors = [];
0013 
0014 for s = 1:numel(sensors)
0015     if has_variable(subid, ['cont3_motion_pos_' sensor_names{sensors(s)}])
0016         data = get_variable(subid, ['cont3_motion_pos_' sensor_names{sensors(s)}]);
0017         idx = find(data(:,1) >= 30, 1);
0018         data = data(idx:end,:);
0019         data = data(:,[4 3 2]);
0020         data(:,3) = 700-data(:,3);
0021 %         data(:,1) = 100-data(:,1);
0022         data = downsample(data, 2);
0023         mosdata_x = cat(2, mosdata_x, data(:,1));
0024         mosdata_y = cat(2, mosdata_y, data(:,2));
0025         mosdata_z = cat(2, mosdata_z, data(:,3));
0026         validsensors = cat(2, validsensors, sensors(s));
0027     end
0028 end
0029 fulldata = nan(size(mosdata_x,1), numel(sensor_names));
0030 mosdata.x = fulldata;
0031 mosdata.y = fulldata;
0032 mosdata.z = fulldata;
0033 
0034 mosdata.x(:, validsensors) = mosdata_x;
0035 mosdata.y(:, validsensors) = mosdata_y;
0036 mosdata.z(:, validsensors) = mosdata_z;
0037 
0038 linemat = nan(1, numel(sensor_names)*3);
0039 mosdata.x_line = linemat;
0040 mosdata.y_line = linemat;
0041 mosdata.z_line = linemat;
0042 
0043 if ismember(1, validsensors)
0044     mosdata.x_line([1 7 10]) = median(mosdata.x(:,1), 1);
0045     mosdata.y_line([1 7 10]) = median(mosdata.y(:,1), 1);
0046     mosdata.z_line([1 7 10]) = 100;
0047 end
0048 
0049 if ismember(2, validsensors)
0050     mosdata.x_line([4 13 16]) = median(mosdata.x(:,2), 1);
0051     mosdata.y_line([4 13 16]) = median(mosdata.y(:,2), 1);
0052     mosdata.z_line([4 13 16]) = 100;
0053 end

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