| Title: | Automated Cardiac Data Processing via ACF, GA & Tracking Index |
|---|---|
| Description: | An algorithm developed to efficiently and accurately process complex and variable cardiac data with three key features: 1. employing autocorrelation to identify recurrent heartbeats and use their periods to compute heart rates; 2. incorporating a genetic algorithm framework to minimize data loss due to noise interference and accommodate within-sequence variations; and 3. introducing a tracking index as a moving reference to reduce errors. Lau, Wong, & Gu (2026) <https://ssrn.com/abstract=5153081>. |
| Authors: | Sarah Lau [aut, ctb] (ORCID: <https://orcid.org/0000-0003-1742-0821>), Adrian Wong [aut, ctb], Yi-Fei Gu [aut, cre] (ORCID: <https://orcid.org/0000-0003-1741-638X>) |
| Maintainer: | Yi-Fei Gu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.3 |
| Built: | 2026-06-06 05:56:04 UTC |
| Source: | https://github.com/vicellken/cardiacdp |
Automatically read and collate separate .csv files in chronological order as inferred by the file names and in hierarchy.
collatedata(file_path, output_file = NULL, verbose = FALSE)collatedata(file_path, output_file = NULL, verbose = FALSE)
file_path |
Designate the path to your file, must be a .zip file |
output_file |
Optional path to write the collated data table as a CSV file. May be either a full file path
(e.g. |
verbose |
Logical; if TRUE, emit progress messages. Default FALSE. |
A single collated data table
zip_path <- system.file("extdata", "example.zip", package = "CardiacDP") collated <- collatedata(zip_path)zip_path <- system.file("extdata", "example.zip", package = "CardiacDP") collated <- collatedata(zip_path)
Employing the autocorrelation function (ACF) with a genetic algorithm framework to locate periodic sub-sequences within each sequence. From the candidate heart rates of these sub-sequences, the final results are either evaluated based on the autocorrelation value or a tracking index (TI).
computeHR( file_path, reduce_res = 0.01, pop_size = 10L, max_gen = 20L, patience = 2L, an_in = 1, acf_thres = 0.5, lr_thres = 0.7, ncore = NULL, output_dir = NULL, save_outputs = FALSE, verbose = FALSE )computeHR( file_path, reduce_res = 0.01, pop_size = 10L, max_gen = 20L, patience = 2L, an_in = 1, acf_thres = 0.5, lr_thres = 0.7, ncore = NULL, output_dir = NULL, save_outputs = FALSE, verbose = FALSE )
file_path |
Designate the path to your file, must be a .zip or .csv file |
reduce_res |
Time interval of reduced resolution (seconds), by default 0.01 |
pop_size |
Number of populations used in the genetic algorithm, by default 10L |
max_gen |
Maximum number of generations in the genetic algorithm, by default 20L |
patience |
Patience threshold (maximum number of generations with no further changes) in the genetic algorithm, by default 2L |
an_in |
Analysis interval (length of a sequence; in minute), by default 1 |
acf_thres |
Threshold used in ACF to classify periodic oscillations from aperiodic noises, by default 0.5 |
lr_thres |
Linear regression r-sq threshold in extrapolating the tracking index, by default 0.7 |
ncore |
Integer; number of CPU cores to use for the genetic algorithm. If NULL (default), uses |
output_dir |
Optional directory to write CSV/PNG outputs when |
save_outputs |
Logical; if TRUE, write CSV/PNG outputs to |
verbose |
Logical; if TRUE, emit progress messages. Default FALSE. |
The positions (in indices) and durations of the sub-sequences (finalsubseq) and the corresponding candidate HR (candidateHR) obtained from the genetic algorithm, and the final results evaluating the candidates by autocorrelation values (results_ACF) or the tracking index (results_TI), which contains the details of the subsequences after checking for resolution (subseqHR with Time_min column), the weighted heart rate per sequence (weightedHR with Time_min column) and a plot (plot). If save_outputs = TRUE, file paths are recorded in output$files.
# use the default parameters to analyse a zip file # the collatedata function will be called automatically zip_path <- system.file("extdata", "example.zip", package = "CardiacDP") computeHR(file_path = zip_path, save_outputs = FALSE) # use the default parameters to analyse a csv file csv_path <- system.file("extdata", "example.csv", package = "CardiacDP") computeHR(file_path = csv_path, reduce_res = 0.1, save_outputs = FALSE) # use customized parameters to analyse a zip file zip_path <- system.file("extdata", "example.zip", package = "CardiacDP") computeHR(zip_path, reduce_res = 0.1, max_gen = 30L, lr_thres = 0.8, save_outputs = FALSE) # use custom parameters to analyse a csv file csv_path <- system.file("extdata", "example.csv", package = "CardiacDP") computeHR(csv_path, reduce_res = 0.1, pop_size = 20L, an_in = 1, acf_thres = 0.6, save_outputs = FALSE)# use the default parameters to analyse a zip file # the collatedata function will be called automatically zip_path <- system.file("extdata", "example.zip", package = "CardiacDP") computeHR(file_path = zip_path, save_outputs = FALSE) # use the default parameters to analyse a csv file csv_path <- system.file("extdata", "example.csv", package = "CardiacDP") computeHR(file_path = csv_path, reduce_res = 0.1, save_outputs = FALSE) # use customized parameters to analyse a zip file zip_path <- system.file("extdata", "example.zip", package = "CardiacDP") computeHR(zip_path, reduce_res = 0.1, max_gen = 30L, lr_thres = 0.8, save_outputs = FALSE) # use custom parameters to analyse a csv file csv_path <- system.file("extdata", "example.csv", package = "CardiacDP") computeHR(csv_path, reduce_res = 0.1, pop_size = 20L, an_in = 1, acf_thres = 0.6, save_outputs = FALSE)