MobilisedPipelineUniversal#
- class mobgap.pipeline.MobilisedPipelineUniversal(pipelines: list[tuple[str, ~mobgap.pipeline.base.BaseMobilisedPipeline[~mobgap.pipeline.base.BaseGaitDatasetT]]] = cf([('healthy', MobilisedPipelineHealthy(cadence_calculation=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)), dmo_aggregation=MobilisedAggregator(groupby=None, unique_wb_id_column='wb_id', use_original_names=False), dmo_thresholds=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], gait_sequence_detection=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=IcdIonescu(cwt_width=9.0, pre_filter=EpflDedriftedGaitFilter(zero_phase=True)), laterality_classification=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)), recommended_cohorts=('HA', 'COPD', 'CHF'), stride_length_calculation=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)), stride_selection=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))]), turn_detection=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)), walking_speed_calculation=WsNaive(), wba=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))]))), ('impaired', MobilisedPipelineImpaired(cadence_calculation=CadFromIcDetector(ic_detector=IcdHKLeeImproved(axis='norm'), max_interpolation_gap_s=3, silence_ic_warning=True, step_time_smoothing=HampelFilter(half_window_size=2, n_sigmas=3.0)), dmo_aggregation=MobilisedAggregator(groupby=None, unique_wb_id_column='wb_id', use_original_names=False), dmo_thresholds=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], gait_sequence_detection=GsdIonescu(active_signal_threshold=0.980665, max_gap_s=3.5, min_n_steps=5, min_step_margin_s=1.5, padding=0.75), initial_contact_detection=IcdIonescu(cwt_width=9.0, pre_filter=EpflDedriftedGaitFilter(zero_phase=True)), laterality_classification=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)), recommended_cohorts=('PD', 'MS', 'PFF'), stride_length_calculation=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)), stride_selection=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))]), turn_detection=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)), walking_speed_calculation=WsNaive(), wba=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))])))]))[source]#
Metapipeline that can use a specific pipeline depending on the cohort of the participant.
This uses the
recommended_cohortsparameter of the pipelines to determine which pipeline to use. You can provide any list of pipelines with their names to this class. However, there must be no overlap in the recommended cohorts of the pipelines.The pipeline that is used (and all its results) can be accessed via the
pipeline_attribute.- Parameters:
- pipelines
A list of tuples with the name of the pipeline and the pipeline instance. The pipeline that has the cohort in its recommended cohorts will be used. If multiple pipelines are recommended for the same cohort an ValueError will be raised. If no pipeline is found, a ValueError will be raised. By default, the
MobilisedPipelineHealthyandMobilisedPipelineImpairedare used.
- 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_thresholdsfunction. 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.
- pipeline_
The pipeline that was used for the provided data with all its results.
- pipeline_name_
The name of the pipeline that was used.
Methods
clone()Create a new instance of the class with all parameters copied over.
get_params([deep])Get parameters for this algorithm.
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.
- __init__(pipelines: list[tuple[str, ~mobgap.pipeline.base.BaseMobilisedPipeline[~mobgap.pipeline.base.BaseGaitDatasetT]]] = cf([('healthy', MobilisedPipelineHealthy(cadence_calculation=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)), dmo_aggregation=MobilisedAggregator(groupby=None, unique_wb_id_column='wb_id', use_original_names=False), dmo_thresholds=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], gait_sequence_detection=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=IcdIonescu(cwt_width=9.0, pre_filter=EpflDedriftedGaitFilter(zero_phase=True)), laterality_classification=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)), recommended_cohorts=('HA', 'COPD', 'CHF'), stride_length_calculation=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)), stride_selection=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))]), turn_detection=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)), walking_speed_calculation=WsNaive(), wba=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))]))), ('impaired', MobilisedPipelineImpaired(cadence_calculation=CadFromIcDetector(ic_detector=IcdHKLeeImproved(axis='norm'), max_interpolation_gap_s=3, silence_ic_warning=True, step_time_smoothing=HampelFilter(half_window_size=2, n_sigmas=3.0)), dmo_aggregation=MobilisedAggregator(groupby=None, unique_wb_id_column='wb_id', use_original_names=False), dmo_thresholds=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], gait_sequence_detection=GsdIonescu(active_signal_threshold=0.980665, max_gap_s=3.5, min_n_steps=5, min_step_margin_s=1.5, padding=0.75), initial_contact_detection=IcdIonescu(cwt_width=9.0, pre_filter=EpflDedriftedGaitFilter(zero_phase=True)), laterality_classification=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)), recommended_cohorts=('PD', 'MS', 'PFF'), stride_length_calculation=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)), stride_selection=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))]), turn_detection=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)), walking_speed_calculation=WsNaive(), wba=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))])))])) 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_recommended_cohorts() tuple[str, ...] | None[source]#
Get the recommended cohorts for this pipeline.
- Returns:
- recommended_cohorts
The recommended cohorts for this pipeline or None
- run(
- datapoint: BaseGaitDatasetT,
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
BaseGaitDatasetor 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,
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 nameThe run method must not modify the input parameters of the pipeline
- Parameters:
- datapoint
An instance of a
tpcp.Datasetcontaining 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,
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.Datasetcontaining 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.