Processes multiple FIT files from a specified directory, utilizing caching to avoid reprocessing unchanged files. This function efficiently processes new or updated files in a directory, leveraging a cache to skip already processed files.

process_fit_directory(
  dir_path,
  cache_file = file.path(dir_path, "hrv_cache.csv"),
  standing_time = 180,
  transition_time = 20,
  laying_time = 180,
  min_rr = 272,
  max_rr = 2000,
  window_size = 7,
  threshold = 0.2,
  centered_transition = TRUE,
  centered_window = FALSE,
  warmup = 70,
  clear_cache = FALSE,
  sport_name = "OST",
  min_quality_threshold = 0,
  correction_method = "linear"
)

Arguments

dir_path

The directory path containing FIT files to process.

cache_file

Path to the cache file for storing processed data. Defaults to "hrv_cache.csv" within the directory.

standing_time

Time in seconds to consider as standing. Default is 180 seconds.

transition_time

Time in seconds to consider as transition. Default is 20 seconds.

laying_time

Time in seconds to consider as laying. Default is 180 seconds.

min_rr

Minimum RR interval in milliseconds. Default is 272 ms.

max_rr

Maximum RR interval in milliseconds. Default is 2000 ms.

window_size

Window size for moving average calculation. Default is 7.

threshold

Threshold for artifact detection. Default is 0.2.

centered_transition

Logical indicating whether to center transition phases. Default is TRUE.

centered_window

Logical indicating whether to use centered window for processing. Default is FALSE.

warmup

Warmup time in seconds to exclude from beginning. Default is 70.

clear_cache

Logical indicating whether to clear existing cache. Default is FALSE.

sport_name

Character string specifying the sport name filter. Default is "OST".

min_quality_threshold

Minimum quality threshold (0-1) for data to be processed. Data below this quality threshold will be discarded. Default is 0.0 (no filtering).

correction_method

Character string specifying the artifact correction method. Options are: "linear", "cubic", "lipponen", "none". Default is "linear".

Value

A tibble containing HRV metrics for all processed FIT files