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. The first column of the input data should always include timestamps.

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

boolean. If TRUE, the input csv file will have a timestamp 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.

Examples

  default_ops = options()
  options(digits.secs=3)

  # Use the sample actigraph csv file provided by the package
  filepath = system.file('extdata', 'actigraph_timestamped.csv', package='MIMSunit')

  # Check file format
  readLines(filepath)[1:15]
#>  [1] "------------ Data File Created By ActiGraph GT3X+ ActiLife v6.13.3 Firmware v2.5.0 date format M/d/yyyy at 40 Hz  Filter Normal -----------"
#>  [2] "Serial Number: CLE2B20130009"                                                                                                               
#>  [3] "Start Time 11:27:00"                                                                                                                        
#>  [4] "Start Date 6/14/2018"                                                                                                                       
#>  [5] "Epoch Period (hh:mm:ss) 00:00:00"                                                                                                           
#>  [6] "Download Time 15:16:42"                                                                                                                     
#>  [7] "Download Date 6/14/2018"                                                                                                                    
#>  [8] "Current Memory Address: 0"                                                                                                                  
#>  [9] "Current Battery Voltage: 4.21     Mode = 12"                                                                                                
#> [10] "--------------------------------------------------"                                                                                         
#> [11] "Timestamp,Accelerometer X,Accelerometer Y,Accelerometer Z"                                                                                  
#> [12] "6/14/2018 12:08:39.725,-0.009,-0.053,-0.988"                                                                                                
#> [13] "6/14/2018 12:08:39.750,-0.009,-0.053,-0.982"                                                                                                
#> [14] "6/14/2018 12:08:39.775,-0.009,-0.053,-0.988"                                                                                                
#> [15] "6/14/2018 12:08:39.800,-0.009,-0.053,-0.982"                                                                                                

  # Load the file with timestamp column
  df = import_actigraph_csv(filepath)

  # Check loaded file
  head(df)
#>     HEADER_TIME_STAMP      X      Y      Z
#> 1 2018-06-14 12:08:39 -0.009 -0.053 -0.988
#> 2 2018-06-14 12:08:39 -0.009 -0.053 -0.982
#> 3 2018-06-14 12:08:39 -0.009 -0.053 -0.988
#> 4 2018-06-14 12:08:39 -0.009 -0.053 -0.982
#> 5 2018-06-14 12:08:39 -0.009 -0.053 -0.982
#> 6 2018-06-14 12:08:39 -0.009 -0.056 -0.988

  # Check more
  summary(df)
#>  HEADER_TIME_STAMP                      X                   Y           
#>  Min.   :2018-06-14 12:08:39.73   Min.   :-0.370000   Min.   :-0.41900  
#>  1st Qu.:2018-06-14 12:09:10.90   1st Qu.:-0.202000   1st Qu.:-0.23800  
#>  Median :2018-06-14 12:09:42.07   Median :-0.003000   Median :-0.05300  
#>  Mean   :2018-06-14 12:09:42.07   Mean   :-0.003874   Mean   :-0.05134  
#>  3rd Qu.:2018-06-14 12:10:13.25   3rd Qu.: 0.191000   3rd Qu.: 0.13800  
#>  Max.   :2018-06-14 12:10:44.43   Max.   : 0.370000   Max.   : 0.31400  
#>        Z         
#>  Min.   :-1.367  
#>  1st Qu.:-0.997  
#>  Median :-0.982  
#>  Mean   :-0.985  
#>  3rd Qu.:-0.974  
#>  Max.   :-0.496  

  # Use the sample actigraph csv file without timestamp
  filepath = system.file('extdata', 'actigraph_no_timestamp.csv', package='MIMSunit')

  # Check file format
  readLines(filepath)[1:15]
#>  [1] "------------ Data File Created By ActiGraph GT3X+ ActiLife v6.13.3 Firmware v2.5.0 date format M/d/yyyy at 40 Hz  Filter Normal -----------,,"
#>  [2] "Serial Number: CLE2B20130009,,"                                                                                                               
#>  [3] "Start Time 11:27:00,,"                                                                                                                        
#>  [4] "Start Date 6/14/2018,,"                                                                                                                       
#>  [5] "Epoch Period (hh:mm:ss) 00:00:00,,"                                                                                                           
#>  [6] "Download Time 15:16:42,,"                                                                                                                     
#>  [7] "Download Date 6/14/2018,,"                                                                                                                    
#>  [8] "Current Memory Address: 0,,"                                                                                                                  
#>  [9] "Current Battery Voltage: 4.21     Mode = 12,,"                                                                                                
#> [10] "--------------------------------------------------,,"                                                                                         
#> [11] "Accelerometer X,Accelerometer Y,Accelerometer Z"                                                                                              
#> [12] "-0.009,-0.053,-0.988"                                                                                                                         
#> [13] "-0.009,-0.053,-0.982"                                                                                                                         
#> [14] "-0.009,-0.053,-0.988"                                                                                                                         
#> [15] "-0.009,-0.053,-0.982"                                                                                                                         

  # 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:27:00 -0.009 -0.053 -0.988
#> 2 2018-06-14 11:27:00 -0.009 -0.053 -0.982
#> 3 2018-06-14 11:27:00 -0.009 -0.053 -0.988
#> 4 2018-06-14 11:27:00 -0.009 -0.053 -0.982
#> 5 2018-06-14 11:27:00 -0.009 -0.053 -0.982
#> 6 2018-06-14 11:27:00 -0.009 -0.056 -0.988

  # Check more
  summary(df)
#>  HEADER_TIME_STAMP                      X                   Y           
#>  Min.   :2018-06-14 11:27:00.00   Min.   :-0.370000   Min.   :-0.41900  
#>  1st Qu.:2018-06-14 11:27:31.18   1st Qu.:-0.202000   1st Qu.:-0.23800  
#>  Median :2018-06-14 11:28:02.34   Median :-0.003000   Median :-0.05300  
#>  Mean   :2018-06-14 11:28:02.34   Mean   :-0.003874   Mean   :-0.05134  
#>  3rd Qu.:2018-06-14 11:28:33.52   3rd Qu.: 0.191000   3rd Qu.: 0.13800  
#>  Max.   :2018-06-14 11:29:04.70   Max.   : 0.370000   Max.   : 0.31400  
#>        Z         
#>  Min.   :-1.367  
#>  1st Qu.:-0.997  
#>  Median :-0.982  
#>  Mean   :-0.985  
#>  3rd Qu.:-0.974  
#>  Max.   :-0.496  

  # Restore default options
  options(default_ops)