import_activpal3_csv imports the raw multi-channel accelerometer data stored in ActivPal3 csv format by converting the accelerometer values (in digital voltage values) to \(g\) unit.

import_activpal3_csv(filepath, header = FALSE)

Arguments

filepath

string. The filepath of the input data.

header

boolean. If TRUE, the input csv file will have column names in the first row.

Value

dataframe. The imported multi-channel accelerometer signal, with the first column being the timestamps in POSXlct format, and the rest columns being accelerometer values in \(g\) unit.

Details

ActivPal 3 sensors have known dynamic range to be \((-2g, +2g)\). And the sensor stores values using 8-bit memory storage. So, the digital voltage values may be converted to \(g\) unit using following equation.

$$x_g = \frac{x_{voltage} - 127}{2^8} * 4$$

How is it used in MIMS-unit algorithm?

This function is a File IO function that is used to import data from ActivPal3 devices during algorithm validation.

Examples

  default_ops = options()
  options(digits.secs=3)
  # Use the sample activpal3 csv file provided by the package
  filepath = system.file('extdata', 'activpal3.csv', package='MIMSunit')

  # Check the csv format
  readLines(filepath)[1:5]
#> [1] "43265.5705908565,112,140,58" "43265.5705914352,124,132,59"
#> [3] "43265.5705920139,116,126,61" "43265.5705925926,116,121,64"
#> [5] "43265.5705931713,102,113,68"

  # Load the file, in our case without header
  df = import_activpal3_csv(filepath, header=FALSE)

  # Check loaded file
  head(df)
#>     HEADER_TIME_STAMP         X         Y         Z
#> 1 2018-06-14 13:41:39 -0.234375  0.203125 -1.078125
#> 2 2018-06-14 13:41:39 -0.046875  0.078125 -1.062500
#> 3 2018-06-14 13:41:39 -0.171875 -0.015625 -1.031250
#> 4 2018-06-14 13:41:39 -0.171875 -0.093750 -0.984375
#> 5 2018-06-14 13:41:39 -0.390625 -0.218750 -0.921875
#> 6 2018-06-14 13:41:39 -0.421875 -0.546875 -0.843750

  # Check more
  summary(df)
#>  HEADER_TIME_STAMP                      X                  Y            
#>  Min.   :2018-06-14 13:41:39.04   Min.   :-1.56250   Min.   :-1.953125  
#>  1st Qu.:2018-06-14 13:42:41.53   1st Qu.: 0.04688   1st Qu.: 0.046875  
#>  Median :2018-06-14 13:43:44.01   Median : 0.06250   Median : 0.046875  
#>  Mean   :2018-06-14 13:43:44.01   Mean   : 0.02084   Mean   :-0.006097  
#>  3rd Qu.:2018-06-14 13:44:46.50   3rd Qu.: 0.06250   3rd Qu.: 0.046875  
#>  Max.   :2018-06-14 13:45:49.00   Max.   : 0.90625   Max.   : 1.218750  
#>        Z          
#>  Min.   :-1.9688  
#>  1st Qu.:-1.0156  
#>  Median : 1.1250  
#>  Mean   : 0.3263  
#>  3rd Qu.: 1.1250  
#>  Max.   : 1.9688  

  # Restore default options
  options(default_ops)