Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the range of motion (max. orientation change) to the list of s…
Browse files Browse the repository at this point in the history
…patial parameters.
HaMora committed Jan 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 4683032 commit cc15db1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion gaitmap/parameters/_spatial_parameters.py
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
ParamterNames = Literal[
"stride_length",
"gait_velocity",
"max_orientation_change",
"ic_angle",
"tc_angle",
"turning_angle",
@@ -93,6 +94,9 @@ class SpatialParameterCalculation(BaseSpatialParameterCalculation):
Arc Length
The overall arc length is directly calculated from the position of the sensor by adding the absolute changes in
position at every time point.
Max. orientation change
The maximum change of angle in the sagittal plane. It is similar to the range of motion, however, the measured
parameter is value effected by other joints such as knee and hip as well.
Turning Angle
The turning angle is calculated as the difference in orientation of the forward direction between the first
and the last sample of each stride.
@@ -186,6 +190,7 @@ def _rename_columns(parameters: pd.DataFrame) -> pd.DataFrame:
pretty_columns = {
"stride_length": "stride length [m]",
"gait_velocity": "gait velocity [m/s]",
"max_orientation_change": "max. angle change [deg]",
"ic_angle": "ic angle [deg]",
"tc_angle": "tc angle [deg]",
"turning_angle": "turning angle [deg]",
@@ -303,7 +308,7 @@ def _calculate_single_sensor(
parameters_
Data frame containing spatial parameters of single sensor
sole_angle_course_
The sole angle in the sagttial plane for each stride
The sole angle in the sagittal plane for each stride
"""
stride_event_list = set_correct_index(stride_event_list, SL_INDEX)
@@ -376,6 +381,9 @@ def _ori_based_parameters(self, orientations, stride_event_list, angle_course):
else:
warnings.warn("TC angle could not be calculated as TC event is not available.")

if self._should_calculate("max_orientation_change"):
param_dict["max_orientation_change"] = _get_max_angle_change(sagittal_angles=angle_course + 90)

if self._should_calculate("turning_angle"):
param_dict["turning_angle"] = _calc_turning_angle(orientations)

@@ -400,6 +408,14 @@ def _get_angle_at_index(angle_course: pd.Series, index_per_stride: pd.Series) ->
return angle_course[indexer].reset_index(level=1, drop=True)


def _get_max_angle_change(sagittal_angles: pd.Series) -> pd.Series:
# get the maximum change in the orientation in sagittal plane. the sagittal angle is equal to the angle_course +90
# degrees. This parameter can have a value between 0 and 180.
max_angle = sagittal_angles.groupby(level="s_id").max()
min_angle = sagittal_angles.groupby(level="s_id").min()
return max_angle - min_angle


def _calc_turning_angle(orientations: pd.DataFrame) -> pd.Series:
# We need to handle the case of empty orientations df manually
if orientations.empty:

0 comments on commit cc15db1

Please sign in to comment.