NStridesCriteria#

class mobgap.wba.NStridesCriteria(
min_strides: int | None = None,
min_strides_left: int | None = None,
min_strides_right: int | None = None,
)[source]#

Min number of strides in the WB.

If any of the three criteria is True the WB is accepted.

Methods

check_include(stride_list, *[, sampling_rate_hz])

Check if a preliminary WB should be considered an actual WB.

check_wb_start_end(stride_list, *, ...[, ...])

Determine the current start and end of the current WB.

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__(
min_strides: int | None = None,
min_strides_left: int | None = None,
min_strides_right: int | None = None,
) None[source]#
check_include(
stride_list: DataFrame,
*,
sampling_rate_hz: float | None = None,
) bool[source]#

Check if a preliminary WB should be considered an actual WB.

Parameters:
preliminary_wb

The preliminary wb including its stride list

sampling_rate_hz

The sampling rate of the data in Hz. This is used to potentially convert values of a stride to seconds if required, assuming that they are in samples. If this is not the case and the values are already in seconds, sampling_rate_hz should set to 1.

Returns:
is_actual_wb

True or False if the preliminary WB should be considered an actual WB

check_wb_start_end(
stride_list: DataFrame,
*,
original_start: int,
current_start: int,
current_end: int,
sampling_rate_hz: float | None = None,
) tuple[int | None, int | None, int | None][source]#

Determine the current start and end of the current WB.

This method is expected to return 3 values:

  • The adjusted start index (or None if no adjustment is required)

  • The adjusted end index (or None if no adjustment is required)

  • The index the WBA should restart the search after the termination. This is often simply current_end, but can be adjusted if you want to allow a new search to start earlier. This might be useful in cases, where the end index was adjusted, but starting a new search directly after the adjusted end would still be meaningfull.

This method gets passed all strides (past and future) of the entire measurement. All this information can be used in the rule. However, looking in the future is discouraged, as this might interfere with other rules.

The method will be called for every end-stride the WBA considers. The method needs to decide, if the new stride (stride_list.iloc[current_end]) should be included in the WB or not. If the stride should be included, the method should return None, None, current_end. If the stride should not be included, the method should return the adjusted end indices (second value). For example, None, current_end - 1, current_end would mean that the stride should not be included and the search for a new WB will start with the stride that was rejected. However, the method can also decide that given the current strides, the WB should be terminated even earlier. In this case, the method can return an arbitrary index as the second value. For example, None, current_end - 2, current_end would mean that the current stride is not part of the WB and the last stride is actively excluded from the WB. However, the search is still restarted with the current stride as the third value is set to current_end. This avoids restarting a new WB, that (depending on the rule), would be terminated immediately again. Sometimes, it makes sense to set the last value to something else than current_end. This would allow to start a new WB earlier or even skip a number of strides, before a new WB can be started. Only very complex rules usually need this.

Parameters:
stride_list

A list of all strides within the measurement.

original_start

The index in the stride list at which the WB was originally started. This is usually the stride after the end of the last WB.

current_start

The index at which the WB actually starts based on all rules so far

current_end

The index at which the WB is supposed to end. This is always the index of the stride that should be considered for the WB.

sampling_rate_hz

The sampling rate of the data in Hz. This is used to potentially convert provided stride value to seconds, assuming that they are in samples.

Returns:
adjusted_start

An optional index of the adjusted start value. If multiple rules adjust the same start value in the same iteration, the one that predicts the latest start is used. If None is returned, this is equivalent to not adjusting the start value and should be the default.

adjusted_end

An optional index of the adjusted end value. If the rule predict that the WB should be terminated - excluding the current stride (current_end) - it should return current_end - 1. If earlier termination times are required the respective index should be returned. In case multiple rules predict a termination, the one with the earliest index is chosen. If the WB should not be terminated either None or current_end should be returned.

restart_index

The index at which the WBA should restart the search for a new WB. By default, this should be current_end, but can be adjusted if the rule wants to allow a new search to start earlier or even later (skipping a number of strides). This value is only considered, if the respective WB-rule is used for the termination of the WB.

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.wba.NStridesCriteria#

Assembling WBs

Assembling WBs