Calculations


Template Matching Scripts

Several scripts included in EMGworks use the concept of templates for segmenting and identifying regions in data.  A template represents a unique, repeated shape of the signal recorded.

The template matching scripts accommodate automatically locating a template (by finding the most repeated shape in a signal), identifying matches in a signal of a predetermined template (with some tolerance for slight shape changes between matches), and discriminating between matches of two different templates in the same file (to segment data based on a template shape).

Some applications for template matching are:

-      Accelerometer data: identify repetitions of a particular repeated motion in a data file (for example, in gait data), or to differentiate between two types of motion recorded in the same data file.

-      Raw EMG data: identify muscle activation patterns of a specific shape.

-      RMS (Envelope) EMG data: identify the location of a specific, repeated envelope shape.  A greater number of points in the template will improve matching accuracy.

-      EKG data: identify EKG pulses, as used in the EKG rate script.

Templates are matched via a correlation calculation (see EMGScript Function ncc documentation for more information).  A peak in the correlation data represents the location in the input channel that corresponds to the start point of a matched template.  The peaks are noted, then clustered together, keeping the largest peaks and rejecting lesser peaks that are within one template width of the larger ones.  The chosen peaks are sorted and another filter applied, this time only peaks above the user specified percentile are chosen.  These are the peaks that are used to determine matched areas.

The output from a template matching script is generally a square wave, with high sections denoting a matched area (the same width as the provided template) and low sections denoting no matches.