#' ActiLife Counts calculator
#'
#' @param file the input file name
#' @param folderInn the input folder
#' @param folderOut the output folder
#' @param filesf frequency of the raw data
#'
#' @return the Actilife counts based on the provided raw data with frequency of 30 Hz
#'
#' @import data.table
#' @importFrom data.table fread
#' @importFrom utils write.csv
#'
#' @export
#'
acti_counts = function(file, folderInn, folderOut, filesf){
#predefined filter coefficients, as found by Jan Brond
A_coeff = c(1,-4.1637,7.5712,-7.9805,5.385,-2.4636,0.89238,0.06361,-1.3481,2.4734,-2.9257,2.9298,-2.7816,2.4777,-1.6847,0.46483,0.46565,-0.67312,0.4162,-0.13832,0.019852)
B_coeff = c(0.049109,-0.12284,0.14356,-0.11269,0.053804,-0.02023,0.0063778,0.018513,-0.038154,0.048727,-0.052577,0.047847,-0.046015,0.036283,-0.012977,-0.0046262,0.012835,-0.0093762,0.0034485,-0.00080972,-0.00019623)
fileR = gsub('.csv', '.Rdata', file)
fileInn = paste0(folderInn, file)
fileOut = paste0(folderOut, fileR)
print(file)
#read test data and split the 3D array into 3 1D arrays
dt = fread(fileInn, showProgress=FALSE)
#calculate counts, files at 30 hrz
cx = counts(dt[, 1], filesf, B=B_coeff, A=A_coeff)
cy = counts(dt[, 2], filesf, B=B_coeff, A=A_coeff)
cz = counts(dt[, 3], filesf, B=B_coeff, A=A_coeff)
print(' Counts calculated')
#combine counts into 2D matrix and save to disk
counts = data.table(x = cx, y = cy, z = cz)
#save(list = 'counts', file = fileOut)
write.csv(counts, paste0(folderOut, 'outputRuben.csv'))
print(' Finished')
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.