IcdHKLeeImproved#

class mobgap.initial_contacts.IcdHKLeeImproved(axis: Literal['is', 'ml', 'pa', 'norm'] = 'norm')[source]#

Detect initial contacts using the HKLee [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 employs morphological operations with closing and opening structural elements to detect signal closings and openings, respectively. Their difference is analyzed to identify instances where R is greater than 0. These regions 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 detect method.

sampling_rate_hz

The sampling rate of the IMU data in Hz passed to the detect method.

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_

(upsampled again in HKLee) 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.

  • 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.

  • The “closing” and “opening” operations are not exactly the same as in the original matlab code. This leads to small differences at the edges of the final signal. This can lead to one additional or one missing IC at the edges of the signal.

  • All parameters are expressed in the units used in mobgap, as opposed to matlab. Specifically, we use m/s^2 instead of g.

Future work:

  • The algorithm can be improved by increasing the threshold of the allowed non-zero values. Currently, only single non-zero sequences are removed. For example, we could include a threshold of the minimum duration (samples) of an initial contact.

[1]

Lee, H-K., et al. “Computational methods to detect step events for normal and pathological gait evaluation using accelerometer.” Electronics letters 46.17 (2010): 1185-1187.

[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.

__init__(
axis: Literal['is', 'ml', 'pa', 'norm'] = 'norm',
) 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,
**_: Unpack[dict[str, Any]],
) 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.

set_params(**params: Any) Self[source]#

Set the parameters of this Algorithm.

To set parameters of nested objects use nested_object_name__para_name=.

Examples using mobgap.initial_contacts.IcdHKLeeImproved#

HKLee algo

HKLee algo