Compute Instantaneous Heart Rate from R-Peak Indices
Source:R/compute_hr_signal.R
compute_hr_signal.RdConverts R-peak sample indices (from detect_qrs()) into a
sample-by-sample instantaneous heart rate trace by filling each inter-beat
interval with the constant HR derived from that interval's length.
Arguments
- qrs
A
mrpheus_qrsobject fromdetect_qrs(), or a named list with at leastqrs_i(integer vector of R-peak indices) andfs(sampling frequency in Hz).
Value
Numeric vector of length max(qrs$qrs_i). Each sample contains
the instantaneous heart rate in beats per minute for the inter-beat
interval it falls within. Samples before the first detected R-peak are 0.
Examples
if (FALSE) { # \dontrun{
rec <- read_philips_physlog("sub-01_physlog.log")
qrs <- detect_qrs(rec$C[, "v1raw"], fs = rec$HDR$sfreq)
hr <- compute_hr_signal(qrs)
plot(seq_along(hr) / rec$HDR$sfreq, hr, type = "l",
xlab = "Time (s)", ylab = "HR (bpm)")
} # }