コード例 #1
0
output_dir = os.path.join(subject_dir, 'real_time/inverse_dynamics/')

tau_reference_file = os.path.join(subject_dir,
                                  'inverse_dynamics/task_InverseDynamics.sto')
tau_rt_file = os.path.join(output_dir, 'tau.sto')

# %%
# read data

tau_reference = read_from_storage(tau_reference_file)
tau_rt = read_from_storage(tau_rt_file)

if gait_cycle:
    t0 = 0.6                        # right heel strike
    tf = 1.83                       # next right heel strike
    tau_reference = to_gait_cycle(tau_reference, t0, tf)
    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)
コード例 #2
0
reconstructed_markers_file = os.path.join(results_dir,
                                          'reconstructed_markers.sto')

if not (os.path.isfile(original_markers_file)
        and os.path.isfile(reconstructed_markers_file)):
    raise RuntimeError('Required files do not exist.')

original_markers = read_from_storage(original_markers_file)
reconstructed_markers = read_from_storage(reconstructed_markers_file)

# %%

if gait_cycle:
    t0 = 0.6  # right heel strike
    tf = 1.83  # next right heel strike
    original_markers = to_gait_cycle(original_markers, t0, tf)
    reconstructed_markers = to_gait_cycle(reconstructed_markers, t0, tf)

    occlusion_start_perc = 100.0 / (tf - t0) * (occlusion_start_time - t0)
    occlusion_stop_perc = 100.0 / (tf - t0) * (occlusion_start_time +
                                               occlusion_duration - t0)

# %%

d_q_total = []
with PdfPages(os.path.join(results_dir,
                           'marker_reconstruction_comparison.pdf')) as pdf:
    reconstructed_markers.columns = [
        c.replace('_1', '_x') for c in reconstructed_markers.columns
    ]
    reconstructed_markers.columns = [
コード例 #3
0
am_rt_file = os.path.join(output_dir, 'am.sto')
tauRes_rt_file = os.path.join(output_dir, 'tauRes.sto')

plot_sto_file(am_rt_file, am_rt_file + '.pdf', 3)
plot_sto_file(tauRes_rt_file, tauRes_rt_file + '.pdf', 3)

# %%
# read data

fm_reference = read_from_storage(fm_reference_file)
fm_rt = read_from_storage(fm_rt_file)

if gait_cycle:
    t0 = 0.6  # right heel strike
    tf = 1.83  # next right heel strike
    fm_reference = to_gait_cycle(fm_reference, t0, tf)
    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)
コード例 #4
0
    'joint_reaction_analysis/task_JointReaction_ReactionLoads.sto')
jr_rt_file = os.path.join(output_dir, 'jr.sto')

# %%
# read data

jr_reference = read_from_storage(jr_reference_file)
jr_rt = read_from_storage(jr_rt_file)
# make very small number zero before plotting
jr_reference[jr_reference.abs() < 1e-9] = 0
jr_rt[jr_reference.abs() < 1e-9] = 0

if gait_cycle:
    t0 = 0.6  # right heel strike
    tf = 1.83  # next right heel strike
    jr_reference = to_gait_cycle(jr_reference, t0, tf)
    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)
コード例 #5
0
q_reference = read_from_storage(q_reference_file, True)
q_dot_reference = read_from_storage(q_dot_reference_file, True)
q_ddot_reference = read_from_storage(q_ddot_reference_file, True)

q_filtered = read_from_storage(q_filtered_file)
q_dot_filtered = read_from_storage(q_dot_filtered_file)
q_ddot_filtered = read_from_storage(q_ddot_filtered_file)

q_filtered_sp = read_from_storage(q_filtered_sp_file)
q_dot_filtered_sp = read_from_storage(q_dot_filtered_sp_file)
q_ddot_filtered_sp = read_from_storage(q_ddot_filtered_sp_file)

if gait_cycle:
    t0 = 0.6  # right heel strike
    tf = 1.83  # next right heel strike
    q_reference = to_gait_cycle(q_reference, t0, tf)
    q_dot_reference = to_gait_cycle(q_dot_reference, t0, tf)
    q_ddot_reference = to_gait_cycle(q_ddot_reference, t0, tf)
    q_filtered = to_gait_cycle(q_filtered, t0, tf)
    q_dot_filtered = to_gait_cycle(q_dot_filtered, t0, tf)
    q_ddot_filtered = to_gait_cycle(q_ddot_filtered, t0, tf)
    q_filtered_sp = to_gait_cycle(q_filtered_sp, t0, tf)
    q_dot_filtered_sp = to_gait_cycle(q_dot_filtered_sp, t0, tf)
    q_ddot_filtered_sp = to_gait_cycle(q_ddot_filtered_sp, t0, tf)

plot_sto_file(q_reference_file, q_reference_file + '.pdf', 2)
plot_sto_file(q_filtered_file, q_filtered_file + '.pdf', 2)

# %%
# compare
コード例 #6
0
# %%

# convert zeros values to NaN for the CoP
right_wrench.p_x = right_wrench.p_x.replace(0.0, float('nan'))
right_wrench.p_y = right_wrench.p_y.replace(0.0, float('nan'))
right_wrench.p_z = right_wrench.p_z.replace(0.0, float('nan'))
left_wrench.p_x = left_wrench.p_x.replace(0.0, float('nan'))
left_wrench.p_y = left_wrench.p_y.replace(0.0, float('nan'))
left_wrench.p_z = left_wrench.p_z.replace(0.0, float('nan'))

# %%

if gait_cycle:
    t0 = t0 + total_time  # right heel strike
    tf = tf + total_time  # next right heel strike
    experimental_grfm = to_gait_cycle(experimental_grfm, t0, tf)
    right_wrench = to_gait_cycle(right_wrench, t0, tf)
    left_wrench = to_gait_cycle(left_wrench, t0, tf)

# %%


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
コード例 #7
0
    # filter type
    filter_type_ext = s[s.find('T') + 1:s.rfind('')]
    if (filter_type_ext == 'lp'):
        filt_type = 'low'
    elif (filter_type_ext == 'hp'):
        filt_type = 'high'
    else:
        raise RuntimeError('Wrong filter type.')

    # %%

    if gait_cycle:
        t0 = 0.6  # right heel strike
        tf = 1.83  # next right heel strike
        q_reference = to_gait_cycle(q_reference, t0, tf)
        q_filtered = to_gait_cycle(q_filtered, t0, tf)

    # %%
    # compare

    d_q_total = []
    with PdfPages(output_dir + 'filter_comparison_' + s + '.pdf') as pdf:
        for i in range(1, q_reference.shape[1]):

            key = q_reference.columns[i]
            j = q_filtered.columns.get_loc(key)

            if key[-2::] in ['tx', 'ty', 'tz']:
                scale = 1
            else:
コード例 #8
0
tau_reference = read_from_storage(tau_reference_file)
tau_pipeline = read_from_storage(tau_pipeline_file)

fm_reference = read_from_storage(fm_reference_file)
fm_pipeline = read_from_storage(fm_pipeline_file)

jr_reference = read_from_storage(jr_reference_file)
jr_pipeline = read_from_storage(jr_pipeline_file)
# make very small number zero before plotting
jr_reference[jr_reference.abs() < 1e-9] = 0
jr_pipeline[jr_pipeline.abs() < 1e-9] = 0

if gait_cycle:
    t0 = 0.6  # right heel strike
    tf = 1.83  # next right heel strike
    q_reference = to_gait_cycle(q_reference, t0, tf)
    q_pipeline = to_gait_cycle(q_pipeline, t0, tf)

    tau_reference = to_gait_cycle(tau_reference, t0, tf)
    tau_pipeline = to_gait_cycle(tau_pipeline, t0, tf)

    fm_reference = to_gait_cycle(fm_reference, t0, tf)
    fm_pipeline = to_gait_cycle(fm_pipeline, t0, tf)

    jr_reference = to_gait_cycle(jr_reference, t0, tf)
    jr_pipeline = to_gait_cycle(jr_pipeline, t0, tf)

# %%
# compare

d_q_total = []
コード例 #9
0
output_dir = os.path.join(subject_dir, 'real_time/inverse_kinematics/')

q_reference_file = os.path.join(subject_dir,
                                'inverse_kinematics/task_InverseKinematics.mot')
q_rt_file = os.path.join(output_dir, 'q.sto')

# %%
# read data

q_reference = read_from_storage(q_reference_file)
q_rt = read_from_storage(q_rt_file)

if gait_cycle:
    t0 = 0.6                        # right heel strike
    tf = 1.83                       # next right heel strike
    q_reference = to_gait_cycle(q_reference, t0, tf)
    q_rt = to_gait_cycle(q_rt, t0, tf)

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

# %%
# compare

d_q_total = []
with PdfPages(output_dir + 'inverse_kinematics_comparison.pdf') as pdf:
    for i in range(1, q_reference.shape[1]):

        # find index
        j = q_rt.columns.get_loc(q_reference.columns[i])

        # deg to rad for rotational degrees of freedom