Title: | Activity Index Calculation using Raw 'Accelerometry' Data |
---|---|
Description: | Reads raw 'accelerometry' from 'GT3X+' data and plain table data to calculate Activity Index from 'Bai et al.' (2016) <doi:10.1371/journal.pone.0160644>. The Activity Index refers to the square root of the second-level average variance of the three 'accelerometry' axes. |
Authors: | Jiawei Bai [cre, aut] , John Muschelli [ctb] |
Maintainer: | Jiawei Bai <[email protected]> |
License: | GPL-3 |
Version: | 0.3.7 |
Built: | 2024-10-31 06:32:07 UTC |
Source: | CRAN |
computeActivityIndex
computes the Activity Index using raw
accelerometry data, based on user specified parameters such as sample rate
and epoch length.
computeActivityIndex(x, x_sigma0 = NULL, sigma0 = NULL, epoch = 1, hertz) ## Default S3 method: computeActivityIndex(x, x_sigma0 = NULL, sigma0 = NULL, epoch = 1, hertz) ## S3 method for class 'GT3XPlus' computeActivityIndex(x, x_sigma0 = NULL, sigma0 = NULL, epoch = 1, hertz)
computeActivityIndex(x, x_sigma0 = NULL, sigma0 = NULL, epoch = 1, hertz) ## Default S3 method: computeActivityIndex(x, x_sigma0 = NULL, sigma0 = NULL, epoch = 1, hertz) ## S3 method for class 'GT3XPlus' computeActivityIndex(x, x_sigma0 = NULL, sigma0 = NULL, epoch = 1, hertz)
x |
An object containing raw accelerometry data, which could
either be a 4-column data frame or " |
x_sigma0 |
A 4-column data frame containing the raw accelerometry
data when the device is not worn. The 1st column has the record/index
number. The 2nd to 4th columns contain the tri-axial raw acceleration. The
data will be used to calculate |
sigma0 |
Specify |
epoch |
The epoch length (in second) of the Activity Index. Must be a positive integer. |
hertz |
The sample rate of the data. |
x
could be either of the following two types of objects:
A 4-column data frame containing the tri-axial raw accelerometry
data in the 2nd to 4th column, and the associated record number (could be
time) in the 1st column. ReadTable
can be used to generate
such data frame.
An "GT3XPlus
" object given by function
ReadGT3XPlus
.
A data frame with two columns. The first column has the "record number" associated with each entry of Activity Index, while the second column has the actual value of Activity Index.
library(graphics) fname = system.file("extdata", "sample_table.csv.gz", package = "ActivityIndex") sampleTable = ReadTable(fname) AI_sampleTable_x = computeActivityIndex( sampleTable, x_sigma0 = sampleTable[1004700:1005600, ], epoch = 1, hertz = 30) AI_sampleTable_x plot(AI ~ RecordNo, data = AI_sampleTable_x, type = "l")
library(graphics) fname = system.file("extdata", "sample_table.csv.gz", package = "ActivityIndex") sampleTable = ReadTable(fname) AI_sampleTable_x = computeActivityIndex( sampleTable, x_sigma0 = sampleTable[1004700:1005600, ], epoch = 1, hertz = 30) AI_sampleTable_x plot(AI ~ RecordNo, data = AI_sampleTable_x, type = "l")
Print method for token
## S3 method for class 'ActivityIndex' print(x, ...)
## S3 method for class 'ActivityIndex' print(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods |
No return value, called for side effects
x = data.frame(RecordNo = rnorm(100), AI = rnorm(100)) class(x) = c("ActivityIndex", class(x)) print(x)
x = data.frame(RecordNo = rnorm(100), AI = rnorm(100)) class(x) = c("ActivityIndex", class(x)) print(x)
ReadGT3XPlus
reads the accelerometry data collected by ActiGraph GT3XPlus
in csv files generated by ActiLife software. It automatically parses the header
of the csv file to acquire the setting of the device.
ReadGT3XPlus(filename, epoch = 1)
ReadGT3XPlus(filename, epoch = 1)
filename |
The name of the csv file. |
epoch |
The epoch length (in second) of the Activity Index. Must
be a positive integer. The default is |
The function is tested on the csv files generated by ActiLife6, which have exactly 10 lines of headers, containing information about the device name, the starting and ending date/time of data collection, the sample rate, and the downloading date/time, etc. The 11th may further be omitted, if it is the header for the tri-axial acceleration time series. The function only reads the first 3 columns from then, if more are present.
The ReadGT3XPlus
returns an object of class "GT3XPlus
".
This class of object is supported by functions computeActivityIndex
.
A object of class "GT3XPlus
" is a list containing at least the following components:
SN
: Serial Number of the accelerometer
StartTime
: Start time of the data collection
StartDate
: Start date of the data collection
Epoch
: The Epoch time of each observation. If sample rate Hertz
>1, then Epoch
=00:00:00
DownloadTime
: Download time of the data
DownloadDate
: Download date the data
Hertz
: Sampling Rate
Raw
: a data frame with 5 columns containing the date, time and acceleration in X, Y and Z axes
for each observation.
filename = system.file("extdata","sample_GT3X+.csv.gz",package="ActivityIndex") res = ReadGT3XPlus(filename)
filename = system.file("extdata","sample_GT3X+.csv.gz",package="ActivityIndex") res = ReadGT3XPlus(filename)
ReadTable
reads the raw tri-axial accelerometry data in csv files.
ReadTable(filename)
ReadTable(filename)
filename |
The name of the csv file. |
The function reads csv files containing only three columns: acceleration time series of x-, y- and z-axis.
The ReadTable
returns a data frame with 4 columns: Index, X, Y and Z.
Index is the column for the indices of acceleration. X, Y and Z are for the acceleration
time series in each direction.
filename = system.file("extdata","sample_table.csv.gz",package="ActivityIndex") res = ReadTable(filename)
filename = system.file("extdata","sample_table.csv.gz",package="ActivityIndex") res = ReadTable(filename)
computing using raw accelerometry dataSigma0
computes , which is needed for
the Activity Index computing in
computeActivityIndex
Sigma0(x, hertz = 30)
Sigma0(x, hertz = 30)
x |
A 4-column data frame containing the raw accelerometry
data when the device is not worn. The 1st column has the record/index
number. The 2nd to 4th columns contain the tri-axial raw acceleration. The
data will be used to calculate |
hertz |
The sample rate of the data. |
, a numeric vector of length one.
filename = system.file("extdata","sample_GT3X+.csv.gz",package="ActivityIndex") res = ReadGT3XPlus(filename) hertz = res$Hertz x = res$Raw[ 1:1000, c("Time", "X", "Y", "Z")] res = Sigma0(x, hertz = hertz) testthat::expect_equal(res, c(SD = 0.184321637135534))
filename = system.file("extdata","sample_GT3X+.csv.gz",package="ActivityIndex") res = ReadGT3XPlus(filename) hertz = res$Hertz x = res$Raw[ 1:1000, c("Time", "X", "Y", "Z")] res = Sigma0(x, hertz = hertz) testthat::expect_equal(res, c(SD = 0.184321637135534))
A vector of length 86400 containing the time scale characters from 00:00:00 to 23:59:59.
A vector of characters with 86400 entries.