IcdEmulationPipeline#
- class mobgap.initial_contacts.pipeline.IcdEmulationPipeline(
- algo: BaseIcDetector,
- *,
- convert_to_body_frame: bool = True,
Run an ICD algorithm in isolation on a Gait Dataset.
This wraps any ICD algorithm and allows to apply it to a single datapoint of a Gait Dataset or optimize it based on a whole dataset.
This pipeline can be used in combination with the
tpcp.validateandtpcp.optimizemodules to evaluate or improve the performance of an ICD algorithm.- Parameters:
- algo
The ICD algorithm that should be run/evaluated.
- convert_to_body_frame
If True, the data will be converted to the body frame before running the algorithm. This is the default, as most algorithm expect the data in the body frame. If your data is explicitly not aligned and your algorithm supports sensor frame/unaligned input you might want to set this to False.
- 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.- algo_
The ICD algo instance with all results after running the algorithm. This can be helpful for debugging or further analysis.
Notes
All emulation pipelines pass available metadata of the dataset to the algorithm. This includes the recording metadata (
recording_metadata) and the participant metadata (participant_metadata), which are passed as keyword arguments to thedetectmethod of the algorithm. In addition, we pass the group label of the datapoint asdp_groupto the algorithm. This is usually not required by algorithms (because this would mean that the algorithm changes behaviour based on the exact recording provided). However, it can be helpful when working with “dummy” algorithms, that simply return some fixed pre-defined results or to be used as cache key, when the algorithm has internal caching mechanisms.For the
self_optimizemethod, we pass the same metadata to the algorithm, but each value is actually a list of values, one for each datapoint in the dataset.Methods
clone()Create a new instance of the class with all parameters copied over.
get_params([deep])Get parameters for this algorithm.
run(datapoint)Run the pipeline on a single data point.
safe_run(datapoint)Run the pipeline with some additional checks.
self_optimize(dataset, **kwargs)Optimize the input parameters of the pipeline or algorithm using any logic.
self_optimize_with_info(dataset, **kwargs)Optimize the input parameters of the pipeline or algorithm using any logic.
set_params(**params)Set the parameters of this Algorithm.
- __init__(
- algo: BaseIcDetector,
- *,
- convert_to_body_frame: bool = True,
- 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.
- run(
- datapoint: BaseGaitDatasetWithReference,
Run the pipeline on a single data point.
This extracts the imu_data (
data_ss) and the sampling rate (sampling_rate_hz) from the datapoint and uses thedetectmethod of the ICD algorithm to detect the gait sequences.- Parameters:
- datapoint
A single datapoint of a Gait Dataset with reference information.
- Returns:
- self
The pipeline instance with the detected initial contacts stored in the
ic_list_attribute.
- 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
- self_optimize(
- dataset: DatasetT,
- **kwargs,
Optimize the input parameters of the pipeline or algorithm using any logic.
This method can be used to adapt the input parameters (values provided in the init) based on any data driven heuristic.
Note
The optimizations must only modify the input parameters (aka
self.cloneshould retain the optimization results). If you need to return further information, implementself_optimize_with_infoinstead.- Parameters:
- dataset
An instance of a
tpcp.Datasetcontaining one or multiple data points that can be used for training. The structure of the data and the available reference information will depend on the dataset.- kwargs
Additional parameters required for the optimization process.
- Returns:
- self
The class instance with optimized input parameters.
- self_optimize_with_info(
- dataset: DatasetT,
- **kwargs,
Optimize the input parameters of the pipeline or algorithm using any logic.
This is equivalent to
self_optimize, but allows you to return additional information as a second return value. If you implement this method, there is no need to implementself_optimizeas well.- Parameters:
- dataset
An instance of a
tpcp.Datasetcontaining one or multiple data points that can be used for training. The structure of the data and the available reference information will depend on the dataset.- kwargs
Additional parameters required for the optimization process.
- Returns:
- self
The class instance with optimized input parameters.
- info
An arbitrary piece of information
Examples using mobgap.initial_contacts.pipeline.IcdEmulationPipeline#
Revalidation of the initial contact detection algorithms
Revalidation of the laterality classification algorithms