KinematicsData#
- class myoverse.datatypes.KinematicsData(input_data, sampling_frequency)[source]#
Class for storing kinematics data.
- Parameters:
input_data (np.ndarray) –
The raw kinematics data. The shape of the array should be (n_joints, 3, n_samples) or (n_chunks, n_joints, 3, n_samples).
Important
The class will only accept 3D or 4D arrays.
There is no way to check if you actually have it in (n_chunks, n_joints, 3, n_samples) format. Please make sure to provide the correct shape of the data.
sampling_frequency (float) – The sampling frequency of the kinematics data.
- input_data#
The raw kinematics data. The shape of the array should be (n_joints, 3, n_samples) or (n_chunks, n_joints, 3, n_samples). The 3 represents the x, y, and z coordinates of the joints.
- Type:
np.ndarray
- processed_data#
A dictionary where the keys are the names of filters applied to the kinematics data and the values are the processed kinematics data.
- Type:
Dict[str, np.ndarray]
Examples
>>> import numpy as np >>> from myoverse.datatypes import KinematicsData >>> >>> # Create sample kinematics data (16 joints, 3 coordinates, 1000 samples) >>> # Each joint has x, y, z coordinates >>> joint_data = np.random.randn(16, 3, 1000) >>> >>> # Create a KinematicsData object with 100 Hz sampling rate >>> kinematics = KinematicsData(joint_data, 100) >>> >>> # Access the raw data >>> raw_data = kinematics.input_data >>> print(f"Data shape: {raw_data.shape}") Data shape: (16, 3, 1000)
Methods
- plot(representation, nr_of_fingers, wrist_included=True)[source]#
Plots the data.
- Parameters:
representation (str) – The representation to plot. .. important :: The representation should be a 3D tensor with shape (n_joints, 3, n_samples).
nr_of_fingers (int) – The number of fingers to plot.
wrist_included (bool, optional) – Whether the wrist is included in the representation. The default is True. .. note :: The wrist is always the first joint in the representation.
- Raises:
KeyError – If the representation does not exist.
Examples
>>> import numpy as np >>> from myoverse.datatypes import KinematicsData >>> >>> # Create sample kinematics data for a hand with 5 fingers >>> # 16 joints: 1 wrist + 3 joints for each of the 5 fingers >>> joint_data = np.random.randn(16, 3, 100) >>> kinematics = KinematicsData(joint_data, 100) >>> >>> # Plot the kinematics data >>> kinematics.plot('Input', nr_of_fingers=5) >>> >>> # Plot without wrist >>> kinematics.plot('Input', nr_of_fingers=5, wrist_included=False)