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.

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.

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.

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.

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))
#> ================================================================================
#>     HEADER_TIME_STAMP  X_ANGLE  Y_ANGLE  Z_ANGLE
#> 1 2016-01-15 11:00:00 11.45678 88.88573 101.4010
#> 2 2016-01-15 11:00:02 10.93501 90.81432 100.9039
#> 3 2016-01-15 11:00:04 10.57168 91.72037 100.4276

  # compute sensor orientation angles with different epoch length
  output = sensor_orientations(df, epoch = '1 sec', dynamic_range=c(-8, 8))
#> ================================================================================
  head(output)
#>     HEADER_TIME_STAMP X_ANGLE Y_ANGLE Z_ANGLE
#> 1 2016-01-15 11:00:00     NaN     NaN     NaN
#> 2 2016-01-15 11:00:01     NaN     NaN     NaN
#> 3 2016-01-15 11:00:02     NaN     NaN     NaN
#> 4 2016-01-15 11:00:03     NaN     NaN     NaN
#> 5 2016-01-15 11:00:04     NaN     NaN     NaN
#> 6 2016-01-15 11:00:05     NaN     NaN     NaN