BaseCadCalculator#

class mobgap.cadence.base.BaseCadCalculator[source]#

Base class for cadence calculation algorithms.

This base class should be used for all cadence calculation algorithms. Algorithms should implement the calculate method, which will perform all relevant processing steps. The method should then return the instance of the class, with the cadence_per_sec_ attribute set to the calculated cadence. Further, the calculate method should set self.data, self.sampling_rate_hz and self.initial_contacts to the parameters passed to the method.

We allow that subclasses specify further parameters for the calculate methods (hence, this baseclass supports **kwargs). However, you should only use them, if you really need them and apply active checks, that they are passed correctly. In 99% of the time, you should add a new parameter to the algorithm itself, instead of adding a new parameter to the calculate method.

Other Parameters:
data

The raw IMU data in the body passed to the calculate method.

initial_contacts

The initial contacts passed to the calculate method.

sampling_rate_hz

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

Attributes:
cadence_per_sec_

The main output of the cadence calculation. It provides a DataFrame with the column cadence_spm that contains the cadence values with one value per full second of the provided data. The unit is 1/min. The index of this dataframe is named sec_center_samples and contains the sample number of the center of the each second.

Notes

You can use the base_cad_docfiller decorator to fill common parts of the docstring for your subclass. See the source of this class for an example.

Methods

calculate(data, *, initial_contacts, ...)

%(calculate_short)s.

clone()

Create a new instance of the class with all parameters copied over.

get_params([deep])

Get parameters for this algorithm.

set_params(**params)

Set the parameters of this Algorithm.

__init__(*args, **kwargs)#
calculate(
data: DataFrame,
*,
initial_contacts: DataFrame,
sampling_rate_hz: float,
**kwargs: Unpack[dict[str, Any]],
) Self[source]#

%(calculate_short)s.

Parameters:
%(calculate_para)s
%(calculate_return)s
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

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.cadence.base.BaseCadCalculator#

The Mobilise-D pipeline: Step-by-Step Breakdown

The Mobilise-D pipeline: Step-by-Step Breakdown

Cadence from Initial Contacts

Cadence from Initial Contacts

Cadence Evaluation

Cadence Evaluation