mims_unit | R Documentation |
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", ... )
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. |
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 |
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
|
epoch |
string. Any format that is acceptable by argument |
dynamic_range |
numerical vector. The dynamic ranges of the input
signal. Should be a 2-element numerical vector. |
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. |
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. |
use_snapshot_to_check |
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. |
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. For a single file, please wrap the filepath in a vector 'c(filepath)'. |
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. |
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.
This is the main entry of MIMS-unit algorithm.
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.
Please make sure the input data do not contain duplicated timestamps. See more information about this issue. Otherwise the computation will stop.
Other Top level API functions:
custom_mims_unit()
,
sensor_orientations()
,
shiny_app()
# 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) head(output) # 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)) head(output)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.