Пример #1
0
def plot_helper(gt_data_frame, est_data_frame, id_gt, id_est, title, y_label):
    ''' Helper function for plotting forces/moments/cop.
    '''
    for i in range(3):

        a = np.array(est_data_frame.iloc[:, i + id_est])  # estimate
        b = np.array(gt_data_frame.iloc[:, i + id_gt])  # ground-truth

        # compute error
        err = round(
            mean_squared_error(b[~np.isnan(a)], a[~np.isnan(a)],
                               squared=False), 2)

        # plot
        fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5, 4))
        ax.plot(gt_data_frame.time, b, label='Measured')
        ax.plot(est_data_frame.time, a, '--', label='Predicted')

        if gait_cycle:
            ax.set_xlabel('gait cycle (%)')
        else:
            ax.set_xlabel('Time (seconds)')

        ax.set_ylabel(y_label)
        ax.set_title(title[i])
        ax.legend(loc='lower right')
        annotate_plot(ax, 'RMSE = ' + str(err))
        fig.patch.set_alpha(1)
        fig.tight_layout()
        pdf.savefig(fig)
        plt.close()
Пример #2
0
                scale * reconstructed_markers.iloc[:, i],
                label='Reconstructed',
                linestyle='--')
        ax.axvspan(occlusion_start_perc,
                   occlusion_stop_perc,
                   label="Occlusion Period",
                   color="tab:blue",
                   alpha=0.3)
        if gait_cycle:
            ax.set_xlabel('gait cycle (%)')
        else:
            ax.set_xlabel('time (s)')

        ax.set_ylabel('position' + position_unit)
        ax.set_title(original_markers.columns[j])
        annotate_plot(ax, 'RMSE = ' + str(d_q))
        ax.legend(loc='lower left')

        fig.tight_layout()
        pdf.savefig(fig)
        plt.close()

print('d_q: μ = ', np.round(np.mean(d_q_total), 3), ' σ = ',
      np.round(np.std(d_q_total, ddof=1), 3))

with open(results_dir + '_metrics.txt', 'w') as file_handle:
    file_handle.write('RMSE\n')
    file_handle.write('\td_q: μ = ' + str(np.round(np.mean(d_q_total), 3)) +
                      ' σ = ' + str(np.round(np.std(d_q_total, ddof=1), 3)))
# %%
Пример #3
0
            units = ' (N)'

        fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5, 4))

        ax.plot(tau_reference.time, tau_reference.iloc[:, i],
                label='OpenSim ID')
        ax.plot(tau_rt.time, tau_rt.iloc[:, j], label='Real-time ID',
                linestyle='--')
        if gait_cycle:
            ax.set_xlabel('gait cycle (%)')
        else:
            ax.set_xlabel('time (s)')

        ax.set_ylabel('generalized forces' + units)
        ax.set_title(tau_rt.columns[j])
        annotate_plot(ax, 'RMSE = ' + str(d_tau))
        ax.legend(loc='lower left')

        fig.tight_layout()
        pdf.savefig(fig)
        plt.close()

print('d_tau: μ = ', np.round(np.mean(d_tau_total), 3),
      ' σ = ', np.round(np.std(d_tau_total, ddof=1), 3))

with open(output_dir + 'metrics.txt', 'w') as file_handle:
    file_handle.write('RMSE\n')
    file_handle.write('\td_q: μ = ' + str(np.round(np.mean(d_tau_total), 3)) +
                      ' σ = ' + str(np.round(np.std(d_tau_total, ddof=1), 3)))

# %%
Пример #4
0
    #plt.xticks(timepoints, timepoints, rotation=45)

    if options.title:
        plt.title("%s (%s)" % (options.title,metabolite))
    else:
        plt.title(metabolite)
    
    plt.gca().xaxis.set_label_text(options.xlabel)
    plt.gca().yaxis.set_label_text(options.ylabel)
    
    # Add some padding either side of graphs
    #plt.xlim( ind[0]-1, ind[-1]+1)
    
    if options.annotate:
        utils.annotate_plot(plt,options)
    
    fig = plt.gcf()
    # Horizontal axis through zero
    #plt.axhline(0, color='k')

    if options.multiplot: #Scale the multiplots a bit more reasonably
        fig.set_size_inches(5 + len(metabolites)*3,6)
    else:
        fig.set_size_inches(8,6)
    
    # Get ylimits for significance bars

    if options.ylim:
        ylim=options.ylim.split(',')
        plt.ylim( int(ylim[0]), int(ylim[1]) )
Пример #5
0
    if args.title:
        plt.title("%s (%s)" % (args.title, metabolite))
    else:
        plt.title(metabolite)

    plt.gca().set_xticklabels(graph['timepoints'], minor=False, rotation=45)

    plt.gca().xaxis.set_label_text(args.xlabel)
    plt.gca().yaxis.set_label_text(args.ylabel)

    # Add some padding either side of graphs
    #plt.xlim( ind[0]-1, ind[-1]+1)

    if args.annotate:
        utils.annotate_plot(plt, args)

    fig = plt.gcf()
    # Horizontal axis through zero
    #plt.axhline(0, color='k')

    if args.multiplot:  # Scale the multiplots a bit more reasonably
        fig.set_size_inches(5 + len(metabolites) * 3, 6)
    else:
        fig.set_size_inches(8, 6)

    # Get ylimits for significance bars

    if args.ylim:
        ylim = args.ylim.split(',')
        plt.ylim(int(ylim[0]), int(ylim[1]))
Пример #6
0
        fig, ax = plt.subplots(nrows=1, ncols=3, figsize=(13, 4))

        ax[0].plot(q_reference.time, q_reference.iloc[:, i], label='OpenSim')
        ax[0].plot(q_filtered.time,
                   scale * q_filtered.iloc[:, j],
                   label='Proposed filter',
                   linestyle='--')
        ax[0].plot(q_filtered_sp.time,
                   scale * q_filtered_sp.iloc[:, j],
                   label='Spatial filter',
                   linestyle=':')
        ax[0].set_xlabel(x_label)
        ax[0].set_ylabel('coordinate' + position_unit)
        ax[0].set_title(q_reference.columns[i])
        annotate_plot(ax[0], 'RMSE = ' + str(d_q))
        annotate_plot(ax[0], 'RMSE = ' + str(d_q_sp), 'upper right')
        ax[0].legend(loc='lower left')

        ax[1].plot(q_dot_reference.time,
                   q_dot_reference.iloc[:, i],
                   label='OpenSim')
        ax[1].plot(q_dot_filtered.time,
                   scale * q_dot_filtered.iloc[:, j],
                   label='Proposed filter',
                   linestyle='--')
        ax[1].plot(q_dot_filtered_sp.time,
                   scale * q_dot_filtered_sp.iloc[:, j],
                   label='Spatial filter',
                   linestyle=':')
        ax[1].set_xlabel(x_label)
Пример #7
0
                                                                          i])
        d_a = rmse_metric(q_ddot_reference.iloc[:, i], q_ddot_filtered.iloc[:,
                                                                            i])
        if not np.isnan(d_q):  # NaN when siganl is zero
            d_q_total.append(d_q)
            d_u_total.append(d_u)
            d_a_total.append(d_a)

        fig, ax = plt.subplots(nrows=1, ncols=3, figsize=(12, 4))

        ax[0].plot(q_reference.time, q_reference.iloc[:, i], label='OpenSim')
        ax[0].plot(q_filtered.time, q_filtered.iloc[:, i], label='filtered')
        ax[0].set_xlabel('time (s)')
        ax[0].set_ylabel('coordinate (deg | m)')
        ax[0].set_title(q_reference.columns[i])
        annotate_plot(ax[0], 'RMSE = ' + str(d_q))
        ax[0].legend(loc='lower left')

        ax[1].plot(q_dot_reference.time,
                   q_dot_reference.iloc[:, i],
                   label='OpenSim')
        ax[1].plot(q_dot_filtered.time,
                   q_dot_filtered.iloc[:, i],
                   label='filtered')
        ax[1].set_xlabel('time (s)')
        ax[1].set_ylabel('speed (deg / s | m / s)')
        ax[1].set_title(q_dot_reference.columns[i])
        annotate_plot(ax[1], 'RMSE = ' + str(d_u))
        # ax[1].legend()

        ax[2].plot(q_ddot_reference.time,
Пример #8
0
    plt.xticks(ind, graph['ticks'])  #, rotation=45)

    if args.title:
        plt.title(args.title)
    else:
        plt.title(metabolite)

    plt.gca().xaxis.set_label_text(args.xlabel)
    plt.gca().yaxis.set_label_text(args.ylabel)

    # Add some padding either side of graphs
    plt.xlim(ind[0] - 1, ind[-1] + 1)

    if args.annotate:
        utils.annotate_plot(plt, options)

    fig = plt.gcf()
    # Horizontal axis through zero
    plt.axhline(0, color='k')

    if args.multiplot:  # Scale the multiplots a bit more reasonably
        fig.set_size_inches(5 + len(metabolites) * 3, 6)
    else:
        fig.set_size_inches(8, 6)

    # Get ylimits for significance bars
    ymin, ymax = graph['ylim']

    sigs = list()
    if args.tests:
Пример #9
0
    if args.title:
        plt.title("%s (%s)" % (args.title, metabolite))
    else:
        plt.title(metabolite)

    plt.gca().set_xticklabels(graph['timepoints'], minor=False, rotation=45)

    plt.gca().xaxis.set_label_text(args.xlabel)
    plt.gca().yaxis.set_label_text(args.ylabel)

    # Add some padding either side of graphs
    #plt.xlim( ind[0]-1, ind[-1]+1)

    if args.annotate:
        utils.annotate_plot(plt, args)

    fig = plt.gcf()
    # Horizontal axis through zero
    #plt.axhline(0, color='k')

    if args.multiplot:  # Scale the multiplots a bit more reasonably
        fig.set_size_inches(5 + len(metabolites) * 3, 6)
    else:
        fig.set_size_inches(8, 6)

    # Get ylimits for significance bars

    if args.ylim:
        ylim = args.ylim.split(',')
        plt.ylim(int(ylim[0]), int(ylim[1]))
Пример #10
0
    "Build from source (via GitHub)",
    "Windows binaries (.msi file), downloaded from GitHub",
    "macOS installer (.pkg file), downloaded from GitHub",
    "Ubuntu Personal Package Archive (PPA)",
    "Other",
]
frequency = CategoricalDtype(["Often", "Sometimes", "Rarely", "Never"])

# %%
interface_data = data[range(8, 13)]
interface_data.columns = interfaces
n_responses = len(interface_data.index)
ax = (interface_data.count().sort_index() / n_responses).plot.barh()
annotate_plot(
    ax,
    f"Which interface(s) do you use to access Cantera? {n_responses} Responses",
    n_responses,
)

# %%
os_data = data[range(1, 8)]
os_data.columns = operating_systems
n_responses = len(os_data.index)
ax = (os_data.count().sort_index() / n_responses).plot.barh()
annotate_plot(ax,
              f"What operating system(s) do you use? {n_responses} Responses",
              n_responses)

# %%
install_data = data[range(13, 21)]
install_data.columns = install_methods
        fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5, 4))

        ax.plot(tau_reference.time, tau_reference.iloc[:, i],
                label='OpenSim')
        ax.plot(tau_rt.time, tau_rt.iloc[:, j], label='Proposed filter',
                linestyle='--')
        ax.plot(tau_rt_sp.time, tau_rt_sp.iloc[:, j], label='Spatial filter',
                linestyle=':')
        if gait_cycle:
            ax.set_xlabel('gait cycle (%)')
        else:
            ax.set_xlabel('time (s)')

        ax.set_ylabel('generalized force' + units)
        ax.set_title(tau_rt.columns[j])
        annotate_plot(ax, 'RMSE = ' + str(d_tau))
        annotate_plot(ax, 'RMSE = ' + str(d_tau_sp), 'upper right')
        ax.legend(loc='lower right')

        fig.tight_layout()
        pdf.savefig(fig)
        plt.close()

print('d_tau: μ = ', np.round(np.mean(d_tau_total), 3),
      ' σ = ', np.round(np.std(d_tau_total, ddof=1), 3))

with open(output_dir + 'metrics.txt', 'w') as file_handle:
    file_handle.write('RMSE\n')
    file_handle.write('\td_q: μ = ' + str(np.round(np.mean(d_tau_total), 3)) +
                      ' σ = ' + str(np.round(np.std(d_tau_total, ddof=1), 3)))