gaitmap.trajectory_reconstruction.ForwardBackwardIntegration#
- class gaitmap.trajectory_reconstruction.ForwardBackwardIntegration(turning_point: float = 0.5, steepness: float = 0.08, level_assumption: bool = True, gravity: ndarray | None = cf(array([0., 0., 9.81])))[source]#
Use forward(-backward) integration of acc to estimate velocity and position.
Warning
We assume that the acc signal is already converted into the global/world frame! Refer to the Coordinate System Guide for details.
This method uses the zero-velocity assumption (ZUPT) to perform a drift removal using a direct-and-reverse (DRI) or forward-backward integration. This means we assume no movement (zero velocity and zero acceleration except gravity) at the beginning and end of the signal.
Further drift correction is applied using a level-assumption (i.e. we assume that the sensor starts and ends its movement at the same z-position/height). If this assumption is not true for your usecase, you can disable it using the
level_assumptionparameter.Implementation based on the paper by Hannink et al. [1] and Zok et al. [2].
- Parameters:
- turning_point
The point at which the sigmoid weighting function has a value of 0.5 and therefore forward and backward integrals are weighted 50/50. Specified as percentage of the signal length (0.0 < turning_point <= 1.0).
- steepness
Steepness of the sigmoid function to weight forward and backward integral.
- level_assumption
If True, it is assumed that the stride starts and ends at z=0 and dedrifting in that direction is applied accordingly.
- gravityOptional (3,) array, or None
The value of gravity that will be subtracted from each Acc sample before integration. If this is
None, no gravity subtraction will be performed. By default 9.81 m/s^2 will be subtracted from the z-Axis.
- Other Parameters:
- data
The data passed to the estimate method.
- sampling_rate_hz
The sampling rate of the data.
- Attributes:
- velocity_
The velocity estimated by direct-and-reverse / forward-backward integration. See Examples for format hints.
- position_
The position estimated by forward integration in the ground plane and by direct-and-reverse / forward-backward integration for the vertical axis. See Examples for format hints.
See also
gaitmap.trajectory_reconstructionOther implemented algorithms for orientation and position estimation
gaitmap.trajectory_reconstruction.StrideLevelTrajectoryApply the method for each stride of a stride list.
Notes
[1]Hannink, J., Ollenschläger, M., Kluge, F., Roth, N., Klucken, J., and Eskofier, B. M. 2017. Benchmarking Foot Trajectory Estimation Methods for Mobile Gait Analysis. Sensors (Basel, Switzerland) 17, 9. https://doi.org/10.3390/s17091940
[2]M. Zok, C. Mazz`a, and U. Della Croce, “Total body centre of mass displacement estimated using ground reactions during transitory motor tasks: Application to step ascent,” Medical Engineering & Physics, vol. 26, no. 9, pp. 791-798, Nov. 2004. [Online]. Available: https://linkinghub.elsevier.com/retrieve/pii/S1350453304001195
Examples
Your data must be a pd.DataFrame with at least columns defined by
SF_ACC. Remember, that this method does not transform your data into another coordinate frame, but just integrates it. If you want to use this method to calculate e.g. a stride length, make sure to cenvert your data into the global frame using any of the implemented orientation estimation methods.>>> import pandas as pd >>> from gaitmap.utils.consts import SF_ACC >>> data = pd.DataFrame(..., columns=SF_ACC) >>> sampling_rate_hz = 100 >>> # Create an algorithm instance >>> fbi = ForwardBackwardIntegration(level_assumption=True, gravity=np.array([0, 0, 9.81])) >>> # Apply the algorithm >>> fbi = fbi.estimate(data, sampling_rate_hz=sampling_rate_hz) >>> # Inspect the results >>> fbi.position_ <pd.Dataframe with resulting positions> >>> fbi.velocity_ <pd.Dataframe with resulting velocities>
Methods
clone()Create a new instance of the class with all parameters copied over.
estimate(data, *, sampling_rate_hz, **_)Estimate the position of the sensor based on the provided global frame data.
from_json(json_str)Import an gaitmap object from its json representation.
get_params([deep])Get parameters for this algorithm.
set_params(**params)Set the parameters of this Algorithm.
to_json()Export the current object parameters as json.
- __init__(turning_point: float = 0.5, steepness: float = 0.08, level_assumption: bool = True, gravity: ndarray | None = cf(array([0., 0., 9.81]))) None[source]#
- clone() Self[source]#
Create a new instance of the class with all parameters copied over.
This will create a new instance of the class itself and all nested objects
- estimate(data: DataFrame, *, sampling_rate_hz: float, **_) Self[source]#
Estimate the position of the sensor based on the provided global frame data.
- Parameters:
- data
Continuous sensor data that includes at least a Acc with all values in the global world frame
- sampling_rate_hz
The sampling rate of the data in Hz
- Returns:
- self
The class instance with all result attributes populated
- classmethod from_json(json_str: str) Self[source]#
Import an gaitmap object from its json representation.
For details have a look at the this example.
You can use the
to_jsonmethod of a class to export it as a compatible json string.- Parameters:
- json_str
json formatted string
- get_params(deep: bool = True) dict[str, Any][source]#
Get parameters for this algorithm.
- Parameters:
- deep
Only relevant if object contains nested algorithm objects. If this is the case and deep is True, the params of these nested objects are included in the output using a prefix like
nested_object_name__(Note the two “_” at the end)
- Returns:
- params
Parameter names mapped to their values.