# eaemg: Ensemble-averaged EMG In biosignalEMG: Tools for Electromyogram Signals (EMG) Analysis

## Description

Creates an ensemble-averaged EMG associated with a cyclical activity.

## Usage

 ```1 2 3 4 5 6 7 8 9``` ```eaemg(data, channel, runs, what, timenormalization = c("min", "mean", "median", "max"), scalem = 1, empirical = TRUE, level = 0.9) ## S3 method for class 'eaemg' plot(x, ci.lty ="dashed", ...) ## S3 method for class 'eaemg' print(x, ...) ## S3 method for class 'eaemg' summary(object, ...) ```

## Arguments

 `data` an ‘emg’ object, usually rectified, moving-average of a rectified EMG or the computed envelope of an EMG. `channel` in case of multi-channel data, `channel` is the specific channel to be considered by the procedure. Possible values: a character vector specifying the name of the channel to be considered (case sensitive) or a numeric value specifying the channel to be considered (number of column in `data`). `runs` an ‘rle’ object indicating the lengths of succesive phases (active and inactive) or an atomic vector indicating in each position if the signal corresponds to a silence phase (0) or an active phase (1 or a greater integer). `what` which phases are going to be ensemble-averaged, active phases (1) or silence phases (0). `timenormalization` a string that indicates with respect to which value all phase durations should be normalized. It can be the “min” (default), “mean”, “median” or “max” duration of the phases. `scalem` a value (>=1) that controls the local detail of the ensemble. `empirical` logical; if `TRUE` (default), the confidence intervals are computed based on the empirical quantiles; if `FALSE`, confidence intervals are computed asumming a Gaussian distribution. `level` a value in [0,1] indicating the confidence level. `x, object` an ‘eaemg’ object. `ci.lty` line type to plot the confidence intervals. `...` additional arguments to be passed to the generic function.

## Details

Ensemble-Averaged EMG is usually applied to EMG signals associated with cyclical activities. In Ensemble-Averaged EMG the time base for each cycle is normalized and all the profiles are averaged. To successfully obtain the average profile, the data should be a rectified EMG, the moving average of a rectified EMG or the envelope of an EMG signal.

The `runs` argument can be computed througth the `rle` function of a thresholded envelope (see Examples) or computed with an onset/offset detection algorithm (see `onoff_singlethres` and `onoff_bonato`).

## Value

returns an object of class ‘eaemg’ which is a list with components:

 `intervals` a matrix with three columns, each corresponding to the lower limit of the interval, the ensemble average and the upper limit of the interval. `empirical` the `empirical` argument `level` the `level` argument

## Author(s)

J.A. Guerrero [email protected]

## References

Kumar S., Mital A. (1996) Electromyography In Ergonomics Taylor & Francis.

Esquivel M.E., Guerrero J.A., Macias-Diaz J.E. (2010) Activity pattern detection in electroneurographic and electromyogram signals through a heteroscedastic change-point method. Mathematical Biosciences 224(2) 109–117

`rectification`, `movingaverage`, `envelope`, `onoff_singlethres`, `onoff_bonato`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23``` ```# change graphical parameters to show multiple plots op <- par(mfrow = c(2, 1)) # Simulate 10 seconds of an EMG emgx <- syntheticemg(n.length.out = 10000, on.sd = 1, on.duration.mean = 350, on.duration.sd = 10, off.sd = 0.05, off.duration.mean = 300, off.duration.sd = 20, on.mode.pos = 0.75, shape.factor = 0.5, samplingrate = 1000, units = "mV", data.name = "Synthetic EMG") # MA-envelope emgma <- envelope(emgx, method = "MA", wsize = 60) # Ensemble-averaged EMG ea1 <- eaemg(emgma, runs = rle(emgx\$on.off), what = 1, timenormalization = "max", scalem = 1, empirical = TRUE, level = 0.9) plot(ea1, lwd = 2, main = "Ensemble-averaged EMG using apriori onset/offset") # Determine the onset/offset runs using a thresholded envelope empiricalonoff <- onoff_singlethres(emgx, t = 0.05) ea2 <- eaemg(emgma, runs = empiricalonoff, what = 1, timenormalization = "max", scalem = 1, empirical = TRUE, level = 0.9) plot(ea2, lwd = 2, main = "Ensemble-averaged EMG using empirical onset/offset") # reset graphical parameters par(op) ```