Flexlib

This documentation provides a detailed overview of the flexlib library, a Python library for working with Flextail sensor data. It focuses on the Measurement and related classes. It also explains the different file formats and how to load and write them.

Core Concepts

Measurement Class

The Measurement class represents a single measurement from the sensor. It contains the following information:

  • timestamp: The timestamp of the measurement.
  • acc: The accelerometer data.
  • gyro: The gyroscope data.
  • angles: The calculated angles.

Read more about Measurement…

AnnotatedRecording Class

The AnnotatedRecording class represents a recording of measurements with annotations. It contains a list of Measurement objects and a list of TimedAnnotation objects.

Methods

  • from_json_entry(json): Creates an AnnotatedRecording object from a JSON entry.
  • split_by_annotations(): Splits the recording into a list of tuples, where each tuple contains an annotation label and a list of measurements.
  • to_json_entry(): Converts the AnnotatedRecording object to a JSON entry.

Read more about AnnotatedRecording…

MeasurementMetric Class

The MeasurementMetric class is used to compare two Measurement objects. It provides several metrics for comparing the measurements, such as the alpha_metric, beta_metric, and orientation_metric.

Read more about MeasurementMetric…

SchmittTrigger

The schmitt_trigger.py module provides a set of classes for implementing Schmitt Triggers. A Schmitt Trigger is a comparator circuit with hysteresis implemented by applying positive feedback to the noninverting input of a comparator or differential amplifier. It is used to detect signals in a noisy environment.

Read more about SchmittTrigger…

MeasurementEvaluationMetric

The measurement_evaluation_metric.py module provides the MeasurementEvaluationMetric enum, which contains helper functions to quickly evaluate various measurement metrics from a measurement object.

Read more about MeasurementEvaluationMetric…

File Formats

The flexlib library supports three different file formats:

  • RSF V1: A binary format for storing measurements.
  • RSF V2: A newer binary format for storing measurements.
  • CSV: A text-based format for storing measurements.

Loading and Writing Data

The FlexReader class is the recommended way to read data from any of the supported file formats. It automatically detects the file format and returns an AnnotatedRecording object.

To write data, you can use the corresponding writer class for the desired file format:

  • RSFV1Writer: For writing data in the RSF V1 format.
  • RSFV2Writer: For writing data in the RSF V2 format.
  • CSVWriter: For writing data in the CSV format.

Read more about File Formats…