import_actigraph_csv imports the raw multi-channel accelerometer data stored in Actigraph raw csv format. It supports files from the following devices: GT3X, GT3X+, GT3X+BT, GT9X, and GT9X-IMU.

import_actigraph_csv(
  filepath,
  in_voltage = FALSE,
  has_ts = TRUE,
  header = TRUE
)

Arguments

filepath

string. The filepath of the input data.

in_voltage

set as TRUE only when the input Actigraph csv file is in analog quantized format and need to be converted into g value

has_ts

set as TRUE only when timestamp is provided as the first column

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

For old device (GT3X) that stores accelerometer values as digital voltage. The function will convert the values to \(g\) unit using the following equation.

$$x_g = \frac{x_{voltage}r}{(2 ^ r) - \frac{v}{2}}$$

Where \(v\) is the max voltage corresponding to the max accelerometer value that can be found in the meta section in the csv file; \(r\) is the resolution level which is the number of bits used to store the voltage values. \(r\) can also be found in the meta section in the csv file.

How is it used in MIMS-unit algorithm?

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

See also

Examples

default_ops = options() options(digits.secs=3) # Use the sample actigraph csv file provided by the package filepath = system.file('extdata', 'actigraph.csv', package='MIMSunit') # Check file format readLines(filepath)[1:15]
#> [1] "------------ Data File Created By ActiGraph GT3X ActiLife v6.13.3 Firmware v4.4.0 date format M/d/yyyy at 30 Hz Filter Normal -----------" #> [2] "Serial Number: MAT2A16099981" #> [3] "Start Time 11:21:00" #> [4] "Start Date 6/14/2018" #> [5] "Epoch Period (hh:mm:ss) 00:00:00" #> [6] "Download Time 15:17:47" #> [7] "Download Date 6/14/2018" #> [8] "Current Memory Address: 2545464" #> [9] "Current Battery Voltage: 4.21 Mode = 12" #> [10] "--------------------------------------------------" #> [11] "Axis1,Axis2,Axis3" #> [12] "-0.08,0.004,-1.052" #> [13] "-0.08,0.004,-1.056" #> [14] "-0.075,0.004,-1.056" #> [15] "-0.075,0.004,-1.052"
# Load the file without timestamp column df = import_actigraph_csv(filepath, has_ts=FALSE) # Check loaded file head(df)
#> HEADER_TIME_STAMP X Y Z #> 1 2018-06-14 11:21:00.000 -0.080 0.004 -1.052 #> 2 2018-06-14 11:21:01.422 -0.080 0.004 -1.056 #> 3 2018-06-14 11:21:02.845 -0.075 0.004 -1.056 #> 4 2018-06-14 11:21:04.267 -0.075 0.004 -1.052 #> 5 2018-06-14 11:21:05.690 -0.075 0.004 -1.052 #> 6 2018-06-14 11:21:07.112 -0.080 0.000 -1.056
# Check more summary(df)
#> HEADER_TIME_STAMP X Y #> Min. :2018-06-14 11:21:00.00 Min. :-0.44400 Min. :-0.366000 #> 1st Qu.:2018-06-14 12:20:11.75 1st Qu.:-0.08000 1st Qu.: 0.000000 #> Median :2018-06-14 13:19:23.50 Median :-0.08000 Median : 0.004000 #> Mean :2018-06-14 13:19:23.50 Mean :-0.07808 Mean : 0.002706 #> 3rd Qu.:2018-06-14 14:18:35.25 3rd Qu.:-0.07500 3rd Qu.: 0.004000 #> Max. :2018-06-14 15:17:47.00 Max. : 0.28500 Max. : 0.382000 #> Z #> Min. :-1.491 #> 1st Qu.:-1.056 #> Median :-1.052 #> Mean :-1.052 #> 3rd Qu.:-1.052 #> Max. :-0.785
# If set has_ts wrong, you should see a warning df = import_actigraph_csv(filepath, has_ts=TRUE)
#> Warning: Unnamed `col_types` should have the same length as `col_names`. Using smaller of the two.
#> Warning: has_ts = TRUE, but only 3 columns, setting has_ts = FALSE
# Check loaded file head(df)
#> HEADER_TIME_STAMP X Y Z #> 1 2018-06-14 11:21:00.000 -0.080 0.004 -1.052 #> 2 2018-06-14 11:21:01.422 -0.080 0.004 -1.056 #> 3 2018-06-14 11:21:02.845 -0.075 0.004 -1.056 #> 4 2018-06-14 11:21:04.267 -0.075 0.004 -1.052 #> 5 2018-06-14 11:21:05.690 -0.075 0.004 -1.052 #> 6 2018-06-14 11:21:07.112 -0.080 0.000 -1.056
# Check more summary(df)
#> HEADER_TIME_STAMP X Y #> Min. :2018-06-14 11:21:00.00 Min. :-0.44400 Min. :-0.366000 #> 1st Qu.:2018-06-14 12:20:11.75 1st Qu.:-0.08000 1st Qu.: 0.000000 #> Median :2018-06-14 13:19:23.50 Median :-0.08000 Median : 0.004000 #> Mean :2018-06-14 13:19:23.50 Mean :-0.07808 Mean : 0.002706 #> 3rd Qu.:2018-06-14 14:18:35.25 3rd Qu.:-0.07500 3rd Qu.: 0.004000 #> Max. :2018-06-14 15:17:47.00 Max. : 0.28500 Max. : 0.382000 #> Z #> Min. :-1.491 #> 1st Qu.:-1.056 #> Median :-1.052 #> Mean :-1.052 #> 3rd Qu.:-1.052 #> Max. :-0.785
# Restore default options options(default_ops)