# Measure the quality of an automatic on/off detection

### Description

These quantities measure different aspects of the accuracy in the determination of activity changes of an electric signal.

### Usage

1 2 3 4 5 |

### Arguments

`b` |
reference vector (target values) indicating for each position if the datum corresponds to a silence phase (0) or an active phase (1 or a greater integer indicating the level of activation). |

`bE` |
detected vector (output of an automatic detector) indicating for each position if the datum corresponds to a silence phase (0) or an active phase (1 or a greater integer indicating the level of activation). |

`t` |
tolerance value (see |

### Details

These quality measures are defined as

ANDP | The absolute difference of the number of detected phases and the actual number of pahses |

MNChPD | The mean of the distances of each detected change-point to the nearest actual change-point |

PCE | The percentage of incorrectly classified points (silence-activity) |

TD | temporal deviation |

PR | computes the true positive ratio (TPR) and the false positive ratio (FPR). |

`TD`

and `PR`

depends on the value of `t`

, which is a tolerance for the difference between the calculated and exact changepoints.

See Guerrero et.al. (2014) for details on the computation of these measures.

### Value

ANDP, MNChPD, PCE, TD: a numeric value. PR: a list of two numeric values (TPR and FPR).

### Note

The parameter `t`

should be adjusted in terms of the sampling rate of the EMG.

### Author(s)

J.E. Macias-Diaz, J.A. Guerrero jaguerrero@correo.uaa.mx

### References

Guerrero J.A., Macias-Diaz J.E. (2014) A computational method for the detection of activation/deactivation patterns in biological signals with three levels of electric intensity. *Math. Biosci.* **248**, 117–127.

Pistohl T., Schmidt T.S.B., Ball T., Schulze-Bonhage A., Aertsen A., Mehring C. (2013) Grasp detection from human ECoG during natural reach-to-grasp movements. *PLoS ONE* **8**

### See Also

`onoff_bonato`

, `onoff_singlethres`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ```
# 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")
# Detect the phases of activation in emgx
b_bonato <- onoff_bonato(emgx, sigma_n = 0.05, m = 10, minL = 30)
b_singlet <- onoff_singlethres(emgx, t = 0.2)
# Compute the quality measures
qm_bonato <- c(ANDP(b_bonato, emgx$on.off), MNChPD(b_bonato, emgx$on.off),
PCE(b_bonato, emgx$on.off), PR(b_bonato, emgx$on.off, t = 10), TD(b_bonato,
emgx$on.off, t = 10))
qm_singlet <- c(ANDP(b_singlet, emgx$on.off), MNChPD(b_singlet, emgx$on.off),
PCE(b_singlet, emgx$on.off), PR(b_singlet, emgx$on.off, t = 10), TD(b_singlet,
emgx$on.off, t = 10))
res <- as.matrix(cbind(qm_bonato, qm_singlet))
rownames(res) <- c("ANDP", "MNChPD", "PCE", "TPR", "FPR", "TD")
print(res)
``` |