def process_raw_gyro_data(self, data):
        """ Calculate 160 features
        :param data:
        :return:
        """
        filt_gyro = util.butter_lowpass(data, 20, 50, 3)
        j2 = np.insert(filt_gyro, filt_gyro.shape[0], np.zeros(3), 0)
        j1 = np.insert(filt_gyro, 0, np.zeros(3), 0)
        gyro_jerk = np.delete((j2 - j1) / self._dt, -1, axis=0)
        gyro_mag = np.sqrt(np.sum(filt_gyro ** 2, axis=1))
        gyro_jerk_mag = np.sqrt(np.sum(gyro_jerk ** 2, axis=1))

        # 24 features x 2 = 48
        features = self.process_3d_signal(filt_gyro)
        features = np.vstack((features, self.process_3d_signal(gyro_jerk)))

        # 8 features x 2 = 16
        features = np.vstack((features, self.process_mag_signal(gyro_mag)))
        features = np.vstack((features, self.process_mag_signal(gyro_jerk_mag)))

        # FFT 71 + 12 + 12 = 96
        features = np.vstack((features, self.process_fft_3D_signal(filt_gyro)))
        features = np.vstack((features, self.process_fft_1d_signal(gyro_mag)))
        features = np.vstack((features, self.process_fft_1d_signal(gyro_jerk_mag)))

        #    print("Gyro features extracted" + str(features.shape))
        #    np.savetxt("..\\Tmp\\features.txt", features.T)
        return features, filt_gyro
    def process_raw_acc_data(self, data):
        """ Calculate 274 features
        :param data: num.examples * nuum_col. Num_cal is 3 axes and optionally number of seconds
        :return:
        """
        # remove noise
        body_acc = util.butter_lowpass(data, 20, 50, 3)

        # split into gravity and body signal with lowpass filter
        grav_acc = util.butter_lowpass(body_acc, 0.3, 50, 3)
        body_acc = body_acc - grav_acc

        # print(data.shape)
        j1 = np.insert(body_acc, body_acc.shape[0], np.zeros(3), 0)
        j2 = np.insert(body_acc, 0, np.zeros(3), 0)
        body_acc_jerk = np.delete((j2 - j1) / self._dt, -1, axis=0)
        body_acc_mag = np.sqrt(np.sum(body_acc**2, axis=1))
        grav_acc_mag = np.sqrt(np.sum(grav_acc**2, axis=1))
        body_acc_jerk_mag = np.sqrt(np.sum(body_acc_jerk**2, axis=1))

        # should be 40 features each but is 40 * 3 = 120
        features = self.process_3d_signal(body_acc)
        features = np.vstack((features, self.process_3d_signal(grav_acc)))
        features = np.vstack((features, self.process_3d_signal(body_acc_jerk)))

        # should be 13 features but is 9 * 3 = 33
        features = np.vstack((features, self.process_mag_signal(body_acc_mag)))
        features = np.vstack((features, self.process_mag_signal(grav_acc_mag)))
        features = np.vstack(
            (features, self.process_mag_signal(body_acc_jerk_mag)))

        # FFT 71 + 71 + 12 + 12 = 166
        features = np.vstack((features, self.process_fft_3D_signal(body_acc)))
        features = np.vstack(
            (features, self.process_fft_3D_signal(body_acc_jerk)))

        features = np.vstack(
            (features, self.process_fft_1d_signal(body_acc_mag)))
        features = np.vstack(
            (features, self.process_fft_1d_signal(body_acc_jerk_mag)))

        #    print("Acc features extracted" + str(features.shape))
        return features, body_acc, grav_acc
    def process_raw_compas_data(self, data):
        """ Calculate 160 features
        :param data:
        :return:
        """
        filt_comp = util.butter_lowpass(data, 20, 50, 1)

        # 8 features
        features = self.process_mag_signal(filt_comp)

        # FFT 12
        features = np.vstack((features, self.process_fft_1d_signal(filt_comp)))

        return features, filt_comp