Events

This module contains classes for checking and detecting events in a trial.

class gaitalytics.events.BaseEventDetection(configs: MappingConfigs)

Abstract class for event detectors.

This class provides a common interface for detecting events in a trial, which makes them interchangeable.

__init__(configs: MappingConfigs)

Initializes a new instance of the BaseEventDetection class.

Parameters:

configs – The mapping configurations.

abstract detect_events(trial: Trial) DataFrame

Detects the events in the trial.

Parameters:

trial – The trial for which to detect the events.

Returns:

A DataFrame containing the detected events.

Return type:

pd.DataFrame

class gaitalytics.events.MarkerEventDetection(configs: MappingConfigs, **kwargs)

A class for detecting events using marker data.

This class provides a method to detect events using marker data in a trial. The algorithm is based on the paper by Zeni et al. (2008).

__init__(configs: MappingConfigs, **kwargs)

Initializes a new instance of the MarkerEventDetection class.

Parameters:
  • configs – The mapping configurations.

  • **kwargs

    • height: The height of peaks. Default = None

    • threshold: The threshold of peaks. Default = None

    • distance: The min distance in frames between events. Default = None

    • rel_height: The relative height of peak. Default = 0.5

detect_events(trial: Trial) DataFrame

Detects the events in the trial using marker data.

Parameters:

trial – The trial for which to detect the events.

Returns:

A DataFrame containing the detected events.

Return type:

pd.DataFrame

class gaitalytics.events.SequenceEventChecker

A class for checking the sequence of events in a trial.

This class provides a method to check the sequence of events in a trial. It checks the sequence of event labels and contexts.

check_events(events: DataFrame) tuple[bool, list | None]

Checks the sequence of events in the trial.

In a normal gait cycle, the sequence of events is as follows: 1. Foot Strike (right) 2. Foot Off (left) 3. Foot Strike (left) 4. Foot Off (right)

Parameters:

events – The events to be checked.

Returns:

True if the sequence is correct, False otherwise. list | None: A list time slice of incorrect sequence, or None if the sequence is correct.

Return type:

bool