dispel.providers.generic.activity.placement module#

All generic transformation steps related to the placement.

class dispel.providers.generic.activity.placement.ClassifyPlacement[source]#

Bases: TransformStep

Classify placement in 100 ms windows.

data_set_ids: str | Iterable[str] = ['acc_ts_resampled', 'acc_ts_resampled_euclidean_norm']#

An iterable of data sets to be being processed

definitions: List[RawDataValueDefinition] = [<RawDataValueDefinition: start_time (start time)>, <RawDataValueDefinition: end_time (end time)>, <RawDataValueDefinition: duration (duration)>, <RawDataValueDefinition: placement (detected placement)>]#
new_data_set_id: str = 'placement_bouts'#
transform_function(acc_ts_euclidean_norm)#

Concatenate accelerometer and norm data and call placement function.

Parameters:
  • acc_ts (DataFrame) – A pd.DataFrame containing the acceleration and gravity axis

  • acc_ts_euclidean_norm (DataFrame) – A pd.DataFrame containing the norm of the acceleration

Returns:

contains start time, end time and label of each continuous segment

Return type:

pandas.DataFrame

dispel.providers.generic.activity.placement.ROLLING_STEP_SIZE = '100ms'#

This is the step of the sliding window, denoting the size of the “sliding” action, which is the length of sequence you move between each window.

dispel.providers.generic.activity.placement.ROLLING_WINDOW_SIZE = '4s'#

This is the size of the sliding window, denoting the duration between begin and end of sliding window.

dispel.providers.generic.activity.placement.THRES_BELT_MIN_ABS_MEAN_GRAVITY_X_1 = 0.6018150231520484#

[0, 53] deg X axes max.

Type:

belt threshold 1

dispel.providers.generic.activity.placement.THRES_HAND_MAX_MEAN_GRAVITY_Z_1 = -0.6427876096865394#

[8, 50] (or [18, 50]) deg Z axis max.

Type:

handheld threshold 1

dispel.providers.generic.activity.placement.THRES_PANT_MIN_ABS_MEAN_GRAVITY_Y_1 = 0.7071067811865476#

[0, 45] deg Y axes max.

Type:

pant threshold 1

dispel.providers.generic.activity.placement.THRES_TABL_MAX_STD_ACC_NORM_1 = 0.01#

standard deviation of acc norm.

Type:

table threshold 1

dispel.providers.generic.activity.placement.THRES_TABL_MIN_ABS_MEAN_GRAVITY_Z_1 = 0.9510565162951535#

[0, 18] deg Z axis max (to be combined with low std).

Type:

table threshold 1

dispel.providers.generic.activity.placement.THRES_TABL_MIN_ABS_MEAN_GRAVITY_Z_2 = 0.9902680687415704#

[0, 8] deg Z axes max.

Type:

table threshold 2

dispel.providers.generic.activity.placement.merge_adjacent_annotations_rolling(measures_predictions, rolling_step_size='100ms')[source]#

Merge adjacent annotations into segments of continuous labels.

Parameters:
  • measures_predictions (DataFrame) – A pd.DataFrame containing the measures and predicted class

  • rolling_step_size (str) – A str indicating the size of the sliding window

Returns:

contains start time, end time and label of each continuous segment

Return type:

pandas.DataFrame

dispel.providers.generic.activity.placement.placement_classification(data, rolling_window_size='4s', rolling_step_size='100ms')[source]#

Extract measures and predict labels given the gravity and norm data.

Parameters:
  • data (DataFrame) – A pd.DataFrame containing the gravity and accelerometer norm data

  • rolling_window_size (str) – A string containing the size of the sliding window (duration between begin and end of sliding window)

  • rolling_step_size (str) – A string containing the step of the sliding window (duration between centers of consecutive windows)

Returns:

A dataframe containing the extracted measures and label per window

Return type:

pandas.DataFrame

dispel.providers.generic.activity.placement.placement_classification_merged(acc_ts, acc_ts_euclidean_norm)[source]#

Concatenate accelerometer and norm data and call placement function.

Parameters:
  • acc_ts (DataFrame) – A pd.DataFrame containing the acceleration and gravity axis

  • acc_ts_euclidean_norm (DataFrame) – A pd.DataFrame containing the norm of the acceleration

Returns:

contains start time, end time and label of each continuous segment

Return type:

pandas.DataFrame

dispel.providers.generic.activity.placement.placement_classification_one_window(window_measures)[source]#

Classify placement for a window of measure data.

Parameters:

window_measures (Series) – A pd.Series containing the measure for a specific time

Returns:

The label of the predicted class

Return type:

str