| Title: | Pre-Processing of 'GENEActiv' Data |
|---|---|
| Description: | Analytics to read in and segment raw 'GENEActiv' accelerometer data into epochs and events. For more details on the 'GENEActiv' device, see <https://activinsights.com/resources/geneactiv-support-1-2/>. |
| Authors: | Joss Langford [aut], Ian Long [aut], Jia Ying Chua [aut, cre], Activinsights Ltd [cph] |
| Maintainer: | Jia Ying Chua <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.2.0 |
| Built: | 2026-06-09 06:22:35 UTC |
| Source: | https://github.com/cran/GENEAcore |
Aggregate Epochs
aggregate_epochs( time_series, measure = "AGSA", time = "timestamp", sample_frequency, duration = NA, first_epoch_timestamp = NA, fun = mean ) aggregateEpochs(...)aggregate_epochs( time_series, measure = "AGSA", time = "timestamp", sample_frequency, duration = NA, first_epoch_timestamp = NA, fun = mean ) aggregateEpochs(...)
time_series |
Data frame to be aggregated. |
measure |
Name of the measure columns to be included. |
time |
Name of the time column. |
sample_frequency |
Measurement frequency of data. |
duration |
Time duration to aggregate in each epoch. |
first_epoch_timestamp |
Time to start the first epoch, defaults to first record. |
fun |
Function to apply on aggregation, defaults to mean. |
... |
Additional arguments passed to internal aggregation functions. |
Wrapper function that calls aggregate_periods for epochs (duration of fixed length).
Data frame of aggregated epochs.
timestamp <- c( 1619424004, 1619424005, 1619424006, 1619424007, 1619424008, 1619424009, 1619424010, 1619424011, 1619424012, 1619424013, 1619424014, 1619424015 ) value <- c( 0.729614366, 1.729115871, 0.804973546, 2.510181118, 2.23764038, 0.613203747, 0.681953275, 0.089566943, 0.021042388, 2.4780338, 2.437488989, 2.632635727 ) data <- data.frame(timestamp, value) aggregated <- aggregate_epochs(data, duration = 5, measure = "value", sample_frequency = 1, first_epoch_timestamp = 1619424005, time = "timestamp" )timestamp <- c( 1619424004, 1619424005, 1619424006, 1619424007, 1619424008, 1619424009, 1619424010, 1619424011, 1619424012, 1619424013, 1619424014, 1619424015 ) value <- c( 0.729614366, 1.729115871, 0.804973546, 2.510181118, 2.23764038, 0.613203747, 0.681953275, 0.089566943, 0.021042388, 2.4780338, 2.437488989, 2.632635727 ) data <- data.frame(timestamp, value) aggregated <- aggregate_epochs(data, duration = 5, measure = "value", sample_frequency = 1, first_epoch_timestamp = 1619424005, time = "timestamp" )
Aggregate Events
aggregate_events( time_series, measure = "AGSA", time = "timestamp", sample_frequency, events = NA, start_time = "start", end_time = "end", fun = mean ) aggregateEvents(...) aggregatePeriods(...) createEventMapping(...)aggregate_events( time_series, measure = "AGSA", time = "timestamp", sample_frequency, events = NA, start_time = "start", end_time = "end", fun = mean ) aggregateEvents(...) aggregatePeriods(...) createEventMapping(...)
time_series |
Data frame to be aggregated. |
measure |
Name of the measure columns to be included. |
time |
Name of the time column. |
sample_frequency |
Measurement frequency of data. |
events |
Data frame containing the start and end index of each event. |
start_time |
Name of the column in events containing the start index of the events. |
end_time |
Name of the column in events containing the end index of the events. |
fun |
Function to apply on aggregation, defaults to mean. |
... |
Additional arguments passed to internal aggregation functions. |
Wrapper function that calls aggregate_periods for events (duration of variable length).
Data frame of aggregated events.
timestamp <- c( 1619424004, 1619424005, 1619424006, 1619424007, 1619424008, 1619424009, 1619424010, 1619424011, 1619424012, 1619424013, 1619424014, 1619424015 ) value <- c( 0.729614366, 1.729115871, 0.804973546, 2.510181118, 2.23764038, 0.613203747, 0.681953275, 0.089566943, 0.021042388, 2.4780338, 2.437488989, 2.632635727 ) data <- data.frame(timestamp, value) event_start <- c(1, 5, 10) event_end <- c(4, 9, 12) aggregated_events <- aggregate_events(data, events = data.frame(start = event_start, end = event_end), measure = "value", time = "timestamp", start_time = "start", end_time = "end", sample_frequency = 1, fun = sum )timestamp <- c( 1619424004, 1619424005, 1619424006, 1619424007, 1619424008, 1619424009, 1619424010, 1619424011, 1619424012, 1619424013, 1619424014, 1619424015 ) value <- c( 0.729614366, 1.729115871, 0.804973546, 2.510181118, 2.23764038, 0.613203747, 0.681953275, 0.089566943, 0.021042388, 2.4780338, 2.437488989, 2.632635727 ) data <- data.frame(timestamp, value) event_start <- c(1, 5, 10) event_end <- c(4, 9, 12) aggregated_events <- aggregate_events(data, events = data.frame(start = event_start, end = event_end), measure = "value", time = "timestamp", start_time = "start", end_time = "end", sample_frequency = 1, fun = sum )
Apply Absolute Gravity-Subtracted Acceleration (AGSA)
apply_AGSA(x)apply_AGSA(x)
x |
Calibrated acceleration data frame. |
Measure column appended to end of calibrated data frame.
x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_AGSA(calibrated)x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_AGSA(calibrated)
Apply Calibration
apply_calibration(sensor_data, cal_params, measurement_device, use_temp = TRUE)apply_calibration(sensor_data, cal_params, measurement_device, use_temp = TRUE)
sensor_data |
Raw sensor-level data from a bin file in the form (x, y, z, Light, Button, Temp). |
cal_params |
Calibration parameters for acceleration and light from MPI. |
measurement_device |
Name of the measurement device used "GENEActiv 1.1", "GENEActiv 1.2" or "GENEActiv 1.3". |
use_temp |
Allows auto-calibration to be run with and without temperature compensation. |
Function to apply calibration to sensor-level data from a bin file.
Data frame of calibrated sensor data.
cal_params <- list( scale = c(1.015, 1.017, 1.027), offset = c(0.00128, 0.0383, 0.0138), temperature_offset = c(0, 0, 0), error = NA, light_denominator = 48, light_numerator = 911 ) rawdata <- data.frame( time = c(rep(1726650857, 5)), x = c(0.2421875, 0.24609375, 0.25390625, 0.24609375, 0.23828125), y = c(-0.04296875, -0.04687500, -0.03515625, -0.03125000, -0.04296875), z = c(-0.9453125, -0.9453125, -0.9531250, -0.9531250, -0.9609375), light = c(rep(22, 5)), button = c(rep(0, 5)), temp = c(rep(21.3, 5)), volts = c(rep(4.0896, 5)) ) calibrated <- apply_calibration(rawdata, cal_params, "GENEActiv 1.1")cal_params <- list( scale = c(1.015, 1.017, 1.027), offset = c(0.00128, 0.0383, 0.0138), temperature_offset = c(0, 0, 0), error = NA, light_denominator = 48, light_numerator = 911 ) rawdata <- data.frame( time = c(rep(1726650857, 5)), x = c(0.2421875, 0.24609375, 0.25390625, 0.24609375, 0.23828125), y = c(-0.04296875, -0.04687500, -0.03515625, -0.03125000, -0.04296875), z = c(-0.9453125, -0.9453125, -0.9531250, -0.9531250, -0.9609375), light = c(rep(22, 5)), button = c(rep(0, 5)), temp = c(rep(21.3, 5)), volts = c(rep(4.0896, 5)) ) calibrated <- apply_calibration(rawdata, cal_params, "GENEActiv 1.1")
Apply Rotation (Degrees)
apply_degrees(x)apply_degrees(x)
x |
Calibrated acceleration data frame. |
Measure column appended to end of calibrated data frame.
x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_degrees(calibrated)x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_degrees(calibrated)
Apply Euclidean Norm Minus One (ENMO)
apply_ENMO(x)apply_ENMO(x)
x |
Calibrated acceleration data frame. |
Measure column appended to end of calibrated data frame.
x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_ENMO(calibrated)x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_ENMO(calibrated)
Apply Rotation (radians)
apply_radians(x)apply_radians(x)
x |
Calibrated acceleration data frame. |
Measure column appended to end of calibrated data frame.
x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_radians(calibrated)x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_radians(calibrated)
Apply Elevation (UpDown)
apply_updown(x)apply_updown(x)
x |
Calibrated acceleration data frame. |
Measure column appended to end of calibrated data frame.
x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_updown(calibrated)x <- c(0.14268, 0.21757, -0.529, -0.36383) y <- c(0.26385, 0.27295, 0.29220, 0.79510) z <- c(0.27722, 0.20296, 0.35092, 0.27459) calibrated <- data.frame(x, y, z) calibrated <- apply_updown(calibrated)
Bin File Summary
binfile_summary(input, recursive = TRUE, identifier_mapping_record = NULL)binfile_summary(input, recursive = TRUE, identifier_mapping_record = NULL)
input |
Bin file path - single bin file or folder of bin files. |
recursive |
TRUE applies the operation to all nested elements. |
identifier_mapping_record |
File path of the exported identifier_mapping_record CSV file. |
Wrapper function that calls create_summary for bin files only.
Data frame of bin file or MPI summary.
Function to calculate auto-calibration parameters from known still points from a bin file that create a unitary sphere.
calc_autocalparams( binfile, binfile_path, output_folder, sphere_points, use_temp = TRUE, spherecrit = 0.3, maxiter = 500, tol = 1e-13 )calc_autocalparams( binfile, binfile_path, output_folder, sphere_points, use_temp = TRUE, spherecrit = 0.3, maxiter = 500, tol = 1e-13 )
binfile |
Text lines read from an open connection to a bin file. |
binfile_path |
Path to the bin file to be processed. |
output_folder |
Path to the folder containing GENEAcore run outputs and Measurement Period Information (MPI) files. |
sphere_points |
List of points that populate a unitary sphere and their associated temperature in the form (x,y,z,temp). |
use_temp |
Allows auto-calibration to be run with and without temperature compensation. |
spherecrit |
The minimum required acceleration value for each axis in both directions to ensure sufficient range of non-movement positions for auto-calibration to be reliable. |
maxiter |
The maximum number of sphere fit iterations attempted during auto-calibration to converge. |
tol |
The limit of incremental sphere fit improvements before auto-calibration is considered complete. |
List of auto-calibration parameters within the measurement period information (MPI).
binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") output_folder <- tempdir() con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) MPI <- create_MPI(binfile, binfile_path, output_folder) nonmovement_list <- detect_nonmovement(binfile, binfile_path, output_folder) MPI <- calc_autocalparams( binfile, binfile_path, output_folder, nonmovement_list$non_movement$sphere_points )binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") output_folder <- tempdir() con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) MPI <- create_MPI(binfile, binfile_path, output_folder) nonmovement_list <- detect_nonmovement(binfile, binfile_path, output_folder) MPI <- calc_autocalparams( binfile, binfile_path, output_folder, nonmovement_list$non_movement$sphere_points )
Function to print out a summary of an MPI (Measurement Process Information) file, or all MPI files found if a directory path is supplied.
check_MPI(input, print_output = TRUE)check_MPI(input, print_output = TRUE)
input |
Fully qualified path to a MPI file or a directory containing MPI files, the directory is searched recursively. |
print_output |
Boolean to print MPI summary to console. |
## Not run: check_MPI("fully qualified path to a directory structure containing MPI files") check_MPI("fully qualified path to a MPI file") ## End(Not run)## Not run: check_MPI("fully qualified path to a directory structure containing MPI files") check_MPI("fully qualified path to a MPI file") ## End(Not run)
Creates per-participant rest activity and behavioural bout atoms and a payload
create_coel_atoms_json(data_folder)create_coel_atoms_json(data_folder)
data_folder |
Folder that contains raw data bin files for which bouts have been created for. |
Create Measurement Period Information
create_MPI(binfile, binfile_path, output_folder, out_rds = TRUE)create_MPI(binfile, binfile_path, output_folder, out_rds = TRUE)
binfile |
Text lines read from an open connection to a bin file. |
binfile_path |
Path to the bin file to be processed. |
output_folder |
Folder to write MPI file in. |
out_rds |
Allows RDS output to be saved during MPI creation. |
Function to create measurement period information (MPI) from a GENEActiv bin file
List of measurement period information.
binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) output_folder <- tempdir() MPI <- create_MPI(binfile, binfile_path, output_folder, out_rds = FALSE)binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) output_folder <- tempdir() MPI <- create_MPI(binfile, binfile_path, output_folder, out_rds = FALSE)
Detect Non-movement
detect_nonmovement( binfile, binfile_path, output_folder, still_seconds = 120, sd_threshold = 0.013, temp_seconds = 240, border_seconds = 300, long_still_seconds = 120 * 60, delta_temp_threshold = -0.7, posture_changes_max = 2, non_move_duration_max = 12 * 60 * 60 )detect_nonmovement( binfile, binfile_path, output_folder, still_seconds = 120, sd_threshold = 0.013, temp_seconds = 240, border_seconds = 300, long_still_seconds = 120 * 60, delta_temp_threshold = -0.7, posture_changes_max = 2, non_move_duration_max = 12 * 60 * 60 )
binfile |
Text lines read from an open connection to a bin file. |
binfile_path |
Path to the bin file to be processed. |
output_folder |
Path to the folder containing GENEAcore run outputs and Measurement Period Information (MPI) files. |
still_seconds |
The number of seconds included in the rolling standard deviation calculation of non-movement from 1Hz downsampled data. |
sd_threshold |
The threshold applied to the rolling standard deviation of mean acceleration standard deviation of 1Hz downsampled data to determine non-movement. |
temp_seconds |
The number of seconds included in the rolling temperature difference calculation for non-wear, which also determines the shortest detection duration. |
border_seconds |
The maximum number of seconds between non-movement events for them to be combined into the same period. |
long_still_seconds |
The number of seconds for any single non-movement event beyond which the whole period is classed as non-wear. |
delta_temp_threshold |
The threshold applied to the rolling temperature difference to determine non-wear. |
posture_changes_max |
The maximum number of adjoining non-movement events that make up a single period of non-wear less than the maximum non-move duration. |
non_move_duration_max |
The number of seconds beyond which non-movement events are automatically classed as non-wear. |
Function to detect non-movement events, non-wear events and sphere points from a 1Hz downsampled bin file.
List of sphere points, non-movement events and non-wear events.
binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) output_folder <- tempdir() MPI <- create_MPI(binfile, binfile_path, output_folder) MPI <- detect_nonmovement(binfile, binfile_path, output_folder)binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) output_folder <- tempdir() MPI <- create_MPI(binfile, binfile_path, output_folder) MPI <- detect_nonmovement(binfile, binfile_path, output_folder)
Detect Transitions
detect_transitions( measurements, minimum_event_duration = 5, x_cpt_penalty = 18, y_cpt_penalty = 25, z_cpt_penalty = 16, cut_time_24hr = "15:00" )detect_transitions( measurements, minimum_event_duration = 5, x_cpt_penalty = 18, y_cpt_penalty = 25, z_cpt_penalty = 16, cut_time_24hr = "15:00" )
measurements |
The downsampled measurements to calculate changepoint transitions. |
minimum_event_duration |
The minimum interval between changepoint transitions. |
x_cpt_penalty |
The manual penalty value applied in the PELT changepoint
algorithm for the x axis, see |
y_cpt_penalty |
The manual penalty value applied in the PELT changepoint
algorithm for the y axis, see |
z_cpt_penalty |
The manual penalty value applied in the PELT changepoint
algorithm for the z axis, see |
cut_time_24hr |
Time in 24h to split days up by. |
Function to detect mean and variance changepoints in 1Hz acceleration data from a bin file.
List of time and index of each transition.
Daily Measures for Data Folder
folder_measures( data_folder, measure_type = c("activity", "sleep", "both"), minimum_valid_hours = 22, include_participant_info = FALSE, identifier_mapping_record = NULL )folder_measures( data_folder, measure_type = c("activity", "sleep", "both"), minimum_valid_hours = 22, include_participant_info = FALSE, identifier_mapping_record = NULL )
data_folder |
Folder that contains raw data bin files to process or path to single bin file. |
measure_type |
The type of daily measure summary to generate. |
minimum_valid_hours |
Minimum hours of wear time in a 24-hour day to be considered a valid day for reported measures. |
include_participant_info |
If |
identifier_mapping_record |
File path of the exported identifier_mapping_record CSV file. |
Wrapper to process and output daily activity measures aggregate for all bin files in the data folder
Daily aggregated activity measures (.csv)
GENEAbout function which performs the following tasks for each available day:
Assign bout classifications to events only
Reports aggregated daily activity and sleep measures
Creates COEL v2.0 Behavioural Atoms JSON
geneabout(data_folder = data_folder, control = list())geneabout(data_folder = data_folder, control = list())
data_folder |
Folder that contains raw data bin files to process or path to single bin file. |
control |
Named list of optional settings for geneacore functions. |
Control options (all optional):
Logical. Default FALSE. Print elapsed times of each processing step.
Integer. Default 22. Minimum hours of wear time in a 24-hour day to be considered a valid day for reported measures.
Logical. Default FALSE.
If TRUE,daily bouts are saved as RDS files and CSV files (if output_csv is set to TRUE).
If FALSE, only a single RDS file containing bouts for all processed days is saved.
Logical. Default FALSE. Exports bouts as COEL behavioural atoms in JSON format.
For each bin file in the data folder, behavioural bout atoms and rest activity atoms are produced.
Additionally, aggregated JSON files are created in the Batch JSON outputs subfolder.
String. Default NULL.
If a file path to the exported identifier_mapping_record.csv is provided,
encrypted participant IDs in the activity and sleep measures will be replaced
with their corresponding mapped identifiers.
## Not run: controls <- list(minimum_valid_hours = 4, timer = TRUE, coel_json = TRUE) geneabout("path/to/folder", controls) ## End(Not run)## Not run: controls <- list(minimum_valid_hours = 4, timer = TRUE, coel_json = TRUE) geneabout("path/to/folder", controls) ## End(Not run)
GENEAcore function that wraps the functionalities of geneacore_part1 to geneacore_part4. GENEAcore function which performs the following tasks for each valid day:
Checks and reads the data file and creates the Measurement Period Information (MPI)
Downsamples the file to 1Hz and detects periods of non movement
Calculates auto calibration parameters for the device
Samples daily raw bin file data and saves as daily RDS files
Reads and saves button press timestamps to the Measurement Period Information (MPI)
Applies calibration parameters to raw data
Identifies transitions for events processing only
Performs aggregation by event and/or epoch
Calculate steps, if option selected
Calculate non-wear coverage and rest coverage of events and/or epochs
Assign bout classifications to events only
Reports aggregated daily activity and sleep measures
Consolidates daily epochs or bouts outputs into a single file
geneacore(data_folder = data_folder, control = list())geneacore(data_folder = data_folder, control = list())
data_folder |
Folder that contains raw data bin files to process or path to single bin file. |
control |
Named list of optional settings for geneacore functions. |
Control options (all optional):
String. Default "15:00". Time in 24h to split days up by.
Logical. Default FALSE. Create epoch outputs.
Integer. Default 1. Specify duration of fixed epochs.
Logical. Default TRUE. Create event outputs.
Logical. Default FALSE. Calculate step counts and stepping rate during epoch processing.
Steps are always calculated during events processing.
Logical. Default FALSE. Allows CSV output to be saved during epoch and event processing.
Logical. Default FALSE. Print elapsed times of each processing step.
Integer vector of length 2. Default c(1,1).
Controls day split when running function across multiple R sessions.
The first value is the current session number and the second is the total number of sessions.
The default processes all days in a single session.
Integer. Default 0. Hours of wear time in a 24-hour day to be considered a valid day to be processed.
## Not run: controls <- list(output_csv = TRUE, required_processing_hours = 4, timer = TRUE) geneacore("path/to/folder", controls) ## End(Not run)## Not run: controls <- list(output_csv = TRUE, required_processing_hours = 4, timer = TRUE) geneacore("path/to/folder", controls) ## End(Not run)
GENEAcore function which performs the following tasks:
Checks and reads the data file and creates the Measurement Period Information (MPI)
Downsamples the file to 1Hz and detects periods of non movement
Calculates auto calibration parameters for the device
geneacore_part1(data_folder = data_folder, control = list())geneacore_part1(data_folder = data_folder, control = list())
data_folder |
Folder that contains raw data bin files to process or path to single bin file. |
control |
Named list of optional settings for geneacore functions. |
Control options (all optional):
String. Default "15:00". Time in 24h to split days up by.
Logical. Default FALSE. Print elapsed times of each processing step.
Measurement Period Information (.rds, .json) and 1Hz downsampled data (.rds)
## Not run: controls <- list(output_csv = TRUE, required_processing_hours = 4, timer = TRUE) geneacore_part1("path/to/folder", controls) ## End(Not run)## Not run: controls <- list(output_csv = TRUE, required_processing_hours = 4, timer = TRUE) geneacore_part1("path/to/folder", controls) ## End(Not run)
GENEAcore function which performs the following tasks for each valid day:
Samples daily raw bin file data and saves as daily RDS files
Reads and saves button press timestamps to the Measurement Period Information (MPI)
geneacore_part2(data_folder = data_folder, control = list())geneacore_part2(data_folder = data_folder, control = list())
data_folder |
Folder that contains raw data bin files to process or path to single bin file. |
control |
Named list of optional settings for geneacore functions. |
Control options (all optional):
Integer. Default 0. Hours of wear time in a 24-hour day to be considered a valid day to be processed.
Logical. Default FALSE. Print elapsed times of each processing step.
Daily raw data sample of x, y, z, Light, Button, Temperature and Voltage (.rds)
## Not run: controls <- list(output_csv = TRUE, required_processing_hours = 4, timer = TRUE) geneacore_part2("path/to/folder", controls) ## End(Not run)## Not run: controls <- list(output_csv = TRUE, required_processing_hours = 4, timer = TRUE) geneacore_part2("path/to/folder", controls) ## End(Not run)
GENEAcore function which performs the following tasks for each valid day:
Applies calibration parameters to raw data
Identifies transitions for events processing only
Performs aggregation by event and/or epoch
Calculate steps, if option selected
Calculate non-wear coverage and rest coverage of events and/or epochs
geneacore_part3(data_folder = data_folder, control = list())geneacore_part3(data_folder = data_folder, control = list())
data_folder |
Folder that contains raw data bin files to process or path to single bin file. |
control |
Named list of optional settings for geneacore functions. |
Control options (all optional):
Logical. Default FALSE. Create epoch outputs.
Integer. Default 1. Specify duration of fixed epochs.
Logical. Default TRUE. Create event outputs.
Logical. Default FALSE. Calculate step counts and stepping rate during epoch processing.
Steps are always calculated during events processing.
Logical. Default FALSE. Allows CSV output to be saved during epoch and event processing.
Logical. Default FALSE. Print elapsed times of each processing step.
Integer vector of length 2. Default c(1,1).
Controls day split when running function across multiple R sessions.
The first value is the current session number and the second is the total number of sessions.
The default processes all days in a single session.
Integer. Default 0. Hours of wear time in a 24-hour day to be considered a valid day to be processed.
## Not run: controls <- list(output_csv = TRUE, required_processing_hours = 4, timer = TRUE) geneacore_part3("path/to/folder", controls) ## End(Not run)## Not run: controls <- list(output_csv = TRUE, required_processing_hours = 4, timer = TRUE) geneacore_part3("path/to/folder", controls) ## End(Not run)
GENEAcore function which performs the following tasks:
Consolidates daily epochs or bouts outputs into a single file
geneacore_part4(data_folder = data_folder, control = list())geneacore_part4(data_folder = data_folder, control = list())
data_folder |
Folder that contains raw data bin files to process or path to single bin file. |
control |
Named list of optional settings for geneacore functions. |
Control options (all optional):
Logical. Default TRUE. Create epoch outputs.
Integer. Default 1. Specify duration of fixed epochs.
Logical. Default TRUE. Create event outputs.
Logical. Default FALSE. Allows CSV output to be saved during epoch and event processing.
Consolidated epochs and/or bouts output (.rds/.csv)
## Not run: controls <- list(output_csv = TRUE, minimum_valid_hours = 4, timer = TRUE) geneacore_part4("path/to/folder", controls) ## End(Not run)## Not run: controls <- list(output_csv = TRUE, minimum_valid_hours = 4, timer = TRUE) geneacore_part4("path/to/folder", controls) ## End(Not run)
Generate Unique Bin File Identifier
get_UniqueBinFileIdentifier(binfile)get_UniqueBinFileIdentifier(binfile)
binfile |
Text lines read from an open connection to a bin file. |
Function to create a UniqueBinFileIdentifier from a GENEActiv bin file.
Single string identifier.
binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) UniqueBinFileIdentifier <- get_UniqueBinFileIdentifier(binfile)binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) UniqueBinFileIdentifier <- get_UniqueBinFileIdentifier(binfile)
MPI Summary
MPI_summary(input, recursive = TRUE, identifier_mapping_record = NULL)MPI_summary(input, recursive = TRUE, identifier_mapping_record = NULL)
input |
MPI path - single MPI file or folder of MPI files. |
recursive |
TRUE applies the operation to all nested elements. |
identifier_mapping_record |
File path of the exported identifier_mapping_record CSV file. |
Wrapper function that calls create_summary for MPI only.
Data frame of MPI summary.
Sample Bin File
sample_binfile( binfile, binfile_path, output_folder, start_time = NULL, end_time = NULL, downsample = TRUE, output_csv = FALSE, save_raw = FALSE )sample_binfile( binfile, binfile_path, output_folder, start_time = NULL, end_time = NULL, downsample = TRUE, output_csv = FALSE, save_raw = FALSE )
binfile |
Text lines read from an open connection to a bin file. |
binfile_path |
Path to the bin file to be processed. |
output_folder |
Path to the folder containing GENEAcore run outputs and Measurement Period Information (MPI) files. |
start_time |
Time stamp to start the data read, default start of file. |
end_time |
Time stamp to end the data read, default end of file. |
downsample |
Logical to determine whether to downsample the file, default TRUE. |
output_csv |
Allow outputs of bin file sampling to be saved as CSV. |
save_raw |
Save raw sampled data as RDS for quicker reprocessing, default FALSE. |
Function to read in a GENEActiv bin file with option to downsample to 1Hz. This can read the whole of the file or just a portion of it by setting the start_time and end_time parameters.
List of 1Hz downsampled data or raw sample data.
binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") output_folder <- tempdir() con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) measurements <- sample_binfile(binfile, binfile_path, output_folder)binfile_path <- system.file("extdata/10Hz_calibration_file_20Nov25.bin", package = "GENEAcore") output_folder <- tempdir() con <- file(binfile_path, "r") binfile <- readLines(con, skipNul = TRUE) close(con) measurements <- sample_binfile(binfile, binfile_path, output_folder)
Function to calculate the number and variance of the steps in the data.
step_counter( step_data, sample_frequency = 100, filter_order = 2, boundaries = c(0.5, 5), Rp = 3, step_hysteresis = 0.05, fun = c("GENEAcount", "mean", "sd", "stepdiff") ) stepCounter(...)step_counter( step_data, sample_frequency = 100, filter_order = 2, boundaries = c(0.5, 5), Rp = 3, step_hysteresis = 0.05, fun = c("GENEAcount", "mean", "sd", "stepdiff") ) stepCounter(...)
step_data |
The data to use for calculating the steps. This should be a vector of acceleration values. |
sample_frequency |
The sampling frequency of the data, in hertz, when calculating the step number (default 100). |
filter_order |
single integer, order of the Chebyshev bandpass filter,
passed to argument n of |
boundaries |
length 2 numeric vector specifying lower and upper bounds
of Chebychev filter (default |
Rp |
the decibel level that the cheby filter takes, see |
step_hysteresis |
The hysteresis applied after zero crossing of the bandpass filtered y-axis signal. |
fun |
character vector naming functions by which to summarize steps. "count" is an internally implemented summarizing function that returns step count. |
... |
Additional arguments passed to internal aggregation functions. |
Returns a vector with length fun.
d1 <- sin(seq(0.1, 100, 0.1)) / 2 + rnorm(1000) / 10 + 1 Steps4 <- step_counter(d1) length(Steps4) mean(Steps4) sd(Steps4) plot(Steps4)d1 <- sin(seq(0.1, 100, 0.1)) / 2 + rnorm(1000) / 10 + 1 Steps4 <- step_counter(d1) length(Steps4) mean(Steps4) sd(Steps4) plot(Steps4)