| """Canonical joint name mappings for 6 human motion capture datasets. |
| |
| Maps raw joint names from each dataset to standardised lowercase English |
| anatomical names so that the same body part always receives the same |
| canonical label regardless of data source. |
| |
| Generated: 2026-03-18 |
| Datasets: humanml3d, lafan1, 100style, bandai_namco, cmu_mocap, mixamo |
| """ |
|
|
| from __future__ import annotations |
|
|
| |
| |
| |
|
|
| CANONICAL_MAPS: dict[str, dict[str, str]] = { |
|
|
| |
| |
| |
| |
| "humanml3d": { |
| "pelvis": "pelvis", |
| "left_hip": "left upper leg", |
| "right_hip": "right upper leg", |
| "spine1": "spine lower", |
| "left_knee": "left lower leg", |
| "right_knee": "right lower leg", |
| "spine2": "spine mid", |
| "left_ankle": "left foot", |
| "right_ankle": "right foot", |
| "spine3": "spine upper", |
| "left_foot": "left toe", |
| "right_foot": "right toe", |
| "neck": "neck", |
| "left_collar": "left collar", |
| "right_collar": "right collar", |
| "head": "head", |
| "left_shoulder": "left upper arm", |
| "right_shoulder": "right upper arm", |
| "left_elbow": "left forearm", |
| "right_elbow": "right forearm", |
| "left_wrist": "left hand", |
| "right_wrist": "right hand", |
| }, |
|
|
| |
| |
| |
| |
| "lafan1": { |
| "Hips": "pelvis", |
| "LeftUpLeg": "left upper leg", |
| "LeftLeg": "left lower leg", |
| "LeftFoot": "left foot", |
| "LeftToe": "left toe", |
| "RightUpLeg": "right upper leg", |
| "RightLeg": "right lower leg", |
| "RightFoot": "right foot", |
| "RightToe": "right toe", |
| "Spine": "spine lower", |
| "Spine1": "spine mid", |
| "Spine2": "spine upper", |
| "Neck": "neck", |
| "Head": "head", |
| "LeftShoulder": "left collar", |
| "LeftArm": "left upper arm", |
| "LeftForeArm": "left forearm", |
| "LeftHand": "left hand", |
| "RightShoulder": "right collar", |
| "RightArm": "right upper arm", |
| "RightForeArm": "right forearm", |
| "RightHand": "right hand", |
| }, |
|
|
| |
| |
| |
| |
| "100style": { |
| "Hips": "pelvis", |
| "Chest": "spine lower", |
| "Chest2": "spine mid", |
| "Chest3": "spine upper", |
| "Chest4": "chest", |
| "Neck": "neck", |
| "Head": "head", |
| "RightCollar": "right collar", |
| "RightShoulder": "right upper arm", |
| "RightElbow": "right forearm", |
| "RightWrist": "right hand", |
| "LeftCollar": "left collar", |
| "LeftShoulder": "left upper arm", |
| "LeftElbow": "left forearm", |
| "LeftWrist": "left hand", |
| "RightHip": "right upper leg", |
| "RightKnee": "right lower leg", |
| "RightAnkle": "right foot", |
| "RightToe": "right toe", |
| "LeftHip": "left upper leg", |
| "LeftKnee": "left lower leg", |
| "LeftAnkle": "left foot", |
| "LeftToe": "left toe", |
| }, |
|
|
| |
| |
| |
| |
| "bandai_namco": { |
| "joint_Root": "root", |
| "Hips": "pelvis", |
| "Spine": "spine lower", |
| "Chest": "spine upper", |
| "Neck": "neck", |
| "Head": "head", |
| "Shoulder_L": "left collar", |
| "UpperArm_L": "left upper arm", |
| "LowerArm_L": "left forearm", |
| "Hand_L": "left hand", |
| "Shoulder_R": "right collar", |
| "UpperArm_R": "right upper arm", |
| "LowerArm_R": "right forearm", |
| "Hand_R": "right hand", |
| "UpperLeg_L": "left upper leg", |
| "LowerLeg_L": "left lower leg", |
| "Foot_L": "left foot", |
| "Toes_L": "left toe", |
| "UpperLeg_R": "right upper leg", |
| "LowerLeg_R": "right lower leg", |
| "Foot_R": "right foot", |
| "Toes_R": "right toe", |
| }, |
|
|
| |
| |
| |
| |
| "cmu_mocap": { |
| "Hips": "pelvis", |
| "LHipJoint": "left hip joint", |
| "LeftUpLeg": "left upper leg", |
| "LeftLeg": "left lower leg", |
| "LeftFoot": "left foot", |
| "LeftToeBase": "left toe", |
| "RHipJoint": "right hip joint", |
| "RightUpLeg": "right upper leg", |
| "RightLeg": "right lower leg", |
| "RightFoot": "right foot", |
| "RightToeBase": "right toe", |
| "LowerBack": "spine lower", |
| "Spine": "spine mid", |
| "Spine1": "spine upper", |
| "Neck": "neck lower", |
| "Neck1": "neck", |
| "Head": "head", |
| "LeftShoulder": "left collar", |
| "LeftArm": "left upper arm", |
| "LeftForeArm": "left forearm", |
| "LeftHand": "left hand", |
| "LeftFingerBase": "left finger base", |
| "LeftHandIndex1": "left index 1", |
| "LThumb": "left thumb", |
| "RightShoulder": "right collar", |
| "RightArm": "right upper arm", |
| "RightForeArm": "right forearm", |
| "RightHand": "right hand", |
| "RightFingerBase": "right finger base", |
| "RightHandIndex1": "right index 1", |
| "RThumb": "right thumb", |
| }, |
|
|
| |
| |
| |
| |
| |
| "mixamo": { |
| "mixamorig:Hips": "pelvis", |
| "mixamorig:Spine": "spine lower", |
| "mixamorig:Spine1": "spine mid", |
| "mixamorig:Spine2": "spine upper", |
| "mixamorig:Neck": "neck", |
| "mixamorig:Head": "head", |
| "mixamorig:HeadTop_End": "head top", |
| "LeftEye": "left eye", |
| "RightEye": "right eye", |
| |
| "mixamorig:LeftShoulder": "left collar", |
| "mixamorig:LeftArm": "left upper arm", |
| "mixamorig:LeftForeArm": "left forearm", |
| "mixamorig:LeftHand": "left hand", |
| |
| "mixamorig:LeftHandThumb1": "left thumb 1", |
| "mixamorig:LeftHandThumb2": "left thumb 2", |
| "mixamorig:LeftHandThumb3": "left thumb 3", |
| "mixamorig:LeftHandThumb4": "left thumb 4", |
| |
| "mixamorig:LeftHandIndex1": "left index 1", |
| "mixamorig:LeftHandIndex2": "left index 2", |
| "mixamorig:LeftHandIndex3": "left index 3", |
| "mixamorig:LeftHandIndex4": "left index 4", |
| |
| "mixamorig:LeftHandMiddle1": "left middle 1", |
| "mixamorig:LeftHandMiddle2": "left middle 2", |
| "mixamorig:LeftHandMiddle3": "left middle 3", |
| "mixamorig:LeftHandMiddle4": "left middle 4", |
| |
| "mixamorig:LeftHandRing1": "left ring 1", |
| "mixamorig:LeftHandRing2": "left ring 2", |
| "mixamorig:LeftHandRing3": "left ring 3", |
| "mixamorig:LeftHandRing4": "left ring 4", |
| |
| "mixamorig:LeftHandPinky1": "left pinky 1", |
| "mixamorig:LeftHandPinky2": "left pinky 2", |
| "mixamorig:LeftHandPinky3": "left pinky 3", |
| "mixamorig:LeftHandPinky4": "left pinky 4", |
| |
| "mixamorig:RightShoulder": "right collar", |
| "mixamorig:RightArm": "right upper arm", |
| "mixamorig:RightForeArm": "right forearm", |
| "mixamorig:RightHand": "right hand", |
| |
| "mixamorig:RightHandThumb1": "right thumb 1", |
| "mixamorig:RightHandThumb2": "right thumb 2", |
| "mixamorig:RightHandThumb3": "right thumb 3", |
| "mixamorig:RightHandThumb4": "right thumb 4", |
| |
| "mixamorig:RightHandIndex1": "right index 1", |
| "mixamorig:RightHandIndex2": "right index 2", |
| "mixamorig:RightHandIndex3": "right index 3", |
| "mixamorig:RightHandIndex4": "right index 4", |
| |
| "mixamorig:RightHandMiddle1": "right middle 1", |
| "mixamorig:RightHandMiddle2": "right middle 2", |
| "mixamorig:RightHandMiddle3": "right middle 3", |
| "mixamorig:RightHandMiddle4": "right middle 4", |
| |
| "mixamorig:RightHandRing1": "right ring 1", |
| "mixamorig:RightHandRing2": "right ring 2", |
| "mixamorig:RightHandRing3": "right ring 3", |
| "mixamorig:RightHandRing4": "right ring 4", |
| |
| "mixamorig:RightHandPinky1": "right pinky 1", |
| "mixamorig:RightHandPinky2": "right pinky 2", |
| "mixamorig:RightHandPinky3": "right pinky 3", |
| "mixamorig:RightHandPinky4": "right pinky 4", |
| |
| "mixamorig:LeftUpLeg": "left upper leg", |
| "mixamorig:LeftLeg": "left lower leg", |
| "mixamorig:LeftFoot": "left foot", |
| "mixamorig:LeftToeBase": "left toe", |
| "mixamorig:LeftToe_End": "left toe end", |
| |
| "mixamorig:RightUpLeg": "right upper leg", |
| "mixamorig:RightLeg": "right lower leg", |
| "mixamorig:RightFoot": "right foot", |
| "mixamorig:RightToeBase": "right toe", |
| "mixamorig:RightToe_End": "right toe end", |
| }, |
| } |
|
|
| |
| |
| |
|
|
| def get_canonical_names(joint_names: list[str], dataset_id: str) -> list[str]: |
| """Map a list of raw joint names to their canonical equivalents. |
| |
| Parameters |
| ---------- |
| joint_names : list[str] |
| Raw joint names exactly as they appear in the dataset's skeleton.npz. |
| dataset_id : str |
| One of the keys in ``CANONICAL_MAPS`` (e.g. ``"humanml3d"``). |
| |
| Returns |
| ------- |
| list[str] |
| Canonical names in the same order as *joint_names*. |
| |
| Raises |
| ------ |
| KeyError |
| If *dataset_id* is not recognised or a raw joint name has no mapping. |
| """ |
| if dataset_id not in CANONICAL_MAPS: |
| raise KeyError( |
| f"Unknown dataset_id '{dataset_id}'. " |
| f"Available: {sorted(CANONICAL_MAPS.keys())}" |
| ) |
| mapping = CANONICAL_MAPS[dataset_id] |
| canonical: list[str] = [] |
| for name in joint_names: |
| if name not in mapping: |
| raise KeyError( |
| f"Joint '{name}' has no canonical mapping in dataset " |
| f"'{dataset_id}'. Mapped joints: {sorted(mapping.keys())}" |
| ) |
| canonical.append(mapping[name]) |
| return canonical |
|
|
|
|
| def get_all_canonical_names() -> set[str]: |
| """Return the full set of unique canonical names across all datasets.""" |
| names: set[str] = set() |
| for mapping in CANONICAL_MAPS.values(): |
| names.update(mapping.values()) |
| return names |
|
|
|
|
| def verify_all_datasets() -> dict[str, list[str]]: |
| """Load every skeleton.npz and confirm that all raw names have mappings. |
| |
| Returns a dict ``{dataset_id: [canonical_names]}`` on success. |
| Raises ``KeyError`` if any raw name is unmapped. |
| """ |
| import numpy as np |
| from pathlib import Path |
|
|
| base = Path(__file__).resolve().parents[2] / "data" / "processed" |
| result: dict[str, list[str]] = {} |
| for ds_id in CANONICAL_MAPS: |
| skel = np.load(str(base / ds_id / "skeleton.npz"), allow_pickle=True) |
| raw_names = [str(n) for n in skel["joint_names"]] |
| result[ds_id] = get_canonical_names(raw_names, ds_id) |
| return result |
|
|