.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/parameters/spatial_parameters.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_parameters_spatial_parameters.py: .. _example_spatial_parameters: Spatial parameters calculation ============================== This example illustrates illustrates how spatial parameters can be calculated for each stride by the :class:`~gaitmap.parameters.SpatialParameterCalculation`. The used implementation is based on the work of Kanzler et al [1]_ and Rampp et al [2]_. .. [1] Kanzler, C. M., Barth, J., Rampp, A., Schlarb, H., Rott, F., Klucken, J., Eskofier, B. M. (2015, August). Inertial sensor based and shoe size independent gait analysis including heel and toe clearance estimation. In 2015 37th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC) (pp. 5424-5427). IEEE. .. [2] Rampp, A., Barth, J., Schülein, S., Gaßmann, K. G., Klucken, J., & Eskofier, B. M. (2014). Inertial sensor-based stride parameter calculation from gait sequences in geriatric patients. IEEE transactions on biomedical engineering, 62(4), 1089-1097. .. GENERATED FROM PYTHON SOURCE LINES 21-26 Getting input data ------------------ For this we need stride event list obtained from event detection method, position and orientation list obtained from trajectory reconstruction. .. GENERATED FROM PYTHON SOURCE LINES 26-37 .. code-block:: default from gaitmap.example_data import ( get_healthy_example_orientation, get_healthy_example_position, get_healthy_example_stride_events, ) from gaitmap.parameters import SpatialParameterCalculation stride_list = get_healthy_example_stride_events() positions = get_healthy_example_position() orientations = get_healthy_example_orientation() .. GENERATED FROM PYTHON SOURCE LINES 38-43 Preparing the data ------------------ Orientation and position are sampled at 100 Hz as they are derived from mocap data. The stride list is aligned with the IMU samples (204.8 Hz). Therefore, we need to convert the sampling rate for the stride list to be compatible with position and orientation. .. GENERATED FROM PYTHON SOURCE LINES 43-50 .. code-block:: default converted_stride_list = {} for sensor, strides in stride_list.items(): converted_stride_list[sensor] = strides.set_index("s_id").mul(100 / 204.8).round().astype("Int64") stride_list = converted_stride_list .. GENERATED FROM PYTHON SOURCE LINES 51-54 Creating SpatialParameterCalculation object ------------------------------------------- We need this object for calculating the spatial parameters. .. GENERATED FROM PYTHON SOURCE LINES 54-58 .. code-block:: default p = SpatialParameterCalculation() p = p.calculate(stride_event_list=stride_list, positions=positions, orientations=orientations, sampling_rate_hz=100) .. GENERATED FROM PYTHON SOURCE LINES 59-64 Inspecting the results ---------------------- The main output is the `parameters_`, which contains the spatial parameters for each stride in format of data frame in case of single sensor or dictionary of data frames for multiple sensors. As our passed stride_list here consists of two sensors, the output will be a dictionary. .. GENERATED FROM PYTHON SOURCE LINES 64-66 .. code-block:: default p.parameters_["left_sensor"] .. raw:: html
arc_length gait_velocity ic_angle max_lateral_excursion max_orientation_change max_sensor_lift stride_length tc_angle turning_angle
s_id
0 1.551336 1.304694 31.341649 0.037907 90.273736 0.230113 1.396022 -57.449568 -0.847536
1 1.557407 1.306463 30.217489 0.052585 90.508119 0.230177 1.397916 -57.779914 2.431839
2 1.581696 1.327713 33.364893 0.038355 93.115220 0.227605 1.420653 -57.884926 -1.068458
3 1.581874 1.322211 32.826192 0.052619 94.994063 0.231756 1.414765 -60.605447 1.418711
4 1.588506 1.35719 31.644281 0.053196 88.928298 0.228316 1.425050 -52.730850 -0.696435
5 1.601673 1.369327 32.093232 0.045197 90.860257 0.231185 1.437793 -56.677996 1.148086
6 1.603018 1.377332 31.653487 0.047548 90.547222 0.233719 1.446199 -55.699391 -0.751054
7 1.613106 1.349747 33.056158 0.066245 89.254958 0.233695 1.444230 -55.125864 2.367373
8 1.582760 1.31039 30.680655 0.038741 90.028285 0.232082 1.415221 -51.563416 0.118047
9 1.537512 1.276349 32.483550 0.042677 89.327811 0.227329 1.378457 -55.372066 -1.148422
10 1.484822 1.207296 31.927522 0.026986 88.742457 0.221525 1.328025 -56.814935 -4.841572
11 1.488537 1.198343 31.833930 0.047310 85.481615 0.221396 1.318177 -50.893184 -0.330903
12 1.478344 1.12722 32.054301 0.052482 84.449672 0.223780 1.296303 -44.846466 -1.154617
13 1.697819 0.205299 -26.177910 0.602695 45.951556 0.150593 0.468082 -25.935349 -166.322326
14 1.541493 1.192787 -31.241248 0.014819 95.155874 0.229849 1.383633 59.688229 -11.755454
15 1.546868 1.255387 -32.130055 0.049132 88.663217 0.221836 1.380925 48.587683 -3.250563
16 1.562865 1.312509 -32.943188 0.016744 92.130044 0.221109 1.404385 51.039403 4.254341
17 1.609458 1.330787 -32.892909 0.059461 90.338997 0.231328 1.437250 51.148763 3.190712
18 1.573855 1.324743 -33.098392 0.013983 92.811379 0.226108 1.404228 57.248321 -1.209358
19 1.572994 1.302716 -33.639738 0.033045 90.556265 0.222304 1.406933 56.007658 -0.000964
20 1.511498 1.228517 -32.214021 0.036579 90.045474 0.220584 1.339083 54.792416 -0.255400
21 1.539912 1.25378 -33.367350 0.039426 92.697716 0.220686 1.366620 54.989109 -1.828305
22 1.502812 1.212846 -30.780993 0.036905 87.325563 0.228289 1.334131 50.147141 0.409310
23 1.504343 1.206246 -31.148819 0.025703 88.297088 0.225588 1.338933 53.209872 2.333753
24 1.512405 1.21277 -31.993676 0.039298 89.074205 0.220820 1.346174 55.071943 -1.863167
25 1.502292 1.193141 -32.192790 0.051573 88.076743 0.222772 1.336317 48.825681 1.659710
26 1.456642 1.149952 -31.964229 0.028782 87.303691 0.220247 1.299446 54.532540 -2.987568
27 1.316825 1.028979 -30.933646 0.041233 79.972601 0.211285 1.162746 42.210693 -10.672308


.. GENERATED FROM PYTHON SOURCE LINES 67-68 `parameters_pretty_` is another version of `parameters_` but using human readable column names that indicate units. .. GENERATED FROM PYTHON SOURCE LINES 68-69 .. code-block:: default p.parameters_pretty_["left_sensor"] .. raw:: html
arc length [m] gait velocity [m/s] ic angle [deg] max. lateral excursion [m] max. orientation change [deg] max. sensor lift [m] stride length [m] tc angle [deg] turning angle [deg]
stride id
0 1.551336 1.304694 31.341649 0.037907 90.273736 0.230113 1.396022 -57.449568 -0.847536
1 1.557407 1.306463 30.217489 0.052585 90.508119 0.230177 1.397916 -57.779914 2.431839
2 1.581696 1.327713 33.364893 0.038355 93.115220 0.227605 1.420653 -57.884926 -1.068458
3 1.581874 1.322211 32.826192 0.052619 94.994063 0.231756 1.414765 -60.605447 1.418711
4 1.588506 1.35719 31.644281 0.053196 88.928298 0.228316 1.425050 -52.730850 -0.696435
5 1.601673 1.369327 32.093232 0.045197 90.860257 0.231185 1.437793 -56.677996 1.148086
6 1.603018 1.377332 31.653487 0.047548 90.547222 0.233719 1.446199 -55.699391 -0.751054
7 1.613106 1.349747 33.056158 0.066245 89.254958 0.233695 1.444230 -55.125864 2.367373
8 1.582760 1.31039 30.680655 0.038741 90.028285 0.232082 1.415221 -51.563416 0.118047
9 1.537512 1.276349 32.483550 0.042677 89.327811 0.227329 1.378457 -55.372066 -1.148422
10 1.484822 1.207296 31.927522 0.026986 88.742457 0.221525 1.328025 -56.814935 -4.841572
11 1.488537 1.198343 31.833930 0.047310 85.481615 0.221396 1.318177 -50.893184 -0.330903
12 1.478344 1.12722 32.054301 0.052482 84.449672 0.223780 1.296303 -44.846466 -1.154617
13 1.697819 0.205299 -26.177910 0.602695 45.951556 0.150593 0.468082 -25.935349 -166.322326
14 1.541493 1.192787 -31.241248 0.014819 95.155874 0.229849 1.383633 59.688229 -11.755454
15 1.546868 1.255387 -32.130055 0.049132 88.663217 0.221836 1.380925 48.587683 -3.250563
16 1.562865 1.312509 -32.943188 0.016744 92.130044 0.221109 1.404385 51.039403 4.254341
17 1.609458 1.330787 -32.892909 0.059461 90.338997 0.231328 1.437250 51.148763 3.190712
18 1.573855 1.324743 -33.098392 0.013983 92.811379 0.226108 1.404228 57.248321 -1.209358
19 1.572994 1.302716 -33.639738 0.033045 90.556265 0.222304 1.406933 56.007658 -0.000964
20 1.511498 1.228517 -32.214021 0.036579 90.045474 0.220584 1.339083 54.792416 -0.255400
21 1.539912 1.25378 -33.367350 0.039426 92.697716 0.220686 1.366620 54.989109 -1.828305
22 1.502812 1.212846 -30.780993 0.036905 87.325563 0.228289 1.334131 50.147141 0.409310
23 1.504343 1.206246 -31.148819 0.025703 88.297088 0.225588 1.338933 53.209872 2.333753
24 1.512405 1.21277 -31.993676 0.039298 89.074205 0.220820 1.346174 55.071943 -1.863167
25 1.502292 1.193141 -32.192790 0.051573 88.076743 0.222772 1.336317 48.825681 1.659710
26 1.456642 1.149952 -31.964229 0.028782 87.303691 0.220247 1.299446 54.532540 -2.987568
27 1.316825 1.028979 -30.933646 0.041233 79.972601 0.211285 1.162746 42.210693 -10.672308


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.946 seconds) **Estimated memory usage:** 9 MB .. _sphx_glr_download_auto_examples_parameters_spatial_parameters.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: spatial_parameters.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: spatial_parameters.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_