gaitmap.utils.rotations.rotate_dataset#

gaitmap.utils.rotations.rotate_dataset(dataset: DataFrame | dict[Union[collections.abc.Hashable, str], pandas.core.frame.DataFrame], rotation: Rotation | dict[str, scipy.spatial.transform._rotation.Rotation]) DataFrame | dict[Union[collections.abc.Hashable, str], pandas.core.frame.DataFrame][source]#

Apply a rotation to acc and gyro data of a dataset.

Parameters:
dataset

dataframe representing a single or multiple sensors. In case of multiple sensors a df with MultiIndex columns is expected where the first level is the sensor name and the second level the axis names (all sensor frame axis must be present)

rotation

In case a single rotation object is passed, it will be applied to all sensors of the dataset. If a dictionary of rotations is applied, the respective rotations will be matched to the sensors based on the dict keys. If no rotation is provided for a sensor, it will not be modified. Note, that if your rotations are only 90 deg rotations, you can use flip_dataset instead for massive speedups.

Returns:
rotated dataset

This will always be a copy. The original dataframe will not be modified.

See also

gaitmap.utils.rotations.rotate_dataset_series

Apply a series of rotations to a dataset

gaitmap.utils.rotations.flip_dataset

Flip a dataset (only 90 deg rotations allowed)

Examples

This will apply the same rotation to the left and the right foot

>>> dataset = ...  # Sensordata with a left and a right foot sensor
>>> rotate_dataset(dataset, rotation=rotation_from_angle(np.array([0, 0, 1]), np.pi))
<copy of dataset with all axis rotated>

This will apply different rotations to the left and the right foot

>>> dataset = ...  # Sensordata with a left and a right foot sensor (sensors called "left" and "right")
>>> rotate_dataset(dataset, rotation={'left': rotation_from_angle(np.array([0, 0, 1]), np.pi),
...     'right':rotation_from_angle(np.array([0, 0, 1]), np.pi / 2))
<copy of dataset with all axis rotated>

Examples using gaitmap.utils.rotations.rotate_dataset#

Automatic sensor alignment

Automatic sensor alignment

Automatic sensor alignment
Automatic sensor alignment (detailed)

Automatic sensor alignment (detailed)

Automatic sensor alignment (detailed)