segmentation {GENEAclassify} | R Documentation |
Perform Segmentation on GENEActiv Accelerometer Data
Description
Perform segmentation of Activinsights accelerometer data. Data are smoothed by the second, or by 10 data points, whichever number of records is greater.
Filtering is performed by tools from waveslim.
Options are passed to wavelet.filter
.
Usage
segmentation(
data,
outputfile = "detectedChanges",
outputdir = "GENEAclassification",
datacols = "default",
decimalplaces = "default",
filterWave = FALSE,
filtername = "haar",
j = 8,
changepoint = c("UpDownDegrees", "TempFreq", "UpDownFreq", "UpDownMean", "UpDownVar",
"UpDownMeanVar", "DegreesMean", "DegreesVar", "DegreesMeanVar",
"UpDownMeanVarDegreesMeanVar", "UpDownMeanVarMagMeanVar", "RadiansMean",
"RadiansVar", "RadiansMeanVar", "UpDownMeanDegreesVar"),
penalty = "Manual",
pen.value1 = 40,
pen.value2 = 400,
intervalseconds = 30,
mininterval = 5,
samplefreq = 100,
filterorder = 2,
boundaries = c(0.5, 5),
Rp = 3,
plot.it = FALSE,
hysteresis = 0.1,
stft_win = 10,
verbose = FALSE,
verbose_timer = FALSE,
...
)
Arguments
data |
the GENEActiv bin object to be segmented which should be the output
of the |
outputfile |
single character, file name for saving the segmentation output as CSV (and if plot.it is TRUE, corresponding plot PNG). If NULL, create no files. |
outputdir |
single character, the absolute or relative path to directory in which plot and changes files) should be created, or NULL (default "GENEAclassification"). Ignored if outputfile is NULL. |
datacols |
character vector constructed 'column.summary'. This object specifies the data and summary to output for the classification. The first part of each element must name column in the GENEAbin datasets specified by filePath. Derived columns may also be selected:
The second should be the name of a function that evaluates to lenth one.
The functions must contain only alphabetical characters
(no numbers, underscores or punctuation).
The default matrix, specified using the length 1 character vector
|
decimalplaces |
named numeric vector of decimal places with which to
round summary columns.
|
filterWave |
single logical, should a smoothing filter from |
filtername |
single character, the name of the wavelet to use for smoothing
when filter is TRUE. (default "haar") Passed to |
j |
single numeric, the level to which to smooth. Passed to |
changepoint |
defines the change point analysis to use. UpDownDegrees performs the change point analysis on the variance of arm elevation and wrist rotation. TempFreq performs a change point on the variance in the temeprature and frequency (Typically better for sleep behaviours). |
penalty |
single characgter, the penalty to use for changepoint detection. default ("SIC"). |
pen.value1 |
Value of the type 1 error required when penalty is "Asymptotic". |
pen.value2 |
Default set as NULL and so equals pen.value1 if no input. |
intervalseconds |
An integer number of seconds between 5 and 30 during which at most one changepoint may occur. |
mininterval |
single numeric that defines the smallest changepoint initially found. Passed to |
samplefreq |
The sampling frequency of the data, in hertz, when calculating the step number. (default 100). |
filterorder |
The order of the filter applied with respect to the butter or cheby options if stepCounter is used. The order of the moving average filter if step counter 2 is used.
See |
boundaries |
to pass to the filter in the step counting algorithm. |
Rp |
the decibel level that the cheby filter takes. See |
plot.it |
single logical, Creates a plot showing the zero crossings counted by the step counting algorithm#' @param Centre Centres the xz signal about 0 when set to True. |
hysteresis |
The hysteresis applied after zero crossing. (default 100mg) |
stft_win |
numeric for the window to calculate the frequency of an event using the |
verbose |
single logical to print additional progress reporting (default FALSE). |
verbose_timer |
single logical tp print additional progress reporting on time for each section of the function (default FALSE). |
... |
other arguments to be passed to |
Details
Performs the segmentation procedure on the provided elevation data. Optionally a wavelet filter is first applied to smooth the data. The number of changes occuring in a given number of seconds may be controlled using the intervalseconds argument. Changes will be removed based on which segments are the closest match in terms of variance. A series of features for each of the segments will then be calculated and returned as a csv file.
Value
The segment data are returned invisibly. This data frame has columns:
Serial.Number
Start.Time
Segment.Start.Time
Segment.Duration
UpDown.median
UpDown.var
Degrees.median
Degrees.mad
In addition, the requested columns are included. Optionally, as a side effect a csv file is returned listing all of the segments found in the data along with a variety of features for that segment. Optionally a png file plotting the data and the detected changes can also be produced.
Examples
### Load the data to segment keeping only the first quarter of the data
## library(GENEAread)
## testfile = file.path(system.file(package = "GENEAread"),
## "binfile",
## "TESTfile.bin")
## segData <- dataImport(binfile = testfile,
## downsample = 100, start = 0, end = 0.25)
## head(segData)
### Run loaded data through segmentation function
## segment <- segmentation(data = segData, outputfile = NULL)
## head(segment)
## segment2 <- segmentation(data = segData, outputfile = NULL,
## datacols = "Degrees.skew")
## head(segment2)