MobilisedPipelineHealthy#

class mobgap.pipeline.MobilisedPipelineHealthy(
*,
gait_sequence_detection: ~mobgap.gait_sequences.base.BaseGsDetector = cf(GsdIluz(acc_v_standing_threshold=4.903325,
allowed_acc_v_change_per_window=0.15,
allowed_steps_per_s=(0.5,
3),
mean_activity_threshold=-0.980665,
min_gsd_duration_s=5,
pre_filter=FirFilter(cutoff_freq_hz=(0.5,
3),
filter_type='bandpass',
order=200,
window='hamming',
zero_phase=True),
sin_template_freq_hz=2,
std_activity_threshold=0.0980665,
step_detection_thresholds=(3.92266,
14.709975),
window_length_s=3,
window_overlap=0.5)),
initial_contact_detection: ~mobgap.initial_contacts.base.BaseIcDetector = cf(IcdIonescu(cwt_width=9.0,
pre_filter=EpflDedriftedGaitFilter(zero_phase=True))),
laterality_classification: ~mobgap.laterality.base.BaseLRClassifier = cf(LrcUllrich(clf_pipe=Pipeline(steps=[('scaler_old',
MinMaxScaler()),
('clf_old',
SVC(C=0.1,
kernel='linear'))]),
smoothing_filter=ButterworthFilter(cutoff_freq_hz=(0.5,
2),
filter_type='bandpass',
order=4,
zero_phase=True))),
cadence_calculation: ~mobgap.cadence.base.BaseCadCalculator | None = cf(CadFromIcDetector(ic_detector=IcdShinImproved(axis='norm'),
max_interpolation_gap_s=3,
silence_ic_warning=True,
step_time_smoothing=HampelFilter(half_window_size=2,
n_sigmas=3.0))),
stride_length_calculation: ~mobgap.stride_length.base.BaseSlCalculator | None = cf(SlZijlstra(acc_smoothing=ButterworthFilter(cutoff_freq_hz=0.1,
filter_type='highpass',
order=4,
zero_phase=True),
max_interpolation_gap_s=3,
orientation_method=None,
speed_smoothing=ButterworthFilter(cutoff_freq_hz=1,
filter_type='highpass',
order=4,
zero_phase=True),
step_length_scaling_factor=1.14675,
step_length_smoothing=HampelFilter(half_window_size=2,
n_sigmas=3.0))),
walking_speed_calculation: ~mobgap.walking_speed.base.BaseWsCalculator | None = cf(WsNaive()),
turn_detection: ~mobgap.turning.base.BaseTurnDetector | None = cf(TdElGohary(allowed_turn_angle_deg=(45,
inf),
allowed_turn_duration_s=(0.5,
10),
lower_threshold_velocity_dps=5,
min_gap_between_turns_s=0.05,
min_peak_angle_velocity_dps=15,
orientation_estimation=None,
smoothing_filter=ButterworthFilter(cutoff_freq_hz=0.5,
filter_type='lowpass',
order=4,
zero_phase=True))),
stride_selection: ~mobgap.wba._stride_selection.StrideSelection = cf(StrideSelection(incompatible_rules='warn',
rules=[('stride_duration_thres',
IntervalDurationCriteria(inclusive=(False,
True),
max_duration_s=3.0,
min_duration_s=0.2)),
('stride_length_thres',
IntervalParameterCriteria(inclusive=(False,
True),
lower_threshold=0.15,
parameter='stride_length_m',
upper_threshold=None))])),
wba: ~mobgap.wba._wb_assembly.WbAssembly = cf(WbAssembly(rules=[('min_strides',
NStridesCriteria(min_strides=4,
min_strides_left=3,
min_strides_right=3)),
('max_break',
MaxBreakCriteria(consider_end_as_break=True,
max_break_s=3,
remove_last_ic=False))])),
dmo_thresholds: ~pandas.core.frame.DataFrame | None = cf(condition                free_living              ...     global          threshold_type                   min         max  ...        min      max dmo               cohort                          ...                     cadence_spm       CHF      40.594770  167.942930  ...  40.000000  172.900                   COPD     38.880484  151.558718  ...  40.000000  172.900                   HA       35.751898  156.946955  ...  40.000000  172.900                   MS       38.443211  155.394496  ...  40.000000  172.900                   PD       40.957969  142.121947  ...  40.000000  172.900                   PFF      42.191719  157.613665  ...  40.000000  172.900 walking_speed_mps CHF       0.112478    1.757103  ...   0.081515    2.220                   COPD      0.090731    1.641773  ...   0.081515    2.220                   HA        0.097413    1.965728  ...   0.081515    2.220                   MS        0.085918    1.920262  ...   0.081515    2.220                   PD        0.081515    1.735348  ...   0.081515    2.220                   PFF       0.104547    1.553186  ...   0.081515    2.220 stride_length_m   CHF       0.185308    2.166646  ...   0.150523    2.190                   COPD      0.176403    1.711645  ...   0.150523    2.190                   HA        0.155126    2.024694  ...   0.150523    2.190                   MS        0.191099    1.940537  ...   0.150523    2.190                   PD        0.150523    1.982926  ...   0.150523    2.190                   PFF       0.206787    1.697251  ...   0.150523    2.190 stride_duration_s CHF       0.702000    3.030857  ...   0.460000    3.000                   COPD      0.770000    3.000000  ...   0.460000    3.000                   HA        0.735435    3.254400  ...   0.460000    3.000                   MS        0.775597    3.057750  ...   0.460000    3.000                   PD        0.836253    2.928000  ...   0.460000    3.000                   PFF       0.744000    2.769000  ...   0.460000    3.000 step_duration_s   CHF       0.376000    1.504500  ...   0.140000    2.124                   COPD      0.390400    1.788000  ...   0.140000    2.124                   HA        0.367972    1.730400  ...   0.140000    2.124                   MS        0.388084    1.905000  ...   0.140000    2.124                   PD        0.417216    1.605600  ...   0.140000    2.124                   PFF       0.371429    2.124000  ...   0.140000    2.124  [30 rows x 8 columns]),
dmo_aggregation: ~mobgap.aggregation.base.BaseAggregator = cf(MobilisedAggregator(groupby=None,
unique_wb_id_column='wb_id',
use_original_names=False)),
recommended_cohorts: tuple[str,
...] | None = cf(('HA',
'COPD',
'CHF')),
)[source]#

Official Mobilise-D pipeline for healthy and mildly impaired gait (aka P1 pipeline).

Note

When using this pipeline with its default parameters with healthy participants or participants with COPD or congestive heart failure, the use of the name “the Mobilise-D pipeline” is recommended.

Based on the benchmarking performed in [1], the algorithms selected for this pipeline are the optimal choice for healthy and mildly impaired gait or more specifically for the cohorts “HA”, “COPD”, “CHF” within the Mobilise-D validation study. Performance metrics for the original implementation of this pipeline can be found in [2]. This pipeline is referred to as the “P1” pipeline in the context of this and other publications.

For detailed steps on how this pipeline works, check the Notes section and the dedicated examples.

Parameters:
gait_sequence_detection

A valid instance of a gait sequence detection algorithm. This will get the entire raw data as input. The core output is available via the gs_list_ attribute.

initial_contact_detection

A valid instance of an initial contact detection algorithm. This will run on each gait sequence individually. The concatenated raw ICs are available via the raw_ic_list_ attribute.

laterality_classification

A valid instance of a laterality classification algorithm. This will run on each gait sequence individually, getting the predicted ICs from the IC detection algorithm as input. The concatenated raw ICs with L/R label are available via the raw_ic_list_ attribute.

cadence_calculation

A valid instance of a cadence calculation algorithm. This will run on each “refined” gait sequence individually. This means the provided gait sequence will start and end at the first and last detected IC. The detected ICs (with L/R label) and all ParticipantMetadata parameters are provided as keyword arguments. The concatenated raw cadence per second values are available via the raw_per_sec_parameters_ attribute.

stride_length_calculation

A valid instance of a stride length calculation algorithm. This will run on each “refined” gait sequence individually. This means the provided gait sequence will start and end at the first and last detected IC. The detected ICs (with L/R label) and all ParticipantMetadata parameters are provided as keyword arguments. The concatenated raw stride length per second values are available via the raw_per_sec_parameters_ attribute.

walking_speed_calculation

A valid instance of a walking speed calculation algorithm. This will run on each “refined” gait sequence individually. This means the provided gait sequence will start and end at the first and last detected IC. The detected ICs (with L/R label), cadence per second, stride length per second values and all ParticipantMetadata parameters are provided as keyword arguments. The concatenated raw walking speed per second values are available via the raw_per_sec_parameters_ attribute.

Note

If either cadence or stride length is not provided, None will be passed to the algorithm. Depending on the algorithm, this might raise an error, as the information is required.

turn_detection

A valid instance of a turn detection algorithm. This will run on each gait sequence individually. The concatenated raw turn detections are available via the raw_turn_list_ attribute.

stride_selection

A valid instance of a stride selection algorithm. This will be called with all interpolated stride parameters (raw_per_stride_parameters_) across all gait sequences.

wba

A valid instance of a walking bout assembly algorithm. This will be called with the filtered stride list from the stride selection algorithm. The final list of strides that are part of a valid WB are available via the per_stride_parameters_ attribute. The aggregated parameters for each WB are available via the per_wb_parameters_ attribute.

dmo_thresholds

A DataFrame with the thresholds for the individual DMOs. To learn more about the required structure and the filtering process, please refer to the documentation of the get_mobilised_dmo_thresholds and apply_thresholds.

dmo_aggregation

A valid instance of a DMO aggregation algorithm. This will be called with the aggregated parameters for each WB and the mask of the DMOs. The final aggregated parameters are available via the aggregated_parameters_ attribute.

recommended_cohorts

A tuple of recommended cohorts for this pipeline. If a datapoint is provided with a cohort that is not part of this tuple, a warning will be raised. This can also be used in combination with the MobilisedMetaPipeline to conditionally run a specific pipeline based on the cohort of the participant.

Other Parameters:
datapoint

The dataset instance passed to the run method.

Attributes:
per_stride_parameters_

The final list of all strides including their parameters that are part of a valid WB. Note, that all per-stride parameters are interpolated based on the per-sec output of the other algorithms. Check out the pipeline examples to learn more about this.

per_wb_parameters_

Aggregated parameters for each WB. This contains “meta parameters” like the number of strides, duration of the WB and the average over all strides of cadence, stride length and walking speed (if calculated).

per_wb_parameter_mask_

A “valid” mask calculated using the apply_thresholds function. It indicates for each WB which DMOs are valid. NaN indicates that the value has not been checked

aggregated_parameters_

The final aggregated parameters. They are calculated based on the per WB parameters and the DMO mask. Invalid parameters are (depending on the implementation in the provided Aggregation algorithm) excluded. This output can either be a dataframe with a single row (all WBs were aggregated to a single value, default), or a dataframe with multiple rows, if the aggregation algorithm uses a different aggregation approach.

gs_list_

The raw output of the gait sequence detection algorithm. This is a DataFrame with the start and end of each detected gait sequence.

raw_ic_list_

The raw output of the IC detection and the laterality classification. This is a DataFrame with the detected ICs and the corresponding L/R label.

raw_turn_list_

The raw output of the turn detection algorithm. This is a DataFrame with the detected turns (start, end, angle, …).

raw_per_sec_parameters_

A concatenated dataframe with all calculated per-second parameters. The index represents the sample of the center of the second the parameter value belongs to.

raw_per_stride_parameters_

A concatenated dataframe with all calculated per-stride parameters and the general stride information (start, end, laterality).

gait_sequence_detection_

The instance of the gait sequence detection algorithm that was run with all of its results.

gs_iterator_

The instance of the GS iterator that was run with all of its results. This contains the raw results for each GS, as well as the information about the constrained gs. These raw results (inputs and outputs per GS) can be used to test run individual algorithms exactly like they were run within the pipeline.

stride_selection_

The instance of the stride selection algorithm that was run with all of its results.

wba_

The instance of the WBA algorithm that was run with all of its results.

dmo_aggregation_

The instance of the DMO aggregation algorithm that was run with all of its results.

See also

mobgap.pipeline.BaseMobilisedPipeline

A version of the pipeline without any default algorithms or parameters.

mobgap.pipeline.MobilisedPipelineImpaired

A predefined pipeline for impaired walking.

Notes

The Mobilise-D pipeline consists of the following steps:

  1. Gait sequences are detected using the provided gait sequence detection algorithm.

  2. Within each gait sequence, initial contacts are detected using the provided IC detection algorithm. A “refined” version of the gait sequence is created, starting and ending at the first and last detected IC.

  3. Cadence, stride length and walking speed are calculated for each “refined” gait sequence. The output of these algorithms is provided per second.

  4. Using the L/R label for each IC calculated by the laterality classification algorithm, strides are defined.

  5. The per-second parameters are interpolated to per-stride parameters.

  6. The stride selection algorithm is used to filter out strides that don’t fulfill certain criteria.

  7. The WBA algorithm is used to assemble the strides into walking bouts. This is done independent of the original gait sequences.

  8. Aggregated parameters for each WB are calculated.

  9. If DMO thresholds are provided, these WB-level parameters are filtered based on physiological valid thresholds.

  10. The DMO aggregation algorithm is used to aggregate the WB-level parameters to either a set of values per-recording or any other granularity (i.e. one value per hour), depending on the aggregation algorithm.

For a step-by-step example of how these steps are executed, check out The Mobilise-D pipeline: Step-by-Step Breakdown.

[1]

Micó-Amigo, M., Bonci, T., Paraschiv-Ionescu, A. et al. Assessing real-world gait with digital technology? Validation, insights and recommendations from the Mobilise-D consortium. J NeuroEngineering Rehabil 20, 78 (2023). https://doi.org/10.1186/s12984-023-01198-5

[2]

Kirk, C., Küderle, A., Micó-Amigo, M.E. et al. Mobilise-D insights to estimate real-world walking speed in multiple conditions with a wearable device. Sci Rep 14, 1754 (2024). https://doi.org/10.1038/s41598-024-51766-5

Methods

clone()

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

get_params([deep])

Get parameters for this algorithm.

get_recommended_cohorts()

Get the recommended cohorts for this pipeline.

run(datapoint)

Run the pipeline on the provided data..

safe_run(datapoint)

Run the pipeline with some additional checks.

score(datapoint)

Calculate performance of the pipeline on a datapoint with reference information.

set_params(**params)

Set the parameters of this Algorithm.

PredefinedParameters

__init__(
*,
gait_sequence_detection: ~mobgap.gait_sequences.base.BaseGsDetector = cf(GsdIluz(acc_v_standing_threshold=4.903325,
allowed_acc_v_change_per_window=0.15,
allowed_steps_per_s=(0.5,
3),
mean_activity_threshold=-0.980665,
min_gsd_duration_s=5,
pre_filter=FirFilter(cutoff_freq_hz=(0.5,
3),
filter_type='bandpass',
order=200,
window='hamming',
zero_phase=True),
sin_template_freq_hz=2,
std_activity_threshold=0.0980665,
step_detection_thresholds=(3.92266,
14.709975),
window_length_s=3,
window_overlap=0.5)),
initial_contact_detection: ~mobgap.initial_contacts.base.BaseIcDetector = cf(IcdIonescu(cwt_width=9.0,
pre_filter=EpflDedriftedGaitFilter(zero_phase=True))),
laterality_classification: ~mobgap.laterality.base.BaseLRClassifier = cf(LrcUllrich(clf_pipe=Pipeline(steps=[('scaler_old',
MinMaxScaler()),
('clf_old',
SVC(C=0.1,
kernel='linear'))]),
smoothing_filter=ButterworthFilter(cutoff_freq_hz=(0.5,
2),
filter_type='bandpass',
order=4,
zero_phase=True))),
cadence_calculation: ~mobgap.cadence.base.BaseCadCalculator | None = cf(CadFromIcDetector(ic_detector=IcdShinImproved(axis='norm'),
max_interpolation_gap_s=3,
silence_ic_warning=True,
step_time_smoothing=HampelFilter(half_window_size=2,
n_sigmas=3.0))),
stride_length_calculation: ~mobgap.stride_length.base.BaseSlCalculator | None = cf(SlZijlstra(acc_smoothing=ButterworthFilter(cutoff_freq_hz=0.1,
filter_type='highpass',
order=4,
zero_phase=True),
max_interpolation_gap_s=3,
orientation_method=None,
speed_smoothing=ButterworthFilter(cutoff_freq_hz=1,
filter_type='highpass',
order=4,
zero_phase=True),
step_length_scaling_factor=1.14675,
step_length_smoothing=HampelFilter(half_window_size=2,
n_sigmas=3.0))),
walking_speed_calculation: ~mobgap.walking_speed.base.BaseWsCalculator | None = cf(WsNaive()),
turn_detection: ~mobgap.turning.base.BaseTurnDetector | None = cf(TdElGohary(allowed_turn_angle_deg=(45,
inf),
allowed_turn_duration_s=(0.5,
10),
lower_threshold_velocity_dps=5,
min_gap_between_turns_s=0.05,
min_peak_angle_velocity_dps=15,
orientation_estimation=None,
smoothing_filter=ButterworthFilter(cutoff_freq_hz=0.5,
filter_type='lowpass',
order=4,
zero_phase=True))),
stride_selection: ~mobgap.wba._stride_selection.StrideSelection = cf(StrideSelection(incompatible_rules='warn',
rules=[('stride_duration_thres',
IntervalDurationCriteria(inclusive=(False,
True),
max_duration_s=3.0,
min_duration_s=0.2)),
('stride_length_thres',
IntervalParameterCriteria(inclusive=(False,
True),
lower_threshold=0.15,
parameter='stride_length_m',
upper_threshold=None))])),
wba: ~mobgap.wba._wb_assembly.WbAssembly = cf(WbAssembly(rules=[('min_strides',
NStridesCriteria(min_strides=4,
min_strides_left=3,
min_strides_right=3)),
('max_break',
MaxBreakCriteria(consider_end_as_break=True,
max_break_s=3,
remove_last_ic=False))])),
dmo_thresholds: ~pandas.core.frame.DataFrame | None = cf(condition                free_living              ...     global          threshold_type                   min         max  ...        min      max dmo               cohort                          ...                     cadence_spm       CHF      40.594770  167.942930  ...  40.000000  172.900                   COPD     38.880484  151.558718  ...  40.000000  172.900                   HA       35.751898  156.946955  ...  40.000000  172.900                   MS       38.443211  155.394496  ...  40.000000  172.900                   PD       40.957969  142.121947  ...  40.000000  172.900                   PFF      42.191719  157.613665  ...  40.000000  172.900 walking_speed_mps CHF       0.112478    1.757103  ...   0.081515    2.220                   COPD      0.090731    1.641773  ...   0.081515    2.220                   HA        0.097413    1.965728  ...   0.081515    2.220                   MS        0.085918    1.920262  ...   0.081515    2.220                   PD        0.081515    1.735348  ...   0.081515    2.220                   PFF       0.104547    1.553186  ...   0.081515    2.220 stride_length_m   CHF       0.185308    2.166646  ...   0.150523    2.190                   COPD      0.176403    1.711645  ...   0.150523    2.190                   HA        0.155126    2.024694  ...   0.150523    2.190                   MS        0.191099    1.940537  ...   0.150523    2.190                   PD        0.150523    1.982926  ...   0.150523    2.190                   PFF       0.206787    1.697251  ...   0.150523    2.190 stride_duration_s CHF       0.702000    3.030857  ...   0.460000    3.000                   COPD      0.770000    3.000000  ...   0.460000    3.000                   HA        0.735435    3.254400  ...   0.460000    3.000                   MS        0.775597    3.057750  ...   0.460000    3.000                   PD        0.836253    2.928000  ...   0.460000    3.000                   PFF       0.744000    2.769000  ...   0.460000    3.000 step_duration_s   CHF       0.376000    1.504500  ...   0.140000    2.124                   COPD      0.390400    1.788000  ...   0.140000    2.124                   HA        0.367972    1.730400  ...   0.140000    2.124                   MS        0.388084    1.905000  ...   0.140000    2.124                   PD        0.417216    1.605600  ...   0.140000    2.124                   PFF       0.371429    2.124000  ...   0.140000    2.124  [30 rows x 8 columns]),
dmo_aggregation: ~mobgap.aggregation.base.BaseAggregator = cf(MobilisedAggregator(groupby=None,
unique_wb_id_column='wb_id',
use_original_names=False)),
recommended_cohorts: tuple[str,
...] | None = cf(('HA',
'COPD',
'CHF')),
) 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

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.

Get the recommended cohorts for this pipeline.

Returns:
recommended_cohorts

The recommended cohorts for this pipeline or None

run(
datapoint: BaseGaitDatasetT,
) Self[source]#

Run the pipeline on the provided data..

Parameters:
datapoint

The data to run the pipeline on. This needs to be a valid datapoint (i.e. a dataset with just a single row). The Dataset should be a child class of BaseGaitDataset or implement all the same parameters and methods.

Returns:
self

The pipeline object itself with all the results stored in the attributes.

safe_run(
datapoint: DatasetT,
) Self[source]#

Run the pipeline with some additional checks.

It is preferred to use this method over run, as it can catch some simple implementation errors of custom pipelines.

The following things are checked:

  • The run method must return self (or at least an instance of the pipeline)

  • The run method must set result attributes on the pipeline

  • All result attributes must have a trailing _ in their name

  • The run method must not modify the input parameters of the pipeline

Parameters:
datapoint

An instance of a tpcp.Dataset containing only a single datapoint. The structure of the data will depend on the dataset.

Returns:
self

The class instance with all result attributes populated

score(
datapoint: DatasetT,
) float | dict[str, float][source]#

Calculate performance of the pipeline on a datapoint with reference information.

This is an optional method and does not need to be implemented in many cases. Usually stand-a-lone functions are better suited as scorer.

A typical score method will call self.run(datapoint) and then compare the results with reference values also available on the dataset.

Parameters:
datapoint

An instance of a tpcp.Dataset containing only a single datapoint. The structure of the data and the available reference information will depend on the dataset.

Returns:
score

A float or dict of float quantifying the quality of the pipeline on the provided data. A higher score is always better.

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.pipeline.MobilisedPipelineHealthy#

Custom Data and Datasets

Custom Data and Datasets

Preconfigured Mobilised Pipelines

Preconfigured Mobilised Pipelines