sensor_orientations: Estimates sensor orientation

View source: R/mims_unit.R

sensor_orientationsR Documentation

Estimates sensor orientation

Description

sensor_orientations estimates the orientation angles for the input multi-channel accelerometer signal. The input signal can be from devices of any sampling rate and dynamic range. Please refer to function compute_orientation for the implementation of the estimation algorithm.

Usage

sensor_orientations(
  df,
  before_df = NULL,
  after_df = NULL,
  epoch = "5 sec",
  dynamic_range,
  st = NULL
)

Arguments

df

dataframe. Input multi-channel accelerometer signal.

before_df

dataframe. The multi-channel accelerometer signal comes before the input signal to be prepended to the input signal during computation. This is used to eliminate the edge effect during extrapolation and filtering. If it is NULL, algorithm will run directly on the input signal. Default is NULL.

after_df

dataframe. The multi-channel accelerometer signal comes after the input signal to be append to the input signal. This is used to eliminate the edge effect during extrapolation and filtering. If it is NULL, algorithm will run directly on the input signal. Default is NULL.

epoch

string. Any format that is acceptable by argument breaks in method cut.POSIXt.For example, "1 sec", "1 min", "5 sec", "10 min". Default is "5 sec".

dynamic_range

numerical vector. The dynamic ranges of the input signal. Should be a 2-element numerical vector. c(low, high), where low is the negative max value the device can reach and high is the positive max value the device can reach.

st

character or POSIXct timestamp. An optional start time you can set to force the epochs generated by referencing this start time. If it is NULL, the function will use the first timestamp in the timestamp column as start time to generate epochs. This is useful when you are processing a stream of data and want to use a common start time for segmenting data. Default is NULL.

Value

dataframe. The orientation dataframe. The first column is the start time of each epoch in POSIXct format. The second to fourth columns are the orientation angles.

How is it used in MIMS-unit algorithm?

This is not included in the official MIMS-unit algorithm nor the manuscript, but we found it is useful to know the sensor orientations in addition to the summary of movement.

Note

This function interpolates and extrapolates the signal before estimating the orientation angles.

before_df and after_df are often set when the accelerometer data are divided into files of smaller chunk.

See Also

Other Top level API functions: custom_mims_unit(), mims_unit(), shiny_app()

Examples

  # Use sample data for testing
  df = sample_raw_accel_data

  # compute sensor orientation angles
  sensor_orientations(df, epoch = '2 sec', dynamic_range=c(-8, 8))

  # compute sensor orientation angles with different epoch length
  output = sensor_orientations(df, epoch = '1 sec', dynamic_range=c(-8, 8))
  head(output)

MIMSunit documentation built on June 21, 2022, 5:06 p.m.