Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the range of motion (max. orientation change) to the list of spatial parameters. #54

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ project.
- All orientation and trajectory methods now have a new parameter `rotated_data_` that provides the input data rotated
to the world frame based on the calculated orientation.
(https://github.com/mad-lab-fau/gaitmap/pull/64)
- The Spatial Parameter Calculation now also calculates the "Range of Motion" (i.e. the angle change of the sensor in
the sagittal plane) (https://github.com/mad-lab-fau/gaitmap/pull/54)

### Fixed

Expand Down
19 changes: 18 additions & 1 deletion gaitmap/parameters/_spatial_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
ParamterNames = Literal[
"stride_length",
"gait_velocity",
"max_orientation_change",
"ic_angle",
"tc_angle",
"turning_angle",
Expand Down Expand Up @@ -95,6 +96,10 @@ 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
AKuederle marked this conversation as resolved.
Show resolved Hide resolved
The maximum change of sensor angle in the sagittal plane.
This is similar to the range of motion of the ankle, however, the measured parameter is 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.
Expand Down Expand Up @@ -185,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. orientation change [deg]",
"ic_angle": "ic angle [deg]",
"tc_angle": "tc angle [deg]",
"turning_angle": "turning angle [deg]",
Expand Down Expand Up @@ -302,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)
Expand Down Expand Up @@ -375,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)

Expand All @@ -399,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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"name":"max. lateral excursion [m]",
"type":"number"
},
{
"name":"max. orientation change [deg]",
"type":"number"
},
{
"name":"max. sensor lift [m]",
"type":"number"
Expand Down Expand Up @@ -50,6 +54,7 @@
"gait velocity [m\/s]":1.3354107359,
"ic angle [deg]":22.7361564484,
"max. lateral excursion [m]":0.0341080526,
"max. orientation change [deg]":93.5090803846,
"max. sensor lift [m]":0.1819085811,
"stride length [m]":1.421482131,
"tc angle [deg]":-63.7650923994,
Expand All @@ -61,6 +66,7 @@
"gait velocity [m\/s]":1.2459313413,
"ic angle [deg]":20.6089350977,
"max. lateral excursion [m]":0.0786532985,
"max. orientation change [deg]":92.7841392199,
"max. sensor lift [m]":0.1712718319,
"stride length [m]":1.3505701063,
"tc angle [deg]":-63.8597336317,
Expand All @@ -72,6 +78,7 @@
"gait velocity [m\/s]":1.2606830643,
"ic angle [deg]":22.8204931828,
"max. lateral excursion [m]":0.0570237289,
"max. orientation change [deg]":95.4851211993,
"max. sensor lift [m]":0.1616615509,
"stride length [m]":1.3604050645,
"tc angle [deg]":-63.8651551374,
Expand All @@ -83,6 +90,7 @@
"gait velocity [m\/s]":1.3606148666,
"ic angle [deg]":21.4426663279,
"max. lateral excursion [m]":0.0551545322,
"max. orientation change [deg]":96.156170164,
"max. sensor lift [m]":0.1715049273,
"stride length [m]":1.4416671194,
"tc angle [deg]":-65.0488702313,
Expand All @@ -94,6 +102,7 @@
"gait velocity [m\/s]":1.3341255643,
"ic angle [deg]":21.9957987082,
"max. lateral excursion [m]":0.051243633,
"max. orientation change [deg]":92.9112933889,
"max. sensor lift [m]":0.1743348684,
"stride length [m]":1.4005712711,
"tc angle [deg]":-62.6712922138,
Expand All @@ -105,6 +114,7 @@
"gait velocity [m\/s]":1.3690759024,
"ic angle [deg]":22.1469573753,
"max. lateral excursion [m]":0.037265566,
"max. orientation change [deg]":95.0475998929,
"max. sensor lift [m]":0.1696645315,
"stride length [m]":1.4372622999,
"tc angle [deg]":-63.5638167512,
Expand All @@ -116,6 +126,7 @@
"gait velocity [m\/s]":1.2884750518,
"ic angle [deg]":22.8959885002,
"max. lateral excursion [m]":0.0640207455,
"max. orientation change [deg]":95.5502021834,
"max. sensor lift [m]":0.1561371793,
"stride length [m]":1.346355767,
"tc angle [deg]":-63.5780685381,
Expand All @@ -127,6 +138,7 @@
"gait velocity [m\/s]":1.3189493035,
"ic angle [deg]":24.2413841082,
"max. lateral excursion [m]":0.0945651888,
"max. orientation change [deg]":100.4436894261,
"max. sensor lift [m]":0.1686583438,
"stride length [m]":1.4297204364,
"tc angle [deg]":-67.1927466244,
Expand All @@ -138,6 +150,7 @@
"gait velocity [m\/s]":1.3184743272,
"ic angle [deg]":24.8453665414,
"max. lateral excursion [m]":0.0344301683,
"max. orientation change [deg]":94.7168722981,
"max. sensor lift [m]":0.1720865765,
"stride length [m]":1.4098919807,
"tc angle [deg]":-63.0625954339,
Expand All @@ -149,6 +162,7 @@
"gait velocity [m\/s]":1.2161843449,
"ic angle [deg]":28.684856907,
"max. lateral excursion [m]":0.0918787585,
"max. orientation change [deg]":93.1415219738,
"max. sensor lift [m]":0.156534416,
"stride length [m]":1.2826944263,
"tc angle [deg]":-63.4523638147,
Expand All @@ -160,6 +174,7 @@
"gait velocity [m\/s]":1.1452075604,
"ic angle [deg]":18.5391386395,
"max. lateral excursion [m]":0.0412636591,
"max. orientation change [deg]":90.671933184,
"max. sensor lift [m]":0.1652629007,
"stride length [m]":1.3196727747,
"tc angle [deg]":-61.4821958669,
Expand All @@ -171,6 +186,7 @@
"gait velocity [m\/s]":1.1545455916,
"ic angle [deg]":25.4078290024,
"max. lateral excursion [m]":0.0528117344,
"max. orientation change [deg]":88.58226106,
"max. sensor lift [m]":0.1606334508,
"stride length [m]":1.2402345222,
"tc angle [deg]":-59.4442614396,
Expand All @@ -182,6 +198,7 @@
"gait velocity [m\/s]":1.057756155,
"ic angle [deg]":17.8666506072,
"max. lateral excursion [m]":0.0601031243,
"max. orientation change [deg]":88.368785004,
"max. sensor lift [m]":0.1647956856,
"stride length [m]":1.2447228191,
"tc angle [deg]":-58.8665155495,
Expand All @@ -193,6 +210,7 @@
"gait velocity [m\/s]":1.2875927405,
"ic angle [deg]":20.4579725493,
"max. lateral excursion [m]":0.053969348,
"max. orientation change [deg]":89.3454156609,
"max. sensor lift [m]":0.1671645461,
"stride length [m]":1.4145916338,
"tc angle [deg]":-60.6083385884,
Expand All @@ -204,6 +222,7 @@
"gait velocity [m\/s]":1.2927497545,
"ic angle [deg]":21.2717309203,
"max. lateral excursion [m]":0.0192470921,
"max. orientation change [deg]":90.8289554981,
"max. sensor lift [m]":0.1658156135,
"stride length [m]":1.3823837707,
"tc angle [deg]":-59.9633302109,
Expand All @@ -215,6 +234,7 @@
"gait velocity [m\/s]":1.294129442,
"ic angle [deg]":23.4503636556,
"max. lateral excursion [m]":0.0840855702,
"max. orientation change [deg]":94.8226565764,
"max. sensor lift [m]":0.1707130622,
"stride length [m]":1.3964971029,
"tc angle [deg]":-63.6741171182,
Expand All @@ -226,6 +246,7 @@
"gait velocity [m\/s]":1.2809307585,
"ic angle [deg]":23.2544367414,
"max. lateral excursion [m]":0.0144412804,
"max. orientation change [deg]":92.4992353474,
"max. sensor lift [m]":0.1607973273,
"stride length [m]":1.3759998383,
"tc angle [deg]":-60.8586178094,
Expand All @@ -237,6 +258,7 @@
"gait velocity [m\/s]":1.2750775982,
"ic angle [deg]":27.5404884477,
"max. lateral excursion [m]":0.0593852939,
"max. orientation change [deg]":93.6747459091,
"max. sensor lift [m]":0.1553388762,
"stride length [m]":1.3448084043,
"tc angle [deg]":-62.3295483149,
Expand All @@ -248,6 +270,7 @@
"gait velocity [m\/s]":1.233109565,
"ic angle [deg]":20.6563573718,
"max. lateral excursion [m]":0.0369799298,
"max. orientation change [deg]":90.5659340384,
"max. sensor lift [m]":0.1649115211,
"stride length [m]":1.3727977579,
"tc angle [deg]":-61.062506088,
Expand All @@ -259,6 +282,7 @@
"gait velocity [m\/s]":1.2749211643,
"ic angle [deg]":21.4233389743,
"max. lateral excursion [m]":0.034172302,
"max. orientation change [deg]":94.7906729455,
"max. sensor lift [m]":0.1588980474,
"stride length [m]":1.3882198224,
"tc angle [deg]":-63.5421335544,
Expand All @@ -270,6 +294,7 @@
"gait velocity [m\/s]":1.1736863374,
"ic angle [deg]":21.98346491,
"max. lateral excursion [m]":0.0403026359,
"max. orientation change [deg]":90.767416234,
"max. sensor lift [m]":0.1681384776,
"stride length [m]":1.2779885413,
"tc angle [deg]":-60.9357423118,
Expand All @@ -281,6 +306,7 @@
"gait velocity [m\/s]":1.1845438575,
"ic angle [deg]":20.0429487735,
"max. lateral excursion [m]":0.0262335598,
"max. orientation change [deg]":90.3401407158,
"max. sensor lift [m]":0.1688541826,
"stride length [m]":1.3013787497,
"tc angle [deg]":-60.2432443398,
Expand All @@ -292,6 +318,7 @@
"gait velocity [m\/s]":1.1326107117,
"ic angle [deg]":21.232273353,
"max. lateral excursion [m]":0.0511758113,
"max. orientation change [deg]":92.8682547221,
"max. sensor lift [m]":0.1428495675,
"stride length [m]":1.2719749204,
"tc angle [deg]":-63.337273226,
Expand All @@ -303,6 +330,7 @@
"gait velocity [m\/s]":1.1547455297,
"ic angle [deg]":22.3793347978,
"max. lateral excursion [m]":0.0626115658,
"max. orientation change [deg]":91.6903312341,
"max. sensor lift [m]":0.1655961553,
"stride length [m]":1.2968333586,
"tc angle [deg]":-61.1234160364,
Expand All @@ -314,6 +342,7 @@
"gait velocity [m\/s]":1.1659199813,
"ic angle [deg]":20.2510216055,
"max. lateral excursion [m]":0.0315334981,
"max. orientation change [deg]":89.769605429,
"max. sensor lift [m]":0.1661699317,
"stride length [m]":1.3093827915,
"tc angle [deg]":-60.863996535,
Expand All @@ -325,6 +354,7 @@
"gait velocity [m\/s]":1.0284887397,
"ic angle [deg]":19.7408110096,
"max. lateral excursion [m]":0.037808994,
"max. orientation change [deg]":81.4003468047,
"max. sensor lift [m]":0.1636405596,
"stride length [m]":1.1600629827,
"tc angle [deg]":-54.3419164915,
Expand Down
Loading
Loading