IcdShinImproved#
- class mobgap.initial_contacts.IcdShinImproved(axis: Literal['is', 'ml', 'pa', 'norm'] = 'norm')[source]#
Detect initial contacts using the Shin [1] algorithm, with improvements by Ionescu et al. [2].
This algorithm is designed to detect initial contacts from accelerometer signals within a gait sequence. The algorithm filters the accelerometer signal down to its primary frequency components and then detects zero crossings in the filtered signal. These are interpreted as initial contacts.
This is based on the implementation published as part of the mobilised project [3]. However, this implementation deviates from the original implementation in some places. For details, see the notes section and the examples.
- Parameters:
- axis
selecting which part of the accelerometer signal to be used. Can be ‘x’, ‘y’, ‘z’, or ‘norm’. The default is ‘norm’, which is also the default in the original implementation.
- Other Parameters:
- data
The raw IMU data of the gait sequence in the body frame passed to the
detectmethod.- sampling_rate_hz
The sampling rate of the IMU data in Hz passed to the
detectmethod.
- Attributes:
- ic_list_
A pandas dataframe with the indices of the detected initial contacts in the input data. It only has one column,
ic, which contains the indices of the detected initial contacts.- final_filtered_signal_
The downsampled signal after all filter steps. This might be useful for debugging.
- ic_list_internal_
The initial contacts detected on the downsampled signal, before upsampling to the original sampling rate. This can be useful for debugging in combination with the
final_filtered_signal_attribute.
Notes
Points of deviation from the original implementation and their reasons:
Configurable accelerometer signal: on matlab, all axes are used to calculate ICs, here we provide the option to select which axis to use. Despite the fact that the Shin algorithm on matlab uses all axes, here we provide the option of selecting a single axis because other contact detection algorithms use only the horizontal axis.
We use a different downsampling method, which should be “more” correct from a signal theory perspective, but will yield slightly different results.
The matlab code upsamples to 50 Hz before the final detection of 0-crossings. We skip the upsampling of the filtered signal and perform the 0-crossing detection on the downsampled signal. To compensate for the “loss of accuracy” due to the downsampling, we use linear interpolation to determine the exact position of the 0-crossing, even when it occurs between two samples. We then project the interpolated index back to the original sampling rate.
For CWT and gaussian filter, the actual parameter we pass to the respective functions differ from the matlab implementation, as the two languages use different implementations of the functions. However, the similarity of the output was visually confirmed.
All parameters are expressed in the units used in mobgap, as opposed to matlab. Specifically, we use m/s^2 instead of g.
Some early testing indicates, that the python version finds all ICs 5-10 samples earlier than the matlab version. However, this seems to be a relatively consistent offset. Hence, it might be possible to shift/tune this in the future.
[1]Shin, Seung Hyuck, and Chan Gook Park. “Adaptive step length estimation algorithm using optimal parameters and movement status awareness.” Medical engineering & physics 33.9 (2011): 1064-1071.
[2]Paraschiv-Ionescu, A. et al. “Real-world speed estimation using single trunk IMU: methodological challenges for impaired gait patterns”. IEEE EMBC (2020): 4596-4599
Methods
clone()Create a new instance of the class with all parameters copied over.
detect(data, *, sampling_rate_hz, **_)Detect Initial contacts in the passed data.
get_params([deep])Get parameters for this algorithm.
set_params(**params)Set the parameters of this Algorithm.
- 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( ) Self[source]#
Detect Initial contacts in the passed data.
We expect the data to be a single gait sequence. If the data does not contain any gait sequences, the algorithm might behave unexpectedly.
Note
As all other IC algorithms this algorithm technically only allows body-frame data as input. However, as this specific algorithm can run on the norm, we also allow sensor frame data if
self.axis == "norm".- Parameters:
- data
The raw IMU in the body frame.
- sampling_rate_hz
The sampling rate of the IMU data in Hz.
- Returns:
- self
The instance of the class with the
icd_list_attribute set to the detected initial contacts.
- 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.