Example #1
0
def proccess_data(FILE_, DATA, NUM_SAMPLES, LABEL):

    # Remove header, Nan and trash
    data = np.load('DB_1d/' + FILE_ + '.npy')
    Xc_1 = data[:10000, 0]
    Xc_2 = data[10000:, 0]

    print '\nXc_1 cleaned shape ', Xc_1.shape
    print 'Xc_2 cleaned shape ', Xc_2.shape

    #Create temporal serie
    NUM_SAMPLES = 50
    #NUM_COLS = Xc_1.shape[1]

    Xc_1 = mls.generate_envelope(Xc_1, NUM_SAMPLES)
    Xc_2 = mls.generate_envelope(Xc_2, NUM_SAMPLES)

    #Labeling the type of movement
    C = (np.ones(len(Xc_1)) * 0).reshape((len(Xc_1), 1))
    Xc_1 = np.hstack((Xc_1.reshape(Xc_1.shape), C.reshape((len(Xc_1), 1))))

    C = (np.ones(len(Xc_2)) * 1).reshape((len(Xc_2), 1))
    Xc_2 = np.hstack((Xc_2.reshape(Xc_2.shape), C.reshape((len(Xc_2), 1))))

    print 'Xc labeled shape ', Xc_1.shape
    print 'Xc labeled shape ', Xc_2.shape

    # Salving in file on the folder <classifier_data>
    np.save('./preprocessed_data/' + FILE_ + 'op', Xc_1, allow_pickle=False)
    print FILE_ + 'op.npy'

    np.save('./preprocessed_data/' + FILE_ + 'pp', Xc_2, allow_pickle=False)
    print FILE_ + 'pp.npy'

    DATA.append(FILE_ + 'op.npy')
    DATA.append(FILE_ + 'pp.npy')
Example #2
0
def proccess_data(FILE_, DATA, NUM_SAMPLES, LABEL):

    Xc = np.genfromtxt('DB_nd/' + FILE_ + '.txt',
                       delimiter=",",
                       usecols=(1, 2, 3, 4))

    print '\nXc shape ', Xc.shape

    #Create temporal serie
    Xc = mls.generate_envelope(Xc, NUM_SAMPLES)
    print 'Xc temporal-serie shape ', Xc.shape

    #Labeling the type of movement
    C = (np.ones(len(Xc)) * LABEL).reshape((len(Xc), 1))
    Xc = np.hstack((Xc.reshape(Xc.shape), C.reshape((len(Xc), 1))))
    print 'Xc labeled shape ', Xc.shape

    np.save('./preprocessed_data/' + FILE_, Xc, allow_pickle=False)
    print FILE_ + '.npy'

    DATA.append(FILE_ + '.npy')
 def test_generate_envelope(self):
     v1 = np.array([1, 2, 3])
     r1 = generate_envelope(v1, 2)
     expeted = np.array([[1, 2], [2, 3]])
     self.assertTrue((r1 == expeted).all())
Example #4
0
 def test_generate_evnelop_two_channels(self):
     v1 = np.array([[1, 2], [3, 4], [5, 6]])
     r1 = generate_envelope(v1, 2)
     #expected = np.array([[1,3, 2, 4],[3,5, 4,6]])
     expected = np.array([[1, 2, 3, 4], [3, 4, 5, 6]])
     self.assertTrue((r1 == expected).all())