R/mims_unit.R
custom_mims_unit.Rd
custom_mims_unit
computes the Monitor Independent Motion Summary unit
and estimates the sensor orientations for the input multichannel
accelerometer signal with custom settings. The input signal can be from
devices of any sampling rate and dynamic range. Please refer to the
manuscript for detailed description of the algorithm. Please refer to
functions for the intermediate steps: extrapolate
for
extrapolation, iir
for filtering,
aggregate_for_mims
and aggregate_for_orientation
for aggregation.
custom_mims_unit( df, epoch = "5 sec", dynamic_range, noise_level = 0.03, k = 0.05, spar = 0.6, filter_type = "butter", cutoffs = c(0.2, 5), axes = c(2, 3, 4), use_extrapolation = TRUE, use_filtering = TRUE, combination = "sum", allow_truncation = TRUE, output_mims_per_axis = FALSE, output_orientation_estimation = FALSE, epoch_for_orientation_estimation = NULL, before_df = NULL, after_df = NULL, use_gui_progress = FALSE, st = NULL )
df  dataframe. Input multichannel accelerometer signal. 

epoch  string. Any format that is acceptable by argument 
dynamic_range  numerical vector. The dynamic ranges of the input
signal. Should be a 2element numerical vector. 
noise_level  number. The tolerable noise level in \(g\) unit, should be between 0 and 1. Default is 0.03, which applies to most devices. 
k  number. Duration of neighborhood to be used in local spline regression for each side, in seconds. Default is 0.05, as optimized by MIMSunit algorithm. 
spar  number. Between 0 and 1, to control how smooth we want to fit local spline regression, 0 is linear and 1 matches all local points. Default is 0.6, as optimized by MIMSunit algorithm. 
filter_type  string. The type of filter to be applied. Could be 'butter' for butterworth bandpass filter, 'ellip' for elliptic bandpass filter or 'bessel' for bessel lowpass filter + average removal highpass filter. Default is "butter". 
cutoffs  numerical vector. Cut off frequencies to be used in filtering.
If 
axes  numerical vector. Indices of columns that specifies the axis
values of the input signal. Default is 
use_extrapolation  logical. If it is TRUE, the function will apply extrapolation algorithm to the input signal, otherwise it will skip extrapolation but only linearly interpolate the signal to 100Hz. Default is TRUE. 
use_filtering  logical. If it is TRUE, the function will apply bandpass filtering to the input signal, otherwise it will skip the filtering. Default is TRUE. 
combination  string. Method to combine MIMSunit values for each axis.
Could be "sum" for 
allow_truncation  logical. If it is TRUE, the algorithm will truncate very small MIMSunit values to zero. Default is TRUE. 
output_mims_per_axis  logical. If it is TRUE, the output MIMSunit dataframe will have MIMSunit values for each axis from the third column. Default is FALSE. 
output_orientation_estimation  logical. If it is TRUE, the function will also estimate sensor orientations over each epoch. And the output will be a list, with the first element being the MIMSunit dataframe, and the second element being the sensor orientation dataframe. Default is FALSE. 
epoch_for_orientation_estimation  string. string. Any format that is
acceptable by argument 
before_df  dataframe. The multichannel 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 
after_df  dataframe. The multichannel 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

use_gui_progress  logical. If it is TRUE, show GUI progress bar on windows platform. Default is FALSE. 
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. 
dataframe or list. If output_orientation_estimation
is TRUE,
the output will be a list, otherwise the output will be the MIMSunit
dataframe.
The first element will be the MIMSunit dataframe, in which the first
column is the start time of each epoch in POSIXct format, and the second
column is the MIMSunit value for the input signal, and the third column
and on are the MIMSunit values for each axis of the input signal if
output_mims_per_axis
is TRUE.
The second element will be the orientation dataframe, in which the first column is the start time of each epoch in POSIXct format, and the second to fourth column is the estimated orientations for the input signal.
This function allows you to run customized algorithm for MIMSunit and sensor orientations.
before_df
and after_df
are often set when the accelerometer
data are divided into files of smaller chunk.
This is the lowlevel entry
of MIMSunit and orientation estimation algorithm. mims_unit
calls this function internally.
Other Top level API functions:
mims_unit()
,
sensor_orientations()
,
shiny_app()
# Use sample data for testing df = sample_raw_accel_data # compute mims unit values with custom parameter output = custom_mims_unit(df, epoch = '1 sec', dynamic_range=c(8, 8), spar=0.7)#> ================================================================================head(output)#> HEADER_TIME_STAMP MIMS_UNIT #> 1 20160115 11:00:00.013 1.071916 #> 2 20160115 11:00:01.003 1.079748 #> 3 20160115 11:00:02.003 1.001164 #> 4 20160115 11:00:03.003 1.023815 #> 5 20160115 11:00:04.003 1.016161 #> 6 20160115 11:00:05.003 0.813439