Resample#

class mobgap.data_transform.Resample(target_sampling_rate_hz: float = 100.0, *, attempt_index_resample: bool = True)[source]#

Resample the input data to a specified target sampling rate using scipy.signal.resample.

Parameters:
target_sampling_rate_hz

The target sampling rate in Hertz. If the target sampling rate is equal to the sampling rate of the input data, no resampling is performed.

attempt_index_resample

Whether to attempt to resample the index of the input data. This is only used if the input data is a DataFrame or Series with a numeric index. In this case we assume that the index represents the time or the samples, and we try to resample it. If the index is neither numeric nor a datetime objects, we can not resample it and this parameter is ignored. In case you index does not represent the time (either in actual time or samples), you should set this parameter to False.

Other Parameters:
data

The data represented either as a dataframe, a series, or a numpy array.

sampling_rate_hz

The sampling rate of the IMU data in Hz.

Attributes:
transformed_data_

The resampled data

Methods

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.

transform(data, *[, sampling_rate_hz])

Resample the input data to the target sampling rate.

__init__(
target_sampling_rate_hz: float = 100.0,
*,
attempt_index_resample: bool = True,
) 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.

set_params(**params: Any) Self[source]#

Set the parameters of this Algorithm.

To set parameters of nested objects use nested_object_name__para_name=.

transform(
data: Series | DataFrame | ndarray,
*,
sampling_rate_hz: float | None = None,
**_: Unpack[dict[str, Any]],
) Self[source]#

Resample the input data to the target sampling rate.

Parameters:
data

The data represented either as a dataframe, a series, or a numpy array.

sampling_rate_hz

The sampling rate of the IMU data in Hz.

Returns:
Resample

The instance of the transform with the results attached

Raises:
ValueError

If sampling_rate_hz is None.

Examples using mobgap.data_transform.Resample#

General Filter Introduction

General Filter Introduction

Resampling data

Resampling data