Skip to contents

Segments a PCG Shannon-energy envelope into S1 (systolic) and S2 (diastolic) heart-sound events: threshold, find above-threshold runs, merge close peaks, label alternating events.

Usage

pcgseg(envelope, fs = 2000, min_gap_ms = 100)

Arguments

envelope

Numeric vector (Shannon-energy envelope).

fs

Sampling frequency in Hz (default 2000).

min_gap_ms

Minimum gap between peaks in ms (default 100).

Value

List with value (cycle count), name, and extra (s1_indices, s2_indices, n_cycles, n_peaks).

Details

Reference: Liang, Lukkarinen & Hartimo (1997), Comput. Cardiol., pp. 105–108.

Examples

# \donttest{
set.seed(1)
env <- abs(sin(seq(0, 20, length.out = 4000))) + 0.05 * rnorm(4000)
env[env < 0] <- 0
res <- pcgseg(env, fs = 2000)
res$extra$n_cycles
#> [1] 6
# }