R/RcppExports.R

Defines functions dev_parse_primary_accelerometerC legacy_parse_primary_accelerometerC dev_activity2_payload legacy_payload_parse_activity2_26C dev_payload_parse_sensor_data_25C legacy_payload_parse_sensor_data_25C imu_df check_id dev_parse_lux lux_payload interpolate_IMU interpolate_C interval_match zero2one dev_parse_IMU_C legacy_parse_IMU_C impute_C latch_packet blank_packet checksumC print_progC mid_round get_short next_separator latch_replicate get_latch_entries get_latch_values get_latch_index latch_accel get_headersC type3 get_VM_C dev1_bin_initialize dev_parse_activity activity_payload get_int12

Documented in activity_payload blank_packet check_id checksumC dev1_bin_initialize dev_activity2_payload dev_parse_activity dev_parse_IMU_C dev_parse_lux dev_parse_primary_accelerometerC dev_payload_parse_sensor_data_25C get_headersC get_int12 get_latch_entries get_latch_index get_latch_values get_short get_VM_C impute_C imu_df interpolate_C interpolate_IMU interval_match latch_accel latch_packet latch_replicate legacy_parse_IMU_C legacy_parse_primary_accelerometerC legacy_payload_parse_activity2_26C legacy_payload_parse_sensor_data_25C lux_payload mid_round next_separator print_progC zero2one

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Extract a 12-bit integer from two bytes
#'
#' @param x the bytes (RawVector) from which to extract the integer
#' @param i1 integer. The index of the first byte
#' @param i2 integer. The index of the second byte
#' @param full_first boolean. Use the full first byte and half of the second?
#'
#' @keywords internal
get_int12 <- function(x, i1, i2, full_first) {
    .Call('_AGread_get_int12', PACKAGE = 'AGread', x, i1, i2, full_first)
}

#' Parse the payload for an ACTIVITY packet
#' @keywords internal
activity_payload <- function(payload, samp_rate, scale_factor, is_last_packet) {
    .Call('_AGread_activity_payload', PACKAGE = 'AGread', payload, samp_rate, scale_factor, is_last_packet)
}

#' Parse a set of ACTIVITY packets
#'
#' @param packets list of packets
#' @param packet_no IntegerVector indicating which index of \code{packets} to
#'   use for each second of expected output. Values of -1 indicate a latch to
#'   the previous index
#' @param zero_packet list containing a properly-formatted packet pre-filled
#'   with values of zero (used for USB connection events)
#' @param samp_rate int. The sampling rate
#' @param scale_factor int. The scaling factor
#' @keywords internal
dev_parse_activity <- function(packets, packet_no, zero_packet, samp_rate, scale_factor) {
    .Call('_AGread_dev_parse_activity', PACKAGE = 'AGread', packets, packet_no, zero_packet, samp_rate, scale_factor)
}

#' @rdname parse_log_bin
#' @keywords internal
dev1_bin_initialize <- function(log, verbose, include) {
    .Call('_AGread_dev1_bin_initialize', PACKAGE = 'AGread', log, verbose, include)
}

#' @rdname get_VM
#' @param x NumericVector. X-axis values
#' @param y NumericVector. Y-axis values
#' @param z NumericVector. Z-axis values
#' @keywords internal
get_VM_C <- function(x, y, z) {
    .Call('_AGread_get_VM_C', PACKAGE = 'AGread', x, y, z)
}

#' @keywords internal
type3 <- function(log, verbose = FALSE) {
    .Call('_AGread_type3', PACKAGE = 'AGread', log, verbose)
}

#' Collect information about the packets stored in log.bin
#'
#' @param x RawVector. The contents of log.bin
#' @param verbose bool. Print updates to console?
#' @keywords internal
get_headersC <- function(x, verbose) {
    .Call('_AGread_get_headersC', PACKAGE = 'AGread', x, verbose)
}

#' @rdname impute_primary
#' @param vector_size int. The size of the final vector
#' @param accel_input NumericVector. The accelerometer values to reference for
#'   latching
#' @param samp_rate int. The sampling rate
#' @keywords internal
latch_accel <- function(vector_size, accel_input, samp_rate) {
    .Call('_AGread_latch_accel', PACKAGE = 'AGread', vector_size, accel_input, samp_rate)
}

#' @rdname impute_primary
#' @param missing_times vector of missing timestamps for which to identify a
#'   latch index
#' @param reference_times vector of reference timestamps for use in determining
#'   the latch index
#' @keywords internal
get_latch_index <- function(missing_times, reference_times) {
    .Call('_AGread_get_latch_index', PACKAGE = 'AGread', missing_times, reference_times)
}

#' @rdname impute_primary
#' @param indices IntegerVector containing latch indices
#' @param RAW DataFrame containing raw acceleration data
#' @keywords internal
get_latch_values <- function(indices, RAW) {
    .Call('_AGread_get_latch_values', PACKAGE = 'AGread', indices, RAW)
}

#' @rdname impute_primary
#' @param timestamps vector of timestamps on which to perform latching
#' @param accel_x vector of x-axis accelerations on which to perform latching
#' @param accel_y vector of y-axis accelerations on which to perform latching
#' @param accel_z vector of z-axis accelerations on which to perform latching
#' @param return_empty bool. Return an empty data frame?
#' @keywords internal
get_latch_entries <- function(samp_rate, timestamps, accel_x, accel_y, accel_z, return_empty = FALSE) {
    .Call('_AGread_get_latch_entries', PACKAGE = 'AGread', samp_rate, timestamps, accel_x, accel_y, accel_z, return_empty)
}

#' @rdname impute_primary
#' @keywords internal
latch_replicate <- function(start_time, stop_time, x_val, y_val, z_val) {
    .Call('_AGread_latch_replicate', PACKAGE = 'AGread', start_time, stop_time, x_val, y_val, z_val)
}

#' Find the next record separator
#'
#' @param log RawVector. The contents of log.bin
#' @param index int. The starting index from which to search for a record
#'   separator
#' @keywords internal
next_separator <- function(log, index) {
    .Call('_AGread_next_separator', PACKAGE = 'AGread', log, index)
}

#' Flexibly (big/little endian, signed/unsigned) convert two raw bytes to short
#'
#' @param x the bytes (RawVector) from which to extract the short
#' @param i1 integer. The index of the first byte
#' @param i2 integer. The index of the second byte
#' @param is_signed boolean. Return a signed value?
#'
#' @keywords internal
get_short <- function(x, i1, i2, is_signed) {
    .Call('_AGread_get_short', PACKAGE = 'AGread', x, i1, i2, is_signed)
}

#' Perform midpoint rounding the ActiGraph way
#'
#' This function is inefficient but necessary to ensure alignment between
#' \code{\link{read_gt3x}} and \code{\link{read_AG_raw}}
#'
#' @param input double. The number to round
#' @param digits int. The number of digits to round to
#'
#' @keywords internal
mid_round <- function(input, digits) {
    .Call('_AGread_mid_round', PACKAGE = 'AGread', input, digits)
}

#' Print progress updates while parsing packets in C++
#'
#' @param n percentage progress
#' @param label the packet type, as character
#'
#' @keywords internal
print_progC <- function(n, label) {
    invisible(.Call('_AGread_print_progC', PACKAGE = 'AGread', n, label))
}

#' Calculate checksum for a packet in C++
#'
#' @param log RawVector representing the contents of log.bin
#' @param start_index the packet start index
#' @param end_index the packet end index
#'
#' @keywords internal
checksumC <- function(log, start_index, end_index) {
    .Call('_AGread_checksumC', PACKAGE = 'AGread', log, start_index, end_index)
}

#' Handle empty and latched packets
#' @rdname special_packets
#' @param sample_rate int. the sampling rate
#' @param names CharacterVector. Names for the packet elements
#' @keywords internal
blank_packet <- function(sample_rate, names) {
    .Call('_AGread_blank_packet', PACKAGE = 'AGread', sample_rate, names)
}

#' @rdname special_packets
#' @param last_packet the previous packet
#' @keywords internal
latch_packet <- function(last_packet, sample_rate) {
    .Call('_AGread_latch_packet', PACKAGE = 'AGread', last_packet, sample_rate)
}

#' @rdname impute_primary
#' @param gaps DataFrame with gap information
#' @keywords internal
impute_C <- function(gaps, object) {
    .Call('_AGread_impute_C', PACKAGE = 'AGread', gaps, object)
}

#' Parse all IMU packets in a file
#'
#' @param imu_records DataFrame with information about each packet
#' @param log RawVector containing all payload bytes
#' @param info The \code{sensorColumns} information of a \code{SENSOR_SCHEMA}
#'   object
#' @param id integer. The \code{id} information of a \code{SENSOR_SCHEMA}
#'   object
#' @param samp_rate integer. The IMU sampling rate.
#' @param verbose logical. Print updates to console?
#' @keywords internal
legacy_parse_IMU_C <- function(imu_records, log, info, id, samp_rate, verbose) {
    .Call('_AGread_legacy_parse_IMU_C', PACKAGE = 'AGread', imu_records, log, info, id, samp_rate, verbose)
}

#' @rdname legacy_parse_IMU_C
#' @inheritParams dev_parse_primary_accelerometerC
dev_parse_IMU_C <- function(packets, packet_no, zero_packet, id, samp_rate, info) {
    .Call('_AGread_dev_parse_IMU_C', PACKAGE = 'AGread', packets, packet_no, zero_packet, id, samp_rate, info)
}

#' Interpolation-specific sequencer
#'
#' @param samples NumericVector. A data stream.
#' @keywords internal
zero2one <- function(samples) {
    .Call('_AGread_zero2one', PACKAGE = 'AGread', samples)
}

#' Match a resampled interval proportion to its corresponding
#' originally-sampled interval in C++.
#'
#' @param proportion double. The interval proportion to match.
#' @param reference_frame DataFrame containing a \code{prop_min} column to
#'   serve as originally-sampled interval proportions
#'
#' @keywords internal
interval_match <- function(proportion, references) {
    .Call('_AGread_interval_match', PACKAGE = 'AGread', proportion, references)
}

#' @rdname sensor_resample
#' @aliases Resample Interpolate
#' @keywords internal
interpolate_C <- function(original_samples, target_frequency) {
    .Call('_AGread_interpolate_C', PACKAGE = 'AGread', original_samples, target_frequency)
}

#' @rdname sensor_resample
#' @aliases Resample Interpolate
#' @keywords internal
interpolate_IMU <- function(original_samples, target_frequency) {
    .Call('_AGread_interpolate_IMU', PACKAGE = 'AGread', original_samples, target_frequency)
}

#' Parse the payload for a LUX packet
#' @param payload RawVector. The payload
#' @keywords internal
lux_payload <- function(payload) {
    .Call('_AGread_lux_payload', PACKAGE = 'AGread', payload)
}

#' Parse a set of LUX packets
#'
#' @param packets list of packets
#' @param packet_no IntegerVector indicating which index of \code{packets} to
#'   use for each second of expected output. Values of -1 indicate a latch to
#'   the previous index
#' @param zero_packet list containing a properly-formatted packet pre-filled
#'   with values of zero (used for USB connection events and possibly file starts)
#' @keywords internal
dev_parse_lux <- function(packets, packet_no, zero_packet) {
    .Call('_AGread_dev_parse_lux', PACKAGE = 'AGread', packets, packet_no, zero_packet)
}

#' Check sensor payload ID prior to parsing the packet
#'
#' @param x the raw payload
#' @param id integer. The \code{SENSOR_SCHEMA} id
#'
#' @keywords internal
check_id <- function(x, id) {
    invisible(.Call('_AGread_check_id', PACKAGE = 'AGread', x, id))
}

#' Convert parsed packet data from list to data frame
#'
#' @param input parsed packet data (as list)
#'
#' @keywords internal
imu_df <- function(input) {
    .Call('_AGread_imu_df', PACKAGE = 'AGread', input)
}

#' Parse SENSOR_DATA packet in c++
#'
#' @param payload raw vector of payload bytes
#' @param info \code{sensorColumns} information from a \code{SENSOR_SCHEMA}
#'   object
#' @param id integer. The \code{id} information from a \code{SENSOR_SCHEMA}
#'   object
#' @param samp_rate integer. The IMU sampling rate.
#' @param timestamp Datetime. The packet timestamp
#'
#' @keywords internal
legacy_payload_parse_sensor_data_25C <- function(payload, info, id, samp_rate, timestamp) {
    .Call('_AGread_legacy_payload_parse_sensor_data_25C', PACKAGE = 'AGread', payload, info, id, samp_rate, timestamp)
}

#' @rdname legacy_payload_parse_sensor_data_25C
#' @keywords internal
dev_payload_parse_sensor_data_25C <- function(payload, info, id, samp_rate) {
    .Call('_AGread_dev_payload_parse_sensor_data_25C', PACKAGE = 'AGread', payload, info, id, samp_rate)
}

#' Parse a packet of primary accelerometer data in C++
#'
#' @param payload RawVector containing the payload bytes
#' @param is_last_packet logical. Is this the last packet in the file?
#' @param samp_rate integer reflecting the sampling rate
#' @param scale_factor integer reflecting the scale factor
#' @param timestamp Datetime. The packet timestamp
#'
#' @keywords internal
legacy_payload_parse_activity2_26C <- function(payload, samp_rate, scale_factor, is_last_packet, timestamp) {
    .Call('_AGread_legacy_payload_parse_activity2_26C', PACKAGE = 'AGread', payload, samp_rate, scale_factor, is_last_packet, timestamp)
}

#' @rdname legacy_payload_parse_activity2_26C
#' @keywords internal
dev_activity2_payload <- function(payload, samp_rate, scale_factor, is_last_packet) {
    .Call('_AGread_dev_activity2_payload', PACKAGE = 'AGread', payload, samp_rate, scale_factor, is_last_packet)
}

#' Parse all primary accelerometer packets in a file
#'
#' @param primary_records DataFrame with information about each packet
#' @param log RawVector containing all payload bytes
#' @param samp_rate the sampling rate
#' @param scale_factor the accelerometer scale factor
#' @param verbose logical. Print updates to console?
#' @keywords internal
#' @rdname parse_primary_accelerometerC
legacy_parse_primary_accelerometerC <- function(primary_records, log, scale_factor, samp_rate, verbose) {
    .Call('_AGread_legacy_parse_primary_accelerometerC', PACKAGE = 'AGread', primary_records, log, scale_factor, samp_rate, verbose)
}

#' @rdname parse_primary_accelerometerC
#' @param packets list of packets
#' @param packet_no IntegerVector indicating which index of \code{packets} to
#'   use for each second of expected output. Values of -1 indicate a latch to
#'   the previous index
#' @param zero_packet list containing a properly-formatted packet pre-filled
#'   with values of zero (used for USB connection events)
#' @param latch_packets list of empty packets to be filled during latch periods
#' @keywords internal
dev_parse_primary_accelerometerC <- function(packets, packet_no, zero_packet, samp_rate, scale_factor) {
    .Call('_AGread_dev_parse_primary_accelerometerC', PACKAGE = 'AGread', packets, packet_no, zero_packet, samp_rate, scale_factor)
}

Try the AGread package in your browser

Any scripts or data that you put into this service are public.

AGread documentation built on Sept. 13, 2022, 5:06 p.m.