% function [] = residuals(subjectID) % Purpose: Reads the set of motion files output by Darryl's executables % corresponding to subjectID and generates plots of the % RRA Residuals % % Input: subjectID is the prefix ('string') of the following input files, % generated from the preprocessing step and Darryl's executables: % subjectID.mot % subjectIDik.mot % subjectIDrea.mot % subjectIDcmc.mot % % Called Functions: read_motionfile.m % % ASA, 3-05 % Set flag for printing (1 = print to printer; 0 = print to screen only) print_flag = 0; % Set flag for pausing between figures (1 = pause, 0 = do not pause) pause_flag = 1; ic = 1.36; ic2 = 2.55; dur = 1.19; % Read file subjectID.mot % fname = strcat(subjectID, '_raw_all.mot');%changed file name from '.mot' to 'raw.mot' % fname = strcat(subjectID, '_raw_presw2pk.mot'); % mot = read_motionfile('hpl_overground_slow_walk.trc'); % Read files subjectIDik.mot % fname = strcat(subjectID, '_invkin.mot'); % fname = strcat(subjectID, '_invkin_presw2pk.mot'); % fname = strcat(subjectID, 'cmc_presw2pk_original.mot'); ik = read_motionfile2('quickhop6IK.mot'); % Read files subjectIDrea.mot % fname = strcat(subjectID, '_rea.mot'); % fname = strcat(subjectID, '_rea_presw2pk.mot'); rea = read_motionfile2('quickhop_6_RRA_Kinematics_q.mot'); rra_act = read_motionfile3('quickhop_6_RRA_Actuation_force.sto'); % Read files subjectIDcmc.mot % fname = strcat(subjectID, '_cmc.mot'); % fname = strcat(subjectID, '_cmc_presw2pk.mot'); % Generate plots set(0, 'Units', 'pixels'); scnsize = get(0, 'ScreenSize'); scnwidth = scnsize(3); scnheight = scnsize(4); figpos_whole = [0.1*scnwidth, 0.1*scnheight, 0.8*scnwidth, 0.5*scnheight]; figure(1); % Residuals from RRA clf set(gcf, 'Position', figpos_whole, 'Color', 'w'); set(gcf, 'PaperOrientation', 'landscape'); set(gcf, 'PaperPosition', [1 1 9 6.5]); subplot(1, 2, 1); % cid_motx = find(strcmpi(mot.labels, 'time')); % cid_moty = find(strcmpi(mot.labels, 'pelvis_tx')); % p = plot(mot.data(:, cid_motx), mot.data(:, cid_moty)); % set(p, 'LineWidth', 1, 'Color', 'k'); % hold on; cid_time = find(strcmpi(rra_act.labels, 'time')); cid_FX = find(strcmpi(rra_act.labels, 'FX')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_FX)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); hold on; cid_FY = find(strcmpi(rra_act.labels, 'FY')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_FY)); set(p, 'LineWidth', 1, 'Color', [0.0 0.8 0.3]); hold on; cid_FZ = find(strcmpi(rra_act.labels, 'FZ')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_FZ)); set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]); hold on; title_string = ['Residual Forces']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Force (N)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); ytickpositions = get(gca, 'Ytick'); if length(ytickpositions) > 5 new_ytickpositions = ytickpositions(1:2:length(ytickpositions)); set(gca, 'Ytick', new_ytickpositions); end hlegend = legend('{\itFX}', '{\itFY}', '{\itFZ}', 0); set(hlegend, 'Box', 'off', 'XColor', 'w', 'YColor', 'w'); subplot(1, 2, 2); % cid_motx = find(strcmpi(mot.labels, 'time')); % cid_moty = find(strcmpi(mot.labels, 'pelvis_tx')); % p = plot(mot.data(:, cid_motx), mot.data(:, cid_moty)); % set(p, 'LineWidth', 1, 'Color', 'k'); % hold on; cid_time = find(strcmpi(rra_act.labels, 'time')); cid_MX = find(strcmpi(rra_act.labels, 'MX')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_MX)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); hold on; cid_MY = find(strcmpi(rra_act.labels, 'MY')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_MY)); set(p, 'LineWidth', 1, 'Color', [0.0 0.8 0.3]); hold on; cid_MZ = find(strcmpi(rra_act.labels, 'MZ')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_MZ)); set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]); hold on; title_string = ['Residual Moments']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); ytickpositions = get(gca, 'Ytick'); if length(ytickpositions) > 5 new_ytickpositions = ytickpositions(1:2:length(ytickpositions)); set(gca, 'Ytick', new_ytickpositions); end hlegend = legend('{\itMX}', '{\itMY}', '{\itMZ}', 0); set(hlegend, 'Box', 'off', 'XColor', 'w', 'YColor', 'w'); % 2nd orientation figure(2); % Residuals from RRA clf set(gcf, 'Position', figpos_whole, 'Color', 'w'); set(gcf, 'PaperOrientation', 'landscape'); set(gcf, 'PaperPosition', [1 1 9 6.5]); subplot(2, 1, 1); % cid_motx = find(strcmpi(mot.labels, 'time')); % cid_moty = find(strcmpi(mot.labels, 'pelvis_tx')); % p = plot(mot.data(:, cid_motx), mot.data(:, cid_moty)); % set(p, 'LineWidth', 1, 'Color', 'k'); % hold on; cid_time = find(strcmpi(rra_act.labels, 'time')); cid_FX = find(strcmpi(rra_act.labels, 'FX')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_FX)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); hold on; cid_FY = find(strcmpi(rra_act.labels, 'FY')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_FY)); set(p, 'LineWidth', 1, 'Color', [0.0 0.8 0.3]); hold on; cid_FZ = find(strcmpi(rra_act.labels, 'FZ')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_FZ)); set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]); hold on; title_string = ['Residual Forces']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Force (N)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); ytickpositions = get(gca, 'Ytick'); if length(ytickpositions) > 5 new_ytickpositions = ytickpositions(1:2:length(ytickpositions)); set(gca, 'Ytick', new_ytickpositions); end hlegend = legend('{\itFX}', '{\itFY}', '{\itFZ}', 'Location', 'Best'); set(hlegend, 'Box', 'off', 'XColor', 'w', 'YColor', 'w'); subplot(2, 1, 2); % cid_motx = find(strcmpi(mot.labels, 'time')); % cid_moty = find(strcmpi(mot.labels, 'pelvis_tx')); % p = plot(mot.data(:, cid_motx), mot.data(:, cid_moty)); % set(p, 'LineWidth', 1, 'Color', 'k'); % hold on; cid_time = find(strcmpi(rra_act.labels, 'time')); cid_MX = find(strcmpi(rra_act.labels, 'MX')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_MX)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); hold on; cid_MY = find(strcmpi(rra_act.labels, 'MY')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_MY)); set(p, 'LineWidth', 1, 'Color', [0.0 0.8 0.3]); hold on; cid_MZ = find(strcmpi(rra_act.labels, 'MZ')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_MZ)); set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]); hold on; title_string = ['Residual Moments']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); ytickpositions = get(gca, 'Ytick'); if length(ytickpositions) > 5 new_ytickpositions = ytickpositions(1:2:length(ytickpositions)); set(gca, 'Ytick', new_ytickpositions); end hlegend = legend('{\itMX}', '{\itMY}', '{\itMZ}', 'Location', 'Best'); set(hlegend, 'Box', 'off', 'XColor', 'w', 'YColor', 'w'); % Joint Torques figure(3) %Right Leg clf set(gcf, 'Position', figpos_whole, 'Color', 'w'); set(gcf, 'PaperOrientation', 'landscape'); set(gcf, 'PaperPosition', [1 1 9 6.5]); subplot(2,3,1) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'hip_flexion_r')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['hip flexion r']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,2) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'hip_adduction_r')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['hip adduction r']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,3) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'hip_rotation_r')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['hip rotation r']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,4) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'knee_angle_r')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['knee angle r']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,5) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'ankle_angle_r')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['ankle angle r']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,6) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'mtp_angle_r')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); hold on cid_y2 = find(strcmpi(rra_act.labels, 'subtalar_angle_r')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y2)); set(p, 'LineWidth', 1, 'Color', [0.0 0.8 0.3]); title_string = ['subtalar angle r and mtp angle r']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); figure(4) %Left Leg clf set(gcf, 'Position', figpos_whole, 'Color', 'w'); set(gcf, 'PaperOrientation', 'landscape'); set(gcf, 'PaperPosition', [1 1 9 6.5]); subplot(2,3,1) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'hip_flexion_l')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['hip flexion l']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,2) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'hip_adduction_l')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['hip adduction l']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,3) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'hip_rotation_l')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['hip rotation l']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,4) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'knee_angle_l')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['knee angle l']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,5) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'ankle_angle_l')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['ankle angle l']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,6) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'mtp_angle_l')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); hold on cid_y2 = find(strcmpi(rra_act.labels, 'subtalar_angle_l')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y2)); set(p, 'LineWidth', 1, 'Color', [0.0 0.8 0.3]); title_string = ['subtalar angle l and mtp angle l']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); figure(5) %Back Joint clf set(gcf, 'Position', figpos_whole, 'Color', 'w'); set(gcf, 'PaperOrientation', 'landscape'); set(gcf, 'PaperPosition', [1 1 9 6.5]); subplot(2,3,1) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'lumbar_extension')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['lumbar extension']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,2) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'lumbar_bending')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['lumbar bending']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8); subplot(2,3,3) cid_time = find(strcmpi(rra_act.labels, 'time')); cid_y1 = find(strcmpi(rra_act.labels, 'lumbar_rotation')); p = plot(rra_act.data(:, cid_time), rra_act.data(:, cid_y1)); set(p, 'LineWidth', 1, 'Color', [0.8 0.0 0.5]); title_string = ['lumbar rotation']; title(title_string, 'FontSize', 9, 'FontWeight', 'Bold'); xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top'); ylabel('Torque (N-m)', 'FontSize', 9, 'VerticalAlignment', 'bottom'); % set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]); set(gca, 'Box', 'off', 'FontSize', 8);