Identifies when muscle activation begins and ends. The Hodges-Bui method
rectifies the signal, smooths it with a centered moving average
(smooth_ms, as in the original method's low-pass conditioning), and
thresholds the smoothed trace at a multiple of baseline standard
deviations. The Teager-Kaiser method applies the Teager-Kaiser energy
operator, then the same rectify-and-smooth conditioning, before
thresholding. Without smoothing (smooth_ms = 0) the rectified
band-limited signal dips below threshold at every carrier zero-crossing, so
contiguous suprathreshold runs rarely reach min_duration_ms and
genuine bursts go undetected. The Bonato method uses a statistical
double-threshold on the (optionally whitened) signal, declaring activation
when at least r of m successive samples exceed a chi-square
threshold set from a target false-alarm probability. The AGLR method applies
Staude & Wolf's approximated generalized-likelihood-ratio change detector for
a variance increase and refines the onset to the estimated change point.
Usage
emgOnsetDetect(
x,
method = c("hodges_bui", "teager_kaiser", "bonato", "aglr"),
threshold_sd = 3,
baseline_sec = 0.2,
min_duration_ms = 50,
smooth_ms = 25,
r = 5L,
m = 10L,
whiten = TRUE,
false_alarm = 0.05,
assay_name = NULL
)Arguments
- x
A PhysioExperiment object with EMG data.
- method
Detection method: "hodges_bui" (baseline SD threshold), "teager_kaiser" (Teager-Kaiser energy operator), "bonato" (Bonato double-threshold) or "aglr" (approximated generalized likelihood ratio).
- threshold_sd
Number of baseline SDs above mean for the threshold in the "hodges_bui" and "teager_kaiser" methods (default: 3).
- baseline_sec
Duration of the baseline period in seconds from the signal start, used to estimate baseline statistics (default: 0.2).
- min_duration_ms
Minimum activation duration in ms to accept (default: 50).
- smooth_ms
Width in ms of the centered moving-average window applied to the rectified signal ("hodges_bui") or rectified Teager-Kaiser trace ("teager_kaiser") before baseline estimation and thresholding (default: 25, in the 10–50 ms range examined by Hodges & Bui 1996). Set to 0 to disable smoothing (pre-0.2.1 behavior). Ignored by the "bonato" and "aglr" methods, which operate on unsmoothed samples by design.
- r, m
Bonato double-threshold parameters: activation requires at least
rofmsuccessive samples above the detection threshold (defaults: 5 of 10). For "aglr",mis the sliding analysis-window length in samples.- whiten
If TRUE (default), whiten the signal with an AR model estimated from the baseline before applying the "bonato"/"aglr" statistics, so the baseline approximates white Gaussian noise.
- false_alarm
Target false-alarm probability that sets the detection threshold for the "bonato" (per m-sample window) and "aglr" (per sample) methods (default: 0.05).
- assay_name
Input assay name (default: first assay).
Value
A list with two data.frames:
- onsets
A data.frame with columns
channel(integer channel index),sample(sample index of onset), andtime_sec(onset time in seconds). For "bonato"/"aglr" astatcolumn holds the peak detector statistic of the activation.- offsets
A data.frame with the matching
channel,sample,time_sec(andstat) for each offset.
If no activations are detected, both data.frames have zero rows.
References
Hodges, P.W. & Bui, B.H. (1996). "A comparison of computer-based methods for the determination of onset of muscle contraction using electromyography." Electroencephalography and Clinical Neurophysiology, 101(6), 511-519. doi:10.1016/S0921-884X(96)95190-5
Bonato, P., D'Alessio, T. & Knaflitz, M. (1998). "A statistical method for the measurement of muscle activation intervals from surface myoelectric signal during gait." IEEE Transactions on Biomedical Engineering, 45(3), 287-299. doi:10.1109/10.661154
Staude, G. & Wolf, W. (1999). "Objective motor response onset detection in surface myoelectric signals." Medical Engineering & Physics, 21(6-7), 449-467. doi:10.1016/S1350-4533(99)00067-3
Solnik, S., Rider, P., Steinweg, K., DeVita, P. & Hortobagyi, T. (2010). "Teager-Kaiser energy operator signal conditioning improves EMG onset detection." European Journal of Applied Physiology, 110(3), 489-498. doi:10.1007/s00421-010-1521-8
See also
emgEnvelope() for computing amplitude envelopes,
emgAmplitudeNormalize() for amplitude normalization,
emgFatigue() for fatigue analysis
Examples
pe <- make_emg_contraction()
emgOnsetDetect(pe, method = "bonato")$onsets
#> channel sample time_sec stat
#> 1 1 1495 1.494 51757.47