Api

gaitalytics.api.load_config(config_path: Path | str) MappingConfigs

Loads the mapping configuration file.

Parameters:

config_path – The path to the configuration file.

Returns:

A MappingConfigs object.

gaitalytics.api.load_c3d_trial(c3d_file: Path | str, configs: MappingConfigs) Trial

Loads a Trial from a c3d file.

Be aware that all the required data for the trial must be present in the c3d file. i.e. markers, analogs, events, etc.

Parameters:
  • c3d_file – The path to the c3d file.

  • configs – The mapping configurations

Returns:

A Trial object.

gaitalytics.api.detect_events(trial: ~gaitalytics.model.Trial, config: ~gaitalytics.mapping.MappingConfigs, method: type[~gaitalytics.events.BaseEventDetection] = <class 'gaitalytics.events.MarkerEventDetection'>, **kwargs) DataFrame

Detects the events in the trial.

Parameters:
  • trial – The trial to detect the events for.

  • config – The mapping configurations

  • method – The class to use for detecting the events. Currently, only “Marker” is supported, which implements the method from Zenis et al. 2008. Default is “Marker”.

  • **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

Returns:

A DataFrame containing the detected events.

gaitalytics.api.check_events(event_table: DataFrame, method: str = 'sequence')

Checks the events in the trial.

Parameters:
  • event_table – The event table to check.

  • method – The method to use for checking the events. Currently, only supports “sequence” which checks the sequence of events in terms of context and label. Default is “sequence”.

Returns:

The trial with the checked events.

Raises:

ValueError – If the event sequence is not correct or the method is not supported.

gaitalytics.api.write_events_to_c3d(c3d_path: Path | str, event_table: DataFrame, output_path: Path | str | None = None)

Writes the events to the c3d file.

Parameters:
  • c3d_path – The path to the original c3d file.

  • event_table – The DataFrame containing the events.

  • output_path – The path to write the c3d file with the events. If None, the original file will be overwritten.

gaitalytics.api.segment_trial(trial: Trial, method: str = 'HS') TrialCycles

Segments the trial into cycles

Parameters:
  • trial – The trial to segment.

  • method – The method to use for segmenting the trial. Currently, only supports “HS” which segments the trial based on heel strikes. Default is “HS”.

Returns:

The trial with the segmented data.

gaitalytics.api.time_normalise_trial(trial: Trial | TrialCycles, method: str = 'linear', **kwargs) Trial | TrialCycles

Normalises the time in the trial.

Parameters:
  • trial – The trial to normalise the time for.

  • method – The method to use for normalising the time. Currently, only supports “linear” which normalises the time linearly. Default is “linear”.

  • **kwargs

    • n_frames: The number of frames to normalise the data to.

Returns:

The trial with the normalised time.

gaitalytics.api.calculate_features(trial: ~gaitalytics.model.TrialCycles, config: ~gaitalytics.mapping.MappingConfigs, methods: list | tuple = (<class 'gaitalytics.features.TimeSeriesFeatures'>, <class 'gaitalytics.features.PhaseTimeSeriesFeatures'>, <class 'gaitalytics.features.TemporalFeatures'>, <class 'gaitalytics.features.SpatialFeatures'>), **kwargs) DataArray

Calculates the features of the trial.

Parameters:
  • trial – The trial to calculate the features for.

  • config – The mapping configurations

  • methods – Class objects of the feature calculation methods to use.

  • **kwargs – Currently not used.

Returns:

The trial with the calculated features.

gaitalytics.api.export_trial(trial: Trial | TrialCycles, output_path: Path | str, method: str = 'netcdf')

Exports the trial to a c3d file.

This function will create a folder and save the trial as NetCDF files. Depending on the trial following files will be written:

  • markers.nc

  • analogs.nc

  • analysis.nc

  • events.nc

Parameters:
  • trial – The trial to export.

  • output_path – The path to write the c3d file.

  • method – The method to use for exporting the trial. Currently, only supports “netcdf”.