ECG Database Applications Guide Table of Contents


mfilt - general-purpose median filter for DB records


mfilt -l length [ options ... ]


mfilt can be used to apply a median filter of any desired length to any desired section of a database record. The length is expressed in samples (i.e., each output sample is the median of length input samples). Median filters can be much more effective than any type of linear filter for removing impulse noise from signals; they are not particularly useful for removing persistent noise, however. Generally, the shortest effective median filter is the one that should be used, to minimize the aliasing effects resulting from the non-linear characteristics of the filter.

Options are:

-f time
Filter from the specified time on the input record (default: start at the beginning of the record).
Print a usage summary.
-i record
Use the specified record for input (default: record 16).
-l n
Use an n-point median.
-n record
Write the output signals to record.dat, using the same specifications as the input signals, and create a header file for the specified record. This option overrides -o if both are used.
-o record
Use the specified record for output (default: record 16). If the output record header file specifies fewer signals than are present in the input, any extra input signals are discarded.
-t time
Filter until the specified time on the input record (default: go to the end of the record).

In the present implementation, the same filter is applied to each input signal. For each output sample, an array of length input samples centered on the time of interest is sorted. (More efficient algorithms for finding the median exist, especially for large odd values of length; see, for example, Numerical Recipes.) If length is odd, the output is the middle value from the sorted array and there is no phase shift; otherwise, the output is the average of the two middle values from the array and there is a phase shift of one-half of the sampling interval. If necessary, the output is padded at the end to obtain equal numbers of input and output samples.

The shell variable DB should be set and exported (see setdb(1) ).


A 3-point median filter, applied to the first 5 minutes of record 100 to produce a new record 100m:
   mfilt -l 3 -i 100 -n 100m




This program is included in version 8.1 and later versions of the DB Software Package.

Table of Contents