Пример #1
0
        for ex in exer.edict:
            self.edict[ex] = exer.edict[ex]


if __name__ == '__main__':
    from iWalker.Data import Trajectory

    p = Exercises()
    p.from_db(pilot='FSL')
    # p2 = Exercises()
    # p2.from_db(pilot='NOGALES')

    # for v in p.iterator():
    #     data = [v.get_forces()[:, 2]]
    #     # Trajectory(v.get_coordinates()).plot_trajectory(show=True)
    #     trj = Trajectory(v.get_coordinates()).plot_over_trajectory(data)

    # print (len(p.edict))
    # p.delete_patients(['FSL30'])
    # print (len(p.edict))
    # print (len(p2.edict))
    # p.merge(p2)
    # print (len(p.edict))

    for ex in p.iterator():
        ex.classify('speed')

        t = Trajectory(ex.get_coordinates())
        print(t.straightness())
        t.plot_trajectory(show=True)
Пример #2
0
    # e2.delete_patients(['FSL30'])
    #
    # e.merge(e2)

    e.delete_exercises([1425290750])
    # e.delete_exercises([1416241920, 1416241871, 1416409354, 1416391685, 1416933676, 1416918342, 1416391884, 1416391948])
    wlen = 128
    voclen = 3
    ncoefs = 5

    nseries = 0
    lcl = []

    print(len(e.edict))
    for ex in e.iterator():
        t = Trajectory(ex.get_coordinates())
        if t.straightness()[0] < 0.9:
            e.delete_exercises([ex.id])
    print(len(e.edict))

    for ex in e.iterator():
        forces = ex.get_forces()
        if forces.shape[0] > wlen:
            nseries += 1
            if 'FSL' in ex.uid:
                lcl.append('r')
            else:
                lcl.append('g')
        else:
            e.delete_exercises([ex.id])
    print(len(e.edict))
Пример #3
0
                matchYZ[i] = (j, cd)

    return matchXY, matchXZ, matchYZ




if __name__ == '__main__':

    # 'NOGA', 'FSL'
    p = Pacientes()
    e = Exercises()
    p.from_db(pilot='NOGA')
    e.from_db(pilot='NOGA')
    for ex in e.iterator():
        t = Trajectory(ex.get_coordinates())
        if t.straightness()[0] < 0.95:
            e.delete_exercises([ex.id])

    for ex in e.iterator():
        print (ex.uid + '-' + str(ex.id))

        trajec = Trajectory(np.array(ex.frame.loc[:, ['epx', 'epy']]), exer=ex.uid + ' ' + str(ex.id))
        beg, nd, vdis = trajec.find_begginning_end()
        print(beg, nd)

        ltuplesX = segment_signal(ex.frame['rhfx'] - ex.frame['lhfx'], beg, nd)
        ltuplesY = segment_signal(ex.frame['rhfy'] - ex.frame['lhfy'], beg, nd)
        ltuplesZ = segment_signal(ex.frame['rhfz'] - ex.frame['lhfz'], beg, nd)

        # print(ltuplesX)
Пример #4
0
def segmentation(frame, traj=False):
    """
    L-R XYZ forces smoothed with extrema points

    :return:
    """

    vextX = extract_extrema(frame['rhfx'] - frame['lhfx'])
    vextY = extract_extrema(frame['rhfy'] - frame['lhfy'])
    vextZ = extract_extrema(frame['rhfz'] - frame['lhfz'])

    smthsigz = ALS_smoothing(frame['rhfz'] - frame['lhfz'], 1, 0.1)

    # Look for the beggining of the exercise

    trajec = Trajectory(np.array(ex.frame.loc[:, ['epx', 'epy']]),
                        exer=ex.uid + ' ' + str(ex.id))
    beg, nd, vdis = trajec.find_begginning_end()
    print(beg, nd)

    ltuples = segment_signal(frame['rhfz'] - frame['lhfz'], beg, nd)

    plotseg = True
    if plotseg:
        fig = plt.figure(figsize=(60, 20))
        ax = fig.add_subplot(111)
        plt.plot(vdis, smthsigz, c='r')
        plt.plot(vdis, vextX, c='g', marker='o')
        plt.plot(vdis, vextY, c='r', marker='o')
        plt.plot(vdis, vextZ, c='b', marker='o')
        plt.title(ex.uid + '/' + str(ex.id))

        ax.annotate(
            '',
            xy=(vdis[beg], 1),
            xycoords='data',
            xytext=(-15, 25),
            textcoords='offset points',
            arrowprops=dict(facecolor='green', shrink=0.05),
            horizontalalignment='center',
            verticalalignment='bottom',
        )
        ax.annotate(
            '',
            xy=(vdis[nd], vextZ[nd]),
            xycoords='data',
            xytext=(-15, 25),
            textcoords='offset points',
            arrowprops=dict(facecolor='yellow', shrink=0.05),
            horizontalalignment='center',
            verticalalignment='bottom',
        )

        if ltuples is not None:
            for i, j in ltuples:

                ax.annotate(
                    str(i),
                    xy=(vdis[i], vextZ[i]),
                    xycoords='data',
                    xytext=(-15, 25),
                    textcoords='offset points',
                    arrowprops=dict(facecolor='black', shrink=0.03),
                    horizontalalignment='center',
                    verticalalignment='bottom',
                )
                ax.annotate(
                    str(j),
                    xy=(vdis[j], vextZ[j]),
                    xycoords='data',
                    xytext=(-15, 25),
                    textcoords='offset points',
                    arrowprops=dict(facecolor='red', shrink=0.03),
                    horizontalalignment='center',
                    verticalalignment='bottom',
                )
            plt.show()
        else:
            plt.show()

        plt.close()

    if ltuples is not None:
        fig = plt.figure(figsize=(60, 20))
        ax = fig.add_subplot(111)
        plt.plot(vdis, frame['rhfz'], c='r')
        plt.plot(vdis, frame['lhfz'], c='b')
        plt.plot(vdis, frame['lhfx'], c='g')
        plt.plot(vdis, frame['rhfx'], c='y')

        ax.annotate(
            '',
            xy=(vdis[beg], 1),
            xycoords='data',
            xytext=(-15, 25),
            textcoords='offset points',
            arrowprops=dict(facecolor='green', shrink=0.05),
            horizontalalignment='center',
            verticalalignment='bottom',
        )
        ax.annotate(
            '',
            xy=(vdis[nd], vextZ[nd]),
            xycoords='data',
            xytext=(-15, 25),
            textcoords='offset points',
            arrowprops=dict(facecolor='yellow', shrink=0.05),
            horizontalalignment='center',
            verticalalignment='bottom',
        )

        for i, j in ltuples:

            ax.annotate(
                str(i),
                xy=(vdis[i], frame['rhfz'][i]),
                xycoords='data',
                xytext=(-15, 25),
                textcoords='offset points',
                arrowprops=dict(facecolor='black', shrink=0.03),
                horizontalalignment='center',
                verticalalignment='bottom',
            )
            ax.annotate(
                str(j),
                xy=(vdis[j], frame['rhfz'][j]),
                xycoords='data',
                xytext=(-15, 25),
                textcoords='offset points',
                arrowprops=dict(facecolor='red', shrink=0.03),
                horizontalalignment='center',
                verticalalignment='bottom',
            )
        plt.show()
        plt.close()