Example #1
0
    ]
    # for each column in column labels:
    for i in range(1, reconstructed_markers.shape[1]):
        # find index in original
        j = original_markers.columns.get_loc(reconstructed_markers.columns[i])

        # skip valid markers
        if skip_valid_markers:
            if (not reconstructed_markers.columns[i][:-2]
                    in missing_marker_labels):
                continue

        scale = 1000
        position_unit = ' (mm)'

        d_q = rmse_metric(scale * reconstructed_markers.iloc[:, i],
                          original_markers.iloc[:, j])
        if not np.isnan(d_q):  # NaN when siganl is zero
            d_q_total.append(d_q)

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

        ax.plot(original_markers.time,
                original_markers.iloc[:, j],
                label='Original')
        ax.plot(reconstructed_markers.time,
                scale * reconstructed_markers.iloc[:, i],
                label='Reconstructed',
                linestyle='--')
        ax.axvspan(occlusion_start_perc,
                   occlusion_stop_perc,
                   label="Occlusion Period",
Example #2
0
    jr_rt = to_gait_cycle(jr_rt, t0, tf)

plot_sto_file(jr_rt_file, jr_rt_file + '.pdf', 3)

# %%
# compare

d_jr_total = []
with PdfPages(output_dir + 'joint_reaction_comparison_fm.pdf') as pdf:
    for i in range(1, jr_rt.shape[1]):

        # find index
        key = jr_rt.columns[i]
        j = jr_reference.columns.get_loc(key)

        d_jr = rmse_metric(jr_reference.iloc[:, j], jr_rt.iloc[:, i])

        if not np.isnan(d_jr):  # NaN when siganl is zero
            d_jr_total.append(d_jr)

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

        ax.plot(jr_reference.time, jr_reference.iloc[:, j], label='OpenSim')
        ax.plot(jr_rt.time,
                jr_rt.iloc[:, i],
                label='Real-time',
                linestyle='--')
        ax.set_title(jr_rt.columns[i])
        if gait_cycle:
            ax.set_xlabel('gait cycle (%)')
        else:
Example #3
0
    tau_rt = to_gait_cycle(tau_rt, t0, tf)

plot_sto_file(tau_rt_file, tau_rt_file + '.pdf', 3)

# %%
# compare

d_tau_total = []
with PdfPages(output_dir + 'inverse_dynamics_comparison.pdf') as pdf:
    for i in range(1, tau_reference.shape[1]):

        # find index
        key = tau_reference.columns[i].replace('_moment', '').replace('_force', '')
        j = tau_rt.columns.get_loc(key)

        d_tau = rmse_metric(tau_reference.iloc[:, i], tau_rt.iloc[:, j])
        if not np.isnan(d_tau):     # NaN when siganl is zero
            d_tau_total.append(d_tau)

        is_deg = True
        if tau_rt.columns[i] in ['pelvis_tx', 'pelvis_ty', 'pelvis_tz']:
            is_deg = False

        units = ''
        if is_deg:
            units = ' (N m)'
        else:
            units = ' (N)'

        fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5, 4))
Example #4
0
    fm_rt = to_gait_cycle(fm_rt, t0, tf)

plot_sto_file(fm_rt_file, fm_rt_file + '.pdf', 3)

# %%
# compare

d_fm_total = []
with PdfPages(output_dir + 'muscle_optimization_comparison.pdf') as pdf:
    for i in range(1, fm_rt.shape[1]):

        # find index
        key = fm_rt.columns[i]
        j = fm_reference.columns.get_loc(key)

        d_tau = rmse_metric(fm_rt.iloc[:, i], fm_reference.iloc[:, j])
        if not np.isnan(d_tau):  # NaN when signal is zero
            d_fm_total.append(d_tau)

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

        ax.plot(fm_reference.time, fm_reference.iloc[:, j], label='OpenSim SO')
        ax.plot(fm_rt.time,
                fm_rt.iloc[:, i],
                label='Real-time SO',
                linestyle='--')
        if gait_cycle:
            ax.set_xlabel('gait cycle (%)')
        else:
            ax.set_xlabel('time (s)')
Example #5
0
        if q_reference.columns[i] in ['pelvis_tx', 'pelvis_ty', 'pelvis_tz']:
            is_deg = False

        position_unit = ''
        velocity_unit = ''
        acceleration_unit = ''
        if is_deg:
            position_unit = ' (deg)'
            velocity_unit = ' (deg / s)'
            acceleration_unit = ' (deg / $s^2$)'
        else:
            position_unit = ' (m)'
            velocity_unit = ' (m / s)'
            acceleration_unit = ' (m / $s^2$)'

        d_q = rmse_metric(q_reference.iloc[:, i],
                          scale * q_filtered.iloc[:, j])
        d_u = rmse_metric(q_dot_reference.iloc[:, i],
                          scale * q_dot_filtered.iloc[:, j])
        d_a = rmse_metric(q_ddot_reference.iloc[:, i],
                          scale * q_ddot_filtered.iloc[:, j])
        d_q_sp = rmse_metric(q_reference.iloc[:, i],
                             scale * q_filtered_sp.iloc[:, j])
        d_u_sp = rmse_metric(q_dot_reference.iloc[:, i],
                             scale * q_dot_filtered_sp.iloc[:, j])
        d_a_sp = rmse_metric(q_ddot_reference.iloc[:, i],
                             scale * q_ddot_filtered_sp.iloc[:, j])
        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)
Example #6
0
        # find index
        j = q_pipeline.columns.get_loc(q_reference.columns[i])

        is_deg = True
        if q_reference.columns[i] in ['pelvis_tx', 'pelvis_ty', 'pelvis_tz']:
            is_deg = False

        position_unit = ''
        if is_deg:
            position_unit = ' (deg)'
        else:
            position_unit = ' (m)'

        dim = min(q_pipeline.shape[0], q_reference.shape[0])
        d_q = rmse_metric(q_reference.iloc[:dim, i], q_pipeline.iloc[:dim, j])
        if not np.isnan(d_q):  # NaN when siganl is zero
            d_q_total.append(d_q)

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

        ax.plot(q_reference.time, q_reference.iloc[:, i], label='Test IK')
        ax.plot(q_pipeline.time,
                q_pipeline.iloc[:, j],
                label='Pipeline IK',
                linestyle='--')
        if gait_cycle:
            ax.set_xlabel('gait cycle (%)')
        else:
            ax.set_xlabel('time (s)')
           '_tz' in q_reference.columns[i]:
            scale = 1
        else:
            scale = 57.295779513

        is_deg = True
        if q_reference.columns[i] in ['pelvis_tx', 'pelvis_ty', 'pelvis_tz']:
            is_deg = False

        position_unit = ''
        if is_deg:
            position_unit = ' (deg)'
        else:
            position_unit = ' (m)'

        d_q = rmse_metric(q_reference.iloc[:, i],  scale * q_rt.iloc[:, j])
        if not np.isnan(d_q):     # NaN when siganl is zero
            d_q_total.append(d_q)

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

        ax.plot(q_reference.time, q_reference.iloc[:, i], label='OpenSim IK')
        ax.plot(q_rt.time, scale * q_rt.iloc[:, j], label='Real-time IK',
                linestyle='--')
        if gait_cycle:
            ax.set_xlabel('gait cycle (%)')
        else:
            ax.set_xlabel('time (s)')

        ax.set_ylabel('generalized coordinates' + position_unit)
        ax.set_title(q_rt.columns[j])
Example #8
0
# %%
# compare

d_q_total = []
d_u_total = []
d_a_total = []
with PdfPages(output_dir + 'filter_comparison.pdf') as pdf:
    for i in range(1, q_reference.shape[1]):
        # if 'mtp' in q_reference.columns[i] or \
        #    'subtalar' in  q_reference.columns[i] or \
        #    'ankle_angle_l' in  q_reference.columns[i]:
        #     # ankle added because it was too noisy
        #     continue

        d_q = rmse_metric(q_reference.iloc[:, i], q_filtered.iloc[:, i])
        d_u = rmse_metric(q_dot_reference.iloc[:, i], q_dot_filtered.iloc[:,
                                                                          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)')