vignettes/truncation_threshold.Rmd
truncation_threshold.Rmd
Unlike Actigraph count algorithm, MIMS unit algorithm truncates non-zero values caused by floating number precision limit and the imperfect filtering transition band during MIMS unit computation. This article describes the process of deciding the truncation threshold.
The constant signal has zero variance.
st = Sys.time()
ts = seq(st, st + 300, length = 300 * 80)
x = rep(1, length(ts))
y = rep(0, length(ts))
z = rep(0, length(ts))
df = data.frame(HEADER_TIME_STAMP = ts, X=x, Y=y, Z=z)
Plot input accelerometer’s raw signal
MIMSunit::generate_interactive_plot(df, "Acceleration (g)", c(2,3,4))
Compute MIMS-unit values
mims = MIMSunit::custom_mims_unit(df, epoch = '1 sec', dynamic_range = c(-6, 6), allow_truncation = FALSE, output_mims_per_axis = TRUE)
Plot MIMS-unit values
MIMSunit::generate_interactive_plot(mims, "MIMS-unit values", c(2,3,4,5))
The output MIMS unit values have high shoot up at the beginning due to the nonlinear phase response of butterworth filter. It takes about 1 min for the output signal to stabilize. Although the signal is constant, the MIMS unit values are not zeros, which is caused by floating number precision limit during MIMS unit computation (filtering).
The median value after stabilization is
## [1] 3.188147e-10
And the standard deviation is
## [1] 7.586365e-14
The original signal has variance, first import data
df = MIMSunit::rest_on_table
## [1] "X axis variance: 1.997448e-03"
## [1] "Y axis variance: 2.012883e-03"
## [1] "Z axis variance: 1.732148e-03"
Plot signal of input data
MIMSunit::generate_interactive_plot(df, "Acceleration (g)", c(2,3,4))
Compute MIMS-unit values
mims = MIMSunit::custom_mims_unit(df, epoch = '1 sec', dynamic_range = c(-6, 6), allow_truncation=FALSE, output_mims_per_axis = TRUE)
Plot MIMS-unit values
MIMSunit::generate_interactive_plot(mims, "MIMS-unit values", c(2,3,4,5))
The output MIMS unit values have high shoot up at the beginning due to the nonlinear phase response of butterworth filter. It takes about 1 min for the output signal to stabilize. The MIMS unit algorithm outputs non-zero values, which is caused by fluctuation of electronic current of hardware.
The median value after stabilization is
## [1] "1.791693e-03"
And the standard deviation is
## [1] "2.653232e-04"
According to the analysis, a proper truncation threshold for MIMS unit value (1 second bout) can be one numerical magnitude above the larger value of the two cases above, which may be set at 1e-4
.
Therefore, the truncation threshold for a given MIMS unit at t
epoch length will be,
\[0.0001 \times t\]