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_from_files(
  files,
  epoch = "5 sec",
  dynamic_range,
  output_mims_per_axis = FALSE,
  use_gui_progress = FALSE,
  file_type = "mhealth",
  ...
)

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
)

Arguments

files

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.

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.

output_mims_per_axis

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.

use_gui_progress

logical. If it is TRUE, show GUI progress bar on windows platform. Default is FALSE.

file_type

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.

df

dataframe. Input multi-channel accelerometer signal. The first column should be the time component

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.

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 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.

See also

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

Examples

# Use sample mhealth file for testing filepaths = c( system.file('extdata', 'mhealth.csv', package='MIMSunit'), system.file('extdata', 'mhealth1.csv', package='MIMSunit') ) # Test with single file mims_unit_from_files(c(filepaths[1]), epoch = "10 sec", dynamic_range = c(-2, 2))
#> ================================================================================
#> HEADER_TIME_STAMP MIMS_UNIT #> 1 2017-03-16 12:25:49.987 4.122642 #> 2 2017-03-16 12:25:59.007 4.587051 #> 3 2017-03-16 12:26:09.007 4.384481 #> 4 2017-03-16 12:26:19.007 4.263359 #> 5 2017-03-16 12:26:29.007 4.551940 #> 6 2017-03-16 12:26:39.007 4.624672
# Test with multiple files mims_unit_from_files(filepaths, epoch = "20 sec", dynamic_range = c(-2, 2))
#> ================================================================================ #> ================================================================================
#> HEADER_TIME_STAMP MIMS_UNIT #> 1 2017-03-16 12:25:49.987 8.7136829 #> 2 2017-03-16 12:26:09.007 8.6498777 #> 3 2017-03-16 12:26:29.007 9.1808195 #> 4 2017-03-16 12:26:49.013 2.3264562 #> 5 2017-03-16 12:27:09.003 0.8603559 #> 6 2017-03-16 12:27:29.003 5.6263526
# Use sample data for testing df = sample_raw_accel_data # compute mims unit values mims_unit(df, epoch = '5 min', dynamic_range=c(-8, 8))
#> ================================================================================
#> HEADER_TIME_STAMP MIMS_UNIT #> 1 2016-01-15 11:00:00.013 357.93411 #> 2 2016-01-15 11:05:00.003 50.06185 #> 3 2016-01-15 11:10:00.003 16.67783 #> 4 2016-01-15 11:15:00.003 -0.01000
# compute mims unit values with different epoch length output = mims_unit(df, epoch = '15 sec', dynamic_range=c(-8, 8))
#> ================================================================================
head(output)
#> HEADER_TIME_STAMP MIMS_UNIT #> 1 2016-01-15 11:00:00.013 14.66365 #> 2 2016-01-15 11:00:15.003 14.76582 #> 3 2016-01-15 11:00:30.003 14.35483 #> 4 2016-01-15 11:00:45.003 14.60055 #> 5 2016-01-15 11:01:00.003 21.73163 #> 6 2016-01-15 11:01:15.003 25.09067
# output axial values output = mims_unit(df, epoch = '15 sec', dynamic_range=c(-8, 8), output_mims_per_axis=TRUE)
#> ================================================================================
head(output)
#> HEADER_TIME_STAMP MIMS_UNIT MIMS_UNIT_X MIMS_UNIT_Y MIMS_UNIT_Z #> 1 2016-01-15 11:00:00.013 14.66365 6.156116 5.856715 2.650823 #> 2 2016-01-15 11:00:15.003 14.76582 5.872067 6.195618 2.698132 #> 3 2016-01-15 11:00:30.003 14.35483 5.827055 5.991348 2.536424 #> 4 2016-01-15 11:00:45.003 14.60055 5.869957 6.059673 2.670916 #> 5 2016-01-15 11:01:00.003 21.73163 6.026324 11.796255 3.909046 #> 6 2016-01-15 11:01:15.003 25.09067 5.682280 14.699529 4.708865