in common/skeleton.py [0:0]
def remove_joints(self, joints_to_remove, dataset):
"""
Remove the joints specified in 'joints_to_remove', both from the
skeleton definition and from the dataset (which is modified in place).
The rotations of removed joints are propagated along the kinematic chain.
"""
valid_joints = []
for joint in range(len(self._parents)):
if joint not in joints_to_remove:
valid_joints.append(joint)
# Update all transformations in the dataset
for subject in dataset.subjects():
for action in dataset[subject].keys():
rotations = dataset[subject][action]['rotations']
for joint in joints_to_remove:
for child in self._children[joint]:
rotations[:, child] = qmul_np(rotations[:, joint], rotations[:, child])
rotations[:, joint] = [1, 0, 0, 0] # Identity
dataset[subject][action]['rotations'] = rotations[:, valid_joints]
index_offsets = np.zeros(len(self._parents), dtype=int)
new_parents = []
for i, parent in enumerate(self._parents):
if i not in joints_to_remove:
new_parents.append(parent - index_offsets[parent])
else:
index_offsets[i:] += 1
self._parents = np.array(new_parents)
self._offsets = self._offsets[valid_joints]
self._compute_metadata()