mims_unit computes the Monitor Independent Motion Summary unit for the input multi-channel accelerometer signal. 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 for aggregation.

mims_unit(
df,
before_df = NULL,
after_df = NULL,
epoch = "5 sec",
dynamic_range,
output_mims_per_axis = FALSE,
use_gui_progress = FALSE,
st = NULL,
use_snapshot_to_check = FALSE
)

mims_unit_from_files(
files,
epoch = "5 sec",
dynamic_range,
output_mims_per_axis = FALSE,
use_gui_progress = FALSE,
use_snapshot_to_check = FALSE,
file_type = "mhealth",
...
)

## Arguments

df dataframe. Input multi-channel accelerometer signal. The first column should be the time component. The accelerometer data values (typically starting from the second column) should be in $$g$$ (per $$9.81m/s^2$$) unit. 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. 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. 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". 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. logical. If it is TRUE, the output MIMS-unit dataframe will have MIMS-unit values for each axis from the third column. Default is FALSE. logical. If it is TRUE, show GUI progress bar on windows platform. Default is FALSE. 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. logical. If TRUE, the function will use the first 100 rows or 10 the algorithm will use all data to check timestamp duplications. Default is FALSE. character vector. A list of csv filepaths for raw accelerometer data organized in order to be processed. The data should be consecutive in timestamps. A typical case is a set of hourly or daily files for continuous accelerometer sampling. For a single file, please wrap the filepath in a vector c(filepath). character. "mhealth" or "actigraph". The type of the csv files that store the raw accelerometer data. additional parameters passed to the import function when reading in the data from the files.

## Value

dataframe. The MIMS-unit dataframe. The first column is the start time of each epoch in POSIXct format. The second column is the MIMS-unit value for the input signal. If output_mims_per_axis is TRUE, the third column and then are the MIMS-unit values for each axis of the input signal.

## Note

This function is a wrapper function for the low-level custom_mims_unit function. It has set internal parameters as described in the manuscript. If you want to run customized algorithm for MIMSunit or if you want to develop better algorithms based on MIMS-unit algorithm, please use function custom_mims_unit where all parameters are tunable.

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 the main entry of MIMS-unit algorithm.

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

## Examples

  # Use sample data for testing
df = sample_raw_accel_data

# compute mims unit values and output axial values
output = mims_unit(df, epoch = '1 sec', dynamic_range=c(-8, 8), output_mims_per_axis=TRUE)
#>         HEADER_TIME_STAMP MIMS_UNIT MIMS_UNIT_X MIMS_UNIT_Y MIMS_UNIT_Z
#> 1 2016-01-15 11:00:00.013  1.071916   0.5157147   0.3950629   0.1611382
#> 2 2016-01-15 11:00:01.003  1.079748   0.4780306   0.3946065   0.2071108
#> 3 2016-01-15 11:00:02.003  1.001164   0.3800644   0.4082316   0.2128675
#> 4 2016-01-15 11:00:03.003  1.023815   0.4002251   0.4232901   0.2002998
#> 5 2016-01-15 11:00:04.003  1.016161   0.3984286   0.4094350   0.2082975
#> 6 2016-01-15 11:00:05.003  0.813439   0.3977156   0.2549294   0.1607941  # Use sample mhealth file for testing
filepaths = c(
system.file('extdata', 'mhealth.csv', package='MIMSunit')
)

# Test with multiple files
output = mims_unit_from_files(filepaths, epoch = "1 sec", dynamic_range = c(-8, 8))
#> 4 2017-03-16 12:25:53.000 0.4564886