コード例 #1
0
def compare_walking_moments(files, list_of_index):
    """
      Plots the joint angle during walking
      :param files: sting of file name
      :param list_of_index: which traj to use
      """
    fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
    fig.suptitle('Walking Joint Angles', fontsize=20)
    resample = 100000

    # find resample length to use
    for file, i in zip(files, list_of_index):
        trial = ViconGaitingTrial.ViconGaitingTrial(vicon_file=file)
        joints = trial.vicon.get_model_output().get_right_leg().hip.angle
        sample = len(joints)
        resample = min(resample, sample)

    # grab all the trajs and resample
    for file, i in zip(files, list_of_index):
        trial = ViconGaitingTrial.ViconGaitingTrial(vicon_file=file)
        joints = trial.get_joint_trajectories()
        hip = signal.resample(
            trial.vicon.get_model_output().get_right_leg().hip.moment,
            resample)
        knee = signal.resample(
            trial.vicon.get_model_output().get_right_leg().knee.moment,
            resample)
        ankle = signal.resample(
            trial.vicon.get_model_output().get_right_leg().ankle.moment,
            resample)
        ax1.plot(utilities.smooth(hip, 10))
        ax2.plot(utilities.smooth(knee, 10))
        ax3.plot(utilities.smooth(ankle, 10))

    font_size = 25
    ax1.set_ylabel("Nmm/Kg", fontsize=font_size)
    ax2.set_ylabel("Nmm/Kg", fontsize=font_size)
    ax3.set_ylabel("Nmm/Kg", fontsize=font_size)
    ax1.set_title("Hip", fontsize=font_size)
    ax2.set_title("Knee", fontsize=font_size)
    ax3.set_title("Ankle", fontsize=font_size)
    plt.xlabel("Gait %", fontsize=font_size)

    plt.show()
コード例 #2
0
def plot_joint_angles(files, indecies, sides, lables):
    """

    :param files:
    :param indecies:
    :param sides:
    :param lables:
    :return:
    """
    angles = {}
    angles["hip"] = []
    angles["knee"] = []
    angles["ankle"] = []

    angles2 = {}
    angles2["hip"] = []
    angles2["knee"] = []
    angles2["ankle"] = []

    samples = []
    for file, i, side in zip(files, indecies, sides):
        trial = ViconGaitingTrial.ViconGaitingTrial(vicon_file=file)
        trial.create_index_seperators()
        body = trial.get_joint_trajectories()
        if side == "L":
            hip_angle = body.left.hip[i].angle.x.data
            knee_angle = body.left.knee[i].angle.x.data
            ankle_angle = body.left.ankle[i].angle.x.data
        else:
            hip_angle = body.right.hip[i].angle.x.data
            knee_angle = body.right.knee[i].angle.x.data
            ankle_angle = body.right.ankle[i].angle.x.data

        angles["hip"].append(hip_angle)
        angles["knee"].append(knee_angle)
        angles["ankle"].append(ankle_angle)
        samples.append(len(hip_angle))

    sample_size = min(samples)

    # for i in range(len(files)):
    #     angles2["hip"].append(signal.resample(angles["hip"][i], sample_size))
    #     angles2["knee"].append(signal.resample(angles["knee"][i], sample_size))
    #     angles2["ankle"].append(signal.resample(angles["ankle"][i], sample_size))

    for i in range(len(files)):
        angles2["hip"].append(signal.resample(angles["hip"][i], sample_size))
        angles2["knee"].append(signal.resample(angles["knee"][i], sample_size))
        angles2["ankle"].append(
            signal.resample(angles["ankle"][i], sample_size))

    return angles2
コード例 #3
0
def compare_walking_angles(files, list_of_index):
    """
    Plots the joint angle during walking
    :param files: sting of file name
    :param list_of_index: which traj to use
    """
    fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
    fig.suptitle('Walking Joint Angles', fontsize=20)
    resample = 100000

    # find resample length to use
    for file, i in zip(files, list_of_index):
        trial = ViconGaitingTrial.ViconGaitingTrial(vicon_file=file)
        joints = trial.get_joint_trajectories()
        sample = len(joints["Rhip"][i].angle.data)
        resample = min(resample, sample)

    # grab all the trajs and resample
    for file, i in zip(files, list_of_index):
        trial = ViconGaitingTrial.ViconGaitingTrial(vicon_file=file)
        joints = trial.get_joint_trajectories()
        hip = signal.resample( joints["Rhip"][i].angle.data, resample)
        knee = signal.resample(joints["Rknee"][i].angle.data, resample)
        ankle = signal.resample(joints["Rankle"][i].angle.data, resample)
        ax1.plot(hip)
        ax2.plot(knee)
        ax3.plot(ankle)


    font_size = 25
    ax1.set_ylabel("Degrees", fontsize=font_size)
    ax2.set_ylabel("Degrees", fontsize=font_size)
    ax3.set_ylabel("Degrees", fontsize=font_size)
    ax1.set_title("Hip", fontsize=font_size)
    ax2.set_title("Knee", fontsize=font_size)
    ax3.set_title("Ankle", fontsize=font_size)
    plt.xlabel("Gait %", fontsize=font_size)

    plt.show()
コード例 #4
0
def compare_stair_moments(files, side, legend):
    resample = 100000
    fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
    fig.suptitle('Stair Joint Moments', fontsize=20)

    resample = 1000000000

    indiecs = {}
    for file, s in zip(files, side):
        trial = ViconGaitingTrial.ViconGaitingTrial(file)
        rn = trial.get_stair_ranges(s)
        indiecs[file] = rn
        resample = min(resample, rn[1] - rn[0])

    for file, s in zip(files, side):
        trial = ViconGaitingTrial.ViconGaitingTrial(vicon_file=file)
        if s == "R":
            joints = trial.vicon.get_model_output().right_leg()
        else:
            joints = trial.vicon.get_model_output().left_leg()
        rn = indiecs[file]
        hip = signal.resample(joints.hip.angle.x[rn[0]:rn[1]], resample)
        knee = signal.resample(joints.knee.angle.x[rn[0]:rn[1]], resample)
        ankle = signal.resample(joints.ankle.angle.x[rn[0]:rn[1]], resample)
        ax1.plot(utilities.smooth(hip,10))
        ax2.plot( utilities.smooth(knee,10))
        ax3.plot(utilities.smooth(ankle,10))

    #plt.legend(legend)
    font_size = 25
    ax1.set_ylabel("Nmm/kg", fontsize=font_size)
    ax2.set_ylabel("Nmm/kg", fontsize=font_size)
    ax3.set_ylabel("Nmm/Kg", fontsize=font_size)
    ax1.set_title("Hip", fontsize=font_size)
    ax2.set_title("Knee", fontsize=font_size)
    ax3.set_title("Ankle", fontsize=font_size)
    plt.xlabel("Gait %", fontsize=font_size)

    plt.show()
コード例 #5
0
import sys
import matplotlib.pyplot as plt
import Core.utilities as utilities
from scipy import signal
import numpy as np
from Session import ViconGaitingTrial
import Vicon
import os
file = "/home/nathanielgoldfarb/Downloads/Subject01_ver03.csv"
trial = ViconGaitingTrial.ViconGaitingTrial(vicon_file=file)
joints = trial.get_joint_trajectories()
leg = trial.vicon.get_model_output().get_left_leg()
plt.plot(leg.knee.angle.x)
plt.show()
コード例 #6
0
def plot_joint_angles(files, indecies, sides, lables):
    """

    :param files:
    :param indecies:
    :param sides:
    :param lables:
    :return:
    """
    angles = {}
    angles["hip"] = []
    angles["knee"] = []
    angles["ankle"] = []
    samples = []
    for file, i, side in zip(files, indecies, sides):
        trial = ViconGaitingTrial.ViconGaitingTrial(vicon_file=file)
        trial.create_index_seperators()
        body = trial.get_joint_trajectories()
        if side == "L":
            hip_angle = body.left.hip[i].angle.x.data
            knee_angle = body.left.knee[i].angle.x.data
            ankle_angle = body.left.ankle[i].angle.x.data
        else:
            hip_angle = body.right.hip[i].angle.x.data
            knee_angle = body.right.knee[i].angle.x.data
            ankle_angle = body.right.ankle[i].angle.x.data

        angles["hip"].append(hip_angle)
        angles["knee"].append(knee_angle)
        angles["ankle"].append(ankle_angle)
        samples.append(len(hip_angle))
    SMALL_SIZE = 10
    MEDIUM_SIZE = 10
    BIGGER_SIZE = 18

    plt.rc('font', size=SMALL_SIZE)  # controls default text sizes
    plt.rc('axes', titlesize=BIGGER_SIZE)  # fontsize of the axes title
    plt.rc('axes', labelsize=BIGGER_SIZE)  # fontsize of the x and y labels
    plt.rc('xtick', labelsize=BIGGER_SIZE)  # fontsize of the tick labels
    plt.rc('ytick', labelsize=BIGGER_SIZE)  # fontsize of the tick labels
    plt.rc('legend', fontsize=SMALL_SIZE)  # legend fontsize
    plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title
    f, (ax1_angle, ax2_angle, ax3_angle) = plt.subplots(3, 1)
    sample_size = min(samples)

    ax1_angle.set_title("Hip Angle")
    ax2_angle.set_title("Knee Angle")
    ax3_angle.set_title("Ankle Angle")
    f.suptitle('Walking Joint Angles', fontsize=20)

    ax1_angle.set_ylabel("Angle (Degrees)")
    ax2_angle.set_ylabel("Angle (Degrees)")
    ax3_angle.set_ylabel("Angle (Degrees)")
    t = np.linspace(0,100,sample_size)

    for i in range(len(files)):
        ax1_angle.plot(t, signal.resample(angles["hip"][i], sample_size))
        ax2_angle.plot(t, signal.resample(angles["knee"][i], sample_size))
        ax3_angle.plot(t, signal.resample(angles["ankle"][i], sample_size))

    plt.xlabel("Gait %")
    plt.legend(lables)

    plt.show()