verisense_count_steps: Count Steps According to Gu et al, 2017 Method

View source: R/verisense_count_steps.R

verisense_count_stepsR Documentation

Count Steps According to Gu et al, 2017 Method

Description

This method is based off finding peaks in the summed and squared acceleration signal and then using multiple thresholds to determine if each peak is a step or an artifact. An additional magnitude threshold was added to the algorithm to prevent false positives in free living data.

Usage

verisense_count_steps(
  data,
  sample_rate,
  k = 3,
  periodicity_range = c(5, 15),
  similarity_threshold = -0.5,
  continuity_window_size = 4,
  continuity_threshold = 4,
  variance_threshold = 0.001,
  vm_threshold = 1.2,
  peak_finder = c("fast", "original"),
  verbose = TRUE,
  global_vm_threshold = 0.025
)

verisense_count_steps_revised(
  ...,
  k = 4,
  periodicity_range = c(4, 20),
  similarity_threshold = -1,
  continuity_window_size = 4,
  continuity_threshold = 4,
  variance_threshold = 0.01,
  vm_threshold = 1.25
)

Arguments

data

A data.frame with a column for time in POSIXct (usually HEADER_TIMESTAMP, not required), and X, Y, Z

sample_rate

sampling frequency of the input data

k

window size for controlling peak finding.

periodicity_range

a length-2 vector of the range of periodicity. These are integers that represent samples not seconds.

similarity_threshold

threshold (in g) for similarity between magnitude of peaks

continuity_window_size

Window size for continuity

continuity_threshold

Threshold for continuity

variance_threshold

Variance threshold for the signal

vm_threshold

vector magnitude threshold for a peak to be called a peak

peak_finder

function to find peaks, either the "original" from the code, or the optimized "fast" version.

verbose

print diagnostic messages

global_vm_threshold

Global acceleration VM threshold (in standard deviation) for the total vector. If sd(acc) < thresh no steps are estimated. Set to 0 to run estimation regardless.

...

not used, used to passes arguments from verisense_count_steps_revised to verisense_count_steps

Value

A vector of length round(nrow(input_data) / sample_rate) of the estimated steps, where the data is rounded to seconds

Note

the ⁠_revised⁠ version is the same algorithm with different defaults for the parameters as based on doi:10.3390/s22249984.

Author(s)

Matthew R Patterson mpatterson@shimmersensing.com, MIT license, Copyright (c) 2020 Shimmer

Examples

csv_file = system.file("test_data_bout.csv", package = "walking")
if (requireNamespace("readr", quietly = TRUE)) {
  x = readr::read_csv(csv_file)
  colnames(x)[colnames(x) == "UTC time"] = "time"
  out = verisense_count_steps(x, sample_rate = 10L)
}
input_data <- matrix(runif(500 * 3, min = -1.5, max = 1.5), ncol = 3)
verisense_count_steps(input_data, sample_rate = 15L)
verisense_count_steps(input_data, sample_rate = 15L, peak_finder = "fast")
acc = sqrt(rowSums(input_data^2))
verisense_count_steps(acc, sample_rate = 15L, peak_finder = "fast")

walking documentation built on Aug. 4, 2026, 1:07 a.m.