% function [] = cmc_exes(subjectID)
% Purpose:  Reads the set of motion files output by Darryl's executables
%           corresponding to subjectID and generates plots of the
%           gencoords vs time for comparing the output of the IK, REA, and 
%           CMC steps to the subject's experimental data
%
% 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;

%ik = read_motionfile2('MDeMers_IK_SlowWalk.mot');

%rea = read_motionfile2('MDeMers_slow_walk_RRA_Kinematics_q.mot');

cmc = read_motionfile3('quickhop6_cmc_SLS_controls.sto');

% 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.8*scnheight];
    



figure(x);   % R VAS, RF Excitations
    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_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'glut_med1_r.excitation'));
    p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['R VASmed Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
    subplot(2, 3, 2);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'vas_int_r.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['R VASint Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
%     subplot(2, 3, 3);
%     cid_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'vas_lat_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = [subjectID ':  R VASlat Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
% %     set(gca, 'Xtick', [0 0.2 0.4 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
   
    subplot(2, 3, 4);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'rect_fem_r.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['R RF Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
           
    if pause_flag == 1
        pause;
    end
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
figure(6);   % R ILSPSO, GAS/SOL Excitations
    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_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'iliacus_r.excitation'));
%     p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = ['R Iliacus Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
% %     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
%     vline(2.025, 'k', 'RHS')
%     vline(2.175, 'k', 'LTO')
%     vline(2.65, 'k', 'LHS')
%     vline(2.775, 'k', 'RTO')  
%     
%     subplot(2, 3, 2);
%     cid_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'psoas_r.excitation'));
%     p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = ['R Psoas Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
% %     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
%     vline(2.025, 'k', 'RHS')
%     vline(2.175, 'k', 'LTO')
%     vline(2.65, 'k', 'LHS')
%     vline(2.775, 'k', 'RTO')
    
    subplot(2, 3, 4);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'med_gas_r.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['R GASmed Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
%     subplot(2, 3, 5);
%     cid_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'lat_gas_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = [subjectID ':  R GASlat Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
    
    subplot(2, 3, 6);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'soleus_r.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['R Soleus Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
           
    if pause_flag == 1
        pause;
    end
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')

figure(7);   % R Hamstrings, BFSH Excitations
    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_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'semimem_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = [subjectID ':  R SM Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
            
%     subplot(2, 3, 2);
%     cid_motx = find(strcmpi(mot.labels, 'time'));
%     cid_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'semiten_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = [subjectID ':  R ST Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
    
    subplot(2, 3, 3);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'bifemlh_r.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['R BFLH Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
    subplot(2, 3, 4);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'bifemsh_r.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['R BFSH Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
    subplot(2, 3, 5); %R TA
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'tib_ant_r.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['R Tib Ant Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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

           
    if pause_flag == 1
        pause;
    end
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
figure(8);   % L VAS, RF Excitations
    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_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'vas_med_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = ['R VASmed Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
% %     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
            
    subplot(2, 3, 2);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'vas_int_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L VASint Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
%     subplot(2, 3, 3);
%     cid_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'vas_lat_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = [subjectID ':  R VASlat Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
% %     set(gca, 'Xtick', [0 0.2 0.4 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
   
    subplot(2, 3, 4);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'rect_fem_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L RF Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
           
    if pause_flag == 1
        pause;
    end
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')

    
figure(9);   % L ILSPSO, GAS/SOL Excitations
     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_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'iliacus_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L Iliacus Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')  
    
    subplot(2, 3, 2);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'psoas_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L Psoas Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
    subplot(2, 3, 4);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'med_gas_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L GASmed Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
%     subplot(2, 3, 5);
%     cid_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'lat_gas_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = [subjectID ':  R GASlat Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
    
    subplot(2, 3, 6);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'soleus_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L Soleus Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
           
    if pause_flag == 1
        pause;
    end
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')


figure(10);   % L Hamstrings, BFSH Excitations
    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_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'semimem_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = [subjectID ':  R SM Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
            
%     subplot(2, 3, 2);
%     cid_motx = find(strcmpi(mot.labels, 'time'));
%     cid_cmcx = find(strcmpi(cmc.labels, 'time'));
%     cid_cmcy = find(strcmpi(cmc.labels, 'semiten_r_exc'));
%     p = plot(cmc.data(:, cid_cmcx), cmc.data(:, cid_cmcy));
%     set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
%     title_string = [subjectID ':  R ST Excitation'];
%     title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
%     xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
%     set(gca, 'Ylim', [0 1]);
%     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
    
    subplot(2, 3, 3);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'bifemlh_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L BFLH Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
    subplot(2, 3, 4);
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'bifemsh_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L BFSH Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
    
    subplot(2, 3, 5); %L TA
    cid_cmcx = find(strcmpi(cmc.labels, 'time'));
    cid_cmcy = find(strcmpi(cmc.labels, 'tib_ant_l.excitation'));
    p = plot((cmc.data(:, cid_cmcx)), cmc.data(:, cid_cmcy));
    set(p, 'LineWidth', 1, 'Color', [0.0 0.0 0.8]);
    title_string = ['L Tib Ant Excitation'];
    title(title_string, 'FontSize', 9, 'FontWeight', 'Bold');
    xlabel('time (s)', 'FontSize', 9, 'VerticalAlignment', 'top');
%     set(gca, 'Xtick', [0 0.2 0.4 0.6 0.8 1.0]);
    set(gca, 'Ylim', [0 1]);
    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
    vline(2.025, 'k', 'RHS')
    vline(2.175, 'k', 'LTO')
    vline(2.65, 'k', 'LHS')
    vline(2.775, 'k', 'RTO')
           
    if pause_flag == 1
        pause;
    end
    
if print_flag == 1    
    print -f1;
    print -f2;
    print -f3;
    print -f4;
    print -f5;
    print -f6;
    print -f7;
    print -f8;
    print -f9;
    print -f10;
end

    
    
