wristpy.io.readers.readers

Function to read accelerometer data from a file.

Functions

read_watch_data(file_name)

Read watch data from a file.

unix_epoch_time_to_polars_datetime(time[, units])

Convert unix epoch time to polars Series of datetime.

wristpy.io.readers.readers._extract_dynamic_range(metadata: dict, file_type: Literal['.gt3x', '.bin']) tuple[float, float][source]

Extract the dynamic range from metadata.

Parameters:
  • metadata – Metadata subdictionary where accelerometer range values can be found.

  • file_type – Accelerometer data file type. Supports .gt3x and .bin.

Returns:

A tuple containing the accelerometer range.

Raises:

ValueError – If file type is not supported.

wristpy.io.readers.readers.read_watch_data(file_name: Path | str) WatchData[source]

Read watch data from a file.

Currently supported watch types are Actigraph .gt3x and GeneActiv .bin. Assigns the idle_sleep_mode_flag to false unless the watchtype is .gt3x and sleep_mode is enabled (based on watch metadata).

Parameters:

file_name – The filename to read the watch data from.

Returns:

WatchData class

Raises: IOError if the file extension is not supported or doesn’t exist.

wristpy.io.readers.readers.unix_epoch_time_to_polars_datetime(time: ndarray, units: Literal['ns', 'us', 'ms', 's', 'd'] = 'ns') Series[source]

Convert unix epoch time to polars Series of datetime.

Parameters:
  • time – The unix epoch timestamps to convert.

  • units – The units to convert the time to (‘s’, ‘ms’, ‘us’, or ‘ns’). Default value is ‘ns’.