Пример #1
0
def compute_angle(Xs, Bs, Cs, b, c, feature_key):
    a = utils.distance(Bs, Cs)
    if utils.is_number(b):
        b = np.repeat(b, a.shape[0])
    if utils.is_number(c):
        c = np.repeat(c, a.shape[0])
    angles = angle(a, b, c)
    return dataframe(Xs, feature_key, angles)
Пример #2
0
def compute_shoulder_horizontal(participant,
                                Xs,
                                calibration,
                                y,
                                key='shoulder_horizontal'):
    Bs = Xs[['upperarm.X', 'upperarm.Z']].values
    anker = calibration.iloc[2][['upperarm.X', 'upperarm.Z']].values
    Cs = np.tile(anker, (Bs.shape[0], 1))
    origin = Xs[['rightShoulder.X', 'rightShoulder.Z']].values
    b = utils.distance(origin, Cs)
    c = participant.upperarmLength - participant.upperarmMarkerDist
    return compute_angle(Xs, Bs, Cs, b, c, key)
Пример #3
0
def compute_shoulder_abduction(participant,
                               Xs,
                               calibration,
                               y,
                               key='shoulder_abduction'):
    Bs = Xs[['upperarm.X', 'upperarm.Y']].values
    anker = calibration.iloc[0][['upperarm.X', 'upperarm.Y']].values
    Cs = np.tile(anker, (Bs.shape[0], 1))
    origin = Xs[['rightShoulder.X', 'rightShoulder.Y']]
    # origin['rightShoulder.X'] -= participant['rightShoulderMarkerDist.X']
    # origin['rightShoulder.Y'] += participant['rightShoulderMarkerDist.Y']
    b = utils.distance(origin.values, Cs)
    c = participant.upperarmLength - participant.upperarmMarkerDist
    return compute_angle(Xs, Bs, Cs, b, c, key)
Пример #4
0
def compute_velocity(Xs, field='indexfinger', key='indexfinger_velocity'):
    As = Xs[utils.body_field(field)].values
    As = np.vstack((As, [0, 0, 0]))
    Bs = np.roll(As, 1, axis=0)
    # remove first because it is 0 anyways, last because it got appended
    distances = utils.distance(As, Bs)[1:-1]
    As = Xs['time'].values
    As = np.hstack((As, [0]))
    Bs = np.roll(As, 1, axis=0)
    # remove first because it is 0 anyways, last because it got appended
    times = (As - Bs)[1:-1]
    velocity = np.divide(distances, times)
    # add a zero to begin with
    velocity = np.hstack(([0], velocity))
    return dataframe(Xs, key, velocity)
 def compute_distance(xs):
     xs[('dist',
         'real_mean')] = utils.distance(np.array([list(xs.name)]),
                                        np.array([list(xs['pred'])]))[0]
     return xs
Пример #6
0
def compute_distance(Xs, key, field_A, field_B):
    As = Xs[utils.body_field(field_A)].values
    Bs = Xs[utils.body_field(field_B)].values
    distances = utils.distance(As, Bs)
    return dataframe(Xs, key, distances)
 def delta(X, field, d=True):
     s = X[field].values
     t = np.roll(s, 1, axis=0)
     t[0] = s[0]
     return utils.distance(t, s) if d else s - t