def _make_T_emgs(self): """ Seperates then EMGs data :return: EMGs data :rtype: Bio.side """ joints = {} count = 0 emgs = self.vicon.get_all_t_emg() for key, emg in emgs.items(): joints[key] = [] for inc in self.vicon_set_points: start = emg.get_offset_index(inc[0]) end = emg.get_offset_index(inc[1]) data = emg.get_values()[start:end] data = np.array(data.z) #time = (len(data) / float(self.vicon.length)) * self.dt stamp = Data.Data(data, np.linspace(0, 1.0, len(data))) if self._use_black_list: if count in self._black_list: continue joints[key].append(stamp) count += 1 return joints
def _make_force_plates(self): """ Seperates then force plate data :return: Force plate data :rtype: Dict """ joints = {} plates = self.vicon.get_all_force_plate() for key, item in plates.items(): joints[key] = [] for inc in self.vicon_set_points: start = item.get_offset_index(inc[0]) end = item.get_offset_index(inc[1]) Fx = np.array(item.force.x)[start:end] Fy = np.array(item.force.y)[start:end] Fz = np.array(item.force.z)[start:end] Mx = np.array(item.moment.x)[start:end] My = np.array(item.moment.y)[start:end] Mz = np.array(item.moment.z)[start:end] cx = np.array(item.CoP.x)[start:end] cy = np.array(item.CoP.y)[start:end] cz = np.array(item.CoP.z)[start:end] f = PointArray.PointArray(Fx, Fy, Fz) m = PointArray.PointArray(Mx, My, Mz) c = PointArray.PointArray(cx, cy, cz) data = Newton.Newton(c, f, m, None) # time = (len(Fx) / float(self.vicon.length)) * self.dt stamp = Data.Data(data, np.linspace(0, 1.0, len(Fx))) joints[key].append(stamp) return joints
def _make_joint_trajectories(self): """ Seperates then joint trajs data :return: joint trajectory data :rtype: Dict """ joints = {} count = 0 model = self.vicon.get_model_output() for fnc, side in zip((model.get_left_leg(), model.get_right_leg()), ("L", "R")): for joint_name in ["_hip", "_knee", "_ankle"]: name = side + joint_name[1:] joints[name] = [] for inc in self.vicon_set_points: time = np.linspace(0, 1, (inc[1] - inc[0])) current_joint = fnc.__dict__[joint_name] angleX = Data.Data( np.array(current_joint.angle.x[inc[0]:inc[1]]), time) angleY = Data.Data( np.array(current_joint.angle.y[inc[0]:inc[1]]), time) angleZ = Data.Data( np.array(current_joint.angle.z[inc[0]:inc[1]]), time) angle = PointArray.PointArray(x=angleX, y=angleY, z=angleZ) powerX = Data.Data( np.array(current_joint.power.x[inc[0]:inc[1]]), time) powerY = Data.Data( np.array(current_joint.power.y[inc[0]:inc[1]]), time) powerZ = Data.Data( np.array(current_joint.power.z[inc[0]:inc[1]]), time) power = PointArray.PointArray(x=powerX, y=powerY, z=powerZ) torqueX = Data.Data( np.array(current_joint.moment.x[inc[0]:inc[1]]), time) torqueY = Data.Data( np.array(current_joint.moment.y[inc[0]:inc[1]]), time) torqueZ = Data.Data( np.array(current_joint.moment.z[inc[0]:inc[1]]), time) torque = PointArray.PointArray(x=torqueX, y=torqueY, z=torqueZ) forceX = Data.Data( np.array(current_joint.force.x[inc[0]:inc[1]]), time) forceY = Data.Data( np.array(current_joint.force.y[inc[0]:inc[1]]), time) forceZ = Data.Data( np.array(current_joint.force.z[inc[0]:inc[1]]), time) force = PointArray.PointArray(forceX, forceY, forceZ) stamp = Joint.Joint(angle, force, torque, power) if self._use_black_list: if count in self._black_list: continue joints[name].append(stamp) count += 1 left_leg = Leg.Leg(joints["Rhip"], joints["Rknee"], joints["Rankle"]) right_leg = Leg.Leg(joints["Lhip"], joints["Lknee"], joints["Lankle"]) body = Side.Side(left_leg, right_leg) return body