spectrace_find_invalid: Find invalid Specrtrace data

View source: R/spectrace_find_invalid.R

spectrace_find_invalidR Documentation

Find invalid Specrtrace data

Description

This function detects periods of invalid Spectrace data, that is, when the sensor was not worn (nonwear) or covered. Invalid periods are detected by finding clusters of consecutive values of low activity (nonwear) or illuminance (covered).

Usage

spectrace_find_invalid(
  lightData,
  flag_only = FALSE,
  nonwear_min_length = "10 mins",
  nonwear_max_interrupt = "2 mins",
  nonwear_smooth_window = "10 mins",
  covered_min_length = "10 mins",
  covered_max_interrupt = "2 mins",
  covered_threshold = 1
)

Arguments

lightData

Data frame containing the calibrated light data. The data needs to contain the activity column. If the data frame is grouped (see group_by), invalid periods are detected per group. It is highly recommended to group the data before passing it to this function, otherwise the data is considered as one continuous timeseries.

flag_only

Logical. Should only the logical flag for whether the data is invalid be returned as a column? If FALSE (default) the cluster index, and start and end index for each invalid cluster are returned as a column.

nonwear_min_length

String. Minimum length for consecutive low activity values to be considered as invalid. Must be in the format "[numeric] [unit]", with possible units ("seconds","minutes","hours","days"). Units can be abbreviated.

nonwear_max_interrupt

String. Maximum length of consecutive high activity values interrupting consecutive low activity values. Invalid periods can then contain interruptions of up to the specified length. Must be specified in the format "[numeric] [unit]", with possible units ("seconds","minutes", "hours","days"). Units can be abbreviated.

nonwear_smooth_window

String. Size of smoothing window for detecting low activity periods. Must be specified in the format "[numeric] [unit]", with possible units ("seconds","minutes","hours","days"). Units can be abbreviated.

covered_min_length

String. Minimum length for consecutive low illuminance values to be considered as invalid. Must be in the format "[numeric] [unit]", with possible units ("seconds","minutes","hours","days"). Units can be abbreviated.

covered_max_interrupt

String. Maximum length of consecutive high illuminance values interrupting consecutive low illuminance values. Invalid periods can then contain interruptions of up to the specified length. Must be specified in the format "[numeric] [unit]", with possible units ("seconds","minutes", "hours","days"). Units can be abbreviated.

covered_threshold

Numeric. Threshold illuminance to consider sensor as covered. Defaults to 1 lux.

Details

If the data frame is grouped (see group_by), invalid periods are detected per group. It is highly recommended to group the data before passing it to this function, otherwise the data is considered as one continuous timeseries.

Value

Original data frame with additional columns indicating whether a sample is covered or nonwear and if 'flag_only = FALSE' indicating the cluster indices, and indices of start and end of each invalid cluster.


steffenhartmeyer/spectrace documentation built on Dec. 4, 2024, 4:13 p.m.