gaitmap.zupt_detection.ShoeZuptDetector#
- class gaitmap.zupt_detection.ShoeZuptDetector(*, acc_noise_variance: float = 3.5e-09, gyr_noise_variance: float = 1.3e-07, window_length_s: float = 0.15, window_overlap: float | None = 0.5, window_overlap_samples: int | None = None, inactive_signal_threshold: float = 2310129700)[source]#
Detect ZUPTSs using the SHOE algorithm.
This is based on the papers [1] and [2] and uses as weighted sum of the gravity corrected acc and the gyro norm to detect the static moments.
Note
The threshold is heavily dependent on the provided noise levels of the sensors. These values should theoretically be provided in the datasheet of the sensors, but most of the times, it makes sense to grid search the value, as the effective noise level might vary quite a bit. Note, that primarily the relation between the acc and the gyro noise is relevant, as it defines the weighting of the two signals in the ZUPT detection. Default values likely need to be adapted to your specific use case.
- Parameters:
- acc_noise_variance
The variance of the noise of the accelerometer.
- gyr_noise_variance
The variance of the noise of the gyroscope.
- inactive_signal_threshold
Threshold to decide whether a window should be considered as active or inactive. This value heavily depends on the noise levels selected for the other parameters.
- window_length_sint
Length of desired window in seconds. The real window length is calculated as
window_length_samples = round(sampling_rate_hz * window_length_s)- window_overlapfloat
The overlap between two neighboring windows as a fraction of the window length. Must be
0 <= window_overlap < 1. Note that the window length is first converted into samples, before the effective overlap is calculated. The overlap in samples is calculated asoverlap_samples = round(window_length_samples * window_overlap).When
window_overlapis specified,window_overlap_samplesmust beNone.- window_overlap_samplesint
The overlap between two neighboring windows in samples. This can be used as alternative to
window_overlap, when you want to set the overlap independent of the sampling rate. The values can be negative. In this case, it will be interpreted as len(window_length_samples) - window_overlap_samples. This can be helpful if you want to set the overlap to the maximum possible value. Then setwindow_overlap_samplesto -1.When
window_overlap_samplesis specified,window_overlapmust beNone.- window_overlapfloat
The overlap between two neighboring windows as a fraction of the window length. Must be
0 <= window_overlap < 1. Note that the window length is first converted into samples, before the effective overlap is calculated. The overlap in samples is calculated asoverlap_samples = round(window_length_samples * window_overlap)
- Other Parameters:
- data
The data passed to the detect method
- sampling_rate_hz
The sampling rate of this data
- Attributes:
zupts_Get the start and end values of all zupts.
- per_sample_zupts_
A bool array with length
len(data). If the value isTruefor a sample, it is part of a static region.- window_length_samples_
The internally calculated window length in samples. This might be helpful for debugging
- window_overlap_samples_
The internally calculated window overlap in samples. This might be helpful for debugging.
- min_vel_index_
The index of the sample with the minimum velocity. This is calculated as the center of the window with the minimum velocity.
- min_vel_value_
The minimum velocity value. This is calculated as the value of the window with the minimum velocity. If no window is below the threshold, this value is
np.nan. Note, that in this case, min_vel_index is still set to a proper value.
Notes
The default parameters for the noise levels and thresholds are derived based on [2] and a non-exhaustive gridsearch based on level walking data of healthy participants. It is likely that these parameters can be further optimized for a given usecase.
References
[1]I. Skog, J.-O. Nilsson, P. Händel, and J. Rantakokko, “Zero-velocity detection—An algorithm evaluation,” IEEE Trans. Biomed. Eng., vol. 57, no. 11, pp. 2657-2666, Nov. 2010.
Methods
clone()Create a new instance of the class with all parameters copied over.
detect(data, *, sampling_rate_hz, **_)Detect all ZUPT regions in the 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__(*, acc_noise_variance: float = 3.5e-09, gyr_noise_variance: float = 1.3e-07, window_length_s: float = 0.15, window_overlap: float | None = 0.5, window_overlap_samples: int | None = None, inactive_signal_threshold: float = 2310129700) 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
- detect(data: DataFrame, *, sampling_rate_hz: float, **_) Self[source]#
Detect all ZUPT regions in the data.
- Parameters:
- data
The data set holding the imu raw data
- sampling_rate_hz
The sampling rate of the data
- 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.