Benutzer-Werkzeuge

Webseiten-Werkzeuge


modellingcomponents:filter

Dies ist eine alte Version des Dokuments!


Filters

Filters are mathemematical operations running on a timeserie as a whole. They can be used as a preprocessing step, applied to the raw measurment data, at the end of the processing as a postprocessing step or „temporarily“ for visualisation in a plot sheet.

There is a default set of filters implemented. The available filters are explained in the following chapters.

Every filter can have attributes. Some attributes are used from most of the filters. For some of these attributes default values are defined:

stepWidth        =1/120
samplingFrequency="120"
windowWidth      ="12"
noisyData        ="true"
cutOffFrequency  ="5"
zeroPhase        ="true"
sectionMinLength ="10" 

The filter types and characteristics can be defined in the XML markerset/labelset files which define the which data is loaded for processing or which parts of the processed data should be written in an output file.

Further filters can be added by an plugin architecture.

in pre-/postprocessing

The filter-elements defining the filter charatericstics can be used at different positions in the hierarchie of a labelset:

<?xml version="1.0" encoding="UTF-8"?>
<LabelSet>
 <Filter name="butter2" implName="default" cutOffFrequency="20"
         windowWidth="" stepWidth="" noisyData="true" samplingFrequency="1211"
         zeroPhase="true" sectionMinLength="3"/>  
 <Labels fileSuffix="c3d" mimeType="application/c3d-vicon">
    <Filter name="butter2" implName="default" cutOffFrequency="20"
            windowWidth="" stepWidth="" noisyData="true" samplingFrequency="1211"
            zeroPhase="true" sectionMinLength="3"/>  
    <Label name="ABC" comment="" flag="" firstDerivative=""
           secondDerivative="" thirdDerivative="" differentiations=""
           optional="" unchangeable="" mathType="">
       <Filter name="butter2" implName="default" cutOffFrequency="20"
               windowWidth="" stepWidth="" noisyData="true" samplingFrequency="1211"
               zeroPhase="true" sectionMinLength="3"/>  
    </Label>
 </Labels>
</LabelSet>

Defined as the first child of the labelset-element it is applied to all timeseries, as a child of an label-element it is only applied to the timeserie the label corresponds to.

in the plot-sheet

The filter-elements defining the filter charatericstics, can be used also as children of the label-elements in a plot sheet definition.

<?xml version="1.0" encoding="iso-8859-1" ?>
<Sheet name="Bilateral shoulder abdcution">
  <Pages>
    <Page name="Mir 100"  rows="4" columns="3">
    ...
       <Diagram name="Height" 
           column="1"
           row="1"
           xunit="%"
           yunit="mm"
           diagramDescriptionDown="down"
           diagramDescriptionUp="up"
           plane="" 
           diagramType="xt" 
           diagramTitle="Height">
 
           <Label name="Height"
              label="Height">
              <Filter name="dft" implName="default"/>
           </Label>
       </Diagram>  

Comments

  • Till now, only in xt()- and xy()-plots timeseries are filterd.

Available Filter implementations

Poly4Diff

General

A differentiation method, that simultaneously smoothes the data by application of a 4-th order interpolation polynom (5 points). Minimum trial length is four.

Attributes

Attribute Default Description Required
stepWidth 1/120 [s] The time distance between succeeding frames in the unit seconds. No
samplingFrequency 120 [Hz] The sampling frequency in the unit Hz as an alternative parameter to stepWidth. No

References

  • Hildebrand, F.B. (1974). Introduction to Numerical Analysis, 2nd Edition, pp.111
  • Kreyszig, Erwin (1983). Advanced Engineering Mathematics, 5th Edition, pp.793
  • Yakowitz Sydney and Szidarovsky, Ferenc (1989). An Introduction to Numerical Computations, 2nd Edition, pp.18

SmoothDiff

A differentiation method that simultaneously smoothes the data. This method is based on a sliding window technique. The data is approximated within the window with a quadratic polynomial. The coefficients of the quadratic polynomial were then used for calculating the derivative at the window's center (Rand and Stelmach, 2005).

Attributes

Attribute Default Description Required
samplingFrequency 120 [Hz] Scaling coeffiecient (In our case : sampling frequency) No
windowWidth 5 Number of points in sliding window No
noisyData false Ways to treat ends - false ⇒ Not so good for noisy waveforms, but good (best) for smooth ones. true ⇒ For noisy waveforms is better than 1; Flattens ends for smooth ones. No

References

  • The original C++ implementation is from Dr. Yuri Shimansky.
  • Thanks for Laetitia Fradet for the idea to use this filter and to have a look in a Matlab implementation of this filter.

Chunk Mean (chunkmean)

Calculate the mean of a chunk of a timeserie.

The timeserie length must be a multiple of the windows size. The phase of the result is shifted by (window size) /2 frames to the front. The result timeserie length = (original timeserie length)/(window size). This reduction of the timeserie length makes this filter useless in most of the cases.

Attribute Default Description Required
windowWidth 12 Width of the window in which the mean is determined. No

WeightedAverage

Simple Low pass digital filter.

result[i] = (data[i-2] + 3d*data[i-1] + 4d*data[i] + 3d*data[i+1] + data[i+2])/12d

Butterworth and differentiating filter (butterDiff)

This filter determines the derivative based on a 4-th order interpolation polynom.

Attribute Default Description Required
stepWidth 1/120 [s] No
samplingFrequency 120 [Hz] No
cutOffFrequency 5 [Hz] No
zeroPhase true If set to false, only foward direction filterering is done resulting in phase shifting. No
windowWidth 5 No

References

Hildebrand, F.B. (1974). Introduction to Numerical Analysis, 2nd Edition, pp.111 Kreyszig, Erwin (1983). Advanced Engineering Mathematics, 5th Edition, pp.793 Yakowitz, Sydney and Szidarovsky, Ferenc (1989). An Introduction to Numerical Computations, 2nd Edition, pp.18

Butterworth second order (butterOrder2)

Zero-phase forward and reverse butterworth filter of 2. order.

Attributre Default Description Required
samplingFrequency 120 [Hz] No
cutOffFrequency 5 [Hz] No
windowWidth 5 No
sectionMinLength 10 Segments minimal count of frames. If the data contains segments with less frames a warning is given and the data of that segment is not filtered. No
zeroPhase false No

Discrete Fourier Transformation (dft/dft_bin)

Computes 1D Discrete Fourier Transform (DFT). Each DFT output value S[k] is represents the amplitude at frequency 2πkN. The multiplication by the exponential function effectively shifts s[n] down in frequency by 2πkN. The sum over N time samples can then be thought of as applying a decimating lowpass filter. So, effectively, the N outputs of the DFT represent the results of applying a bank of equally-spaced filters across s[n]'s frequency band, thus measuring „how much“ energy is present in various frequency bands in the input signal.

Assuming that a large-enough sample rate was used during the conversion to discrete-time, the result of the DFT will look a lot like the Fourier transform of the original signal s(t).The DFT is only applicable to finite-length signals, so in order to apply it, one must truncate the discrete-time signal s[n] to some finite length N, resulting in a potentially-shorter signal sN[n].

The result array contains the power specturm based on the dft() without the leading DC component for k=0:

spectrum[k]=Math.sqrt(Math.pow(data[k*2],2.0)+Math.pow(data[k*2+1],2.0));

The center frequencies for the bins are available, if the needed attributes are set:

Attribute Default Description Required
samplingFrequency Sample rate in [Hz], needed to calculate the center frequencies for the bins. No
useBinValues false If set to „true“ than a timeserie with the bin values are determined. This needs to set the samplingFrequency attribute too No

Comments

  • The result array with the power spectrum has half size as the input array. Thatś why this filter can not be used in the input- or output-labelsets. It is assumed, that this filter is usefull only in the plotsheet functionality. If there are new applications which needs this filter to be defined in input- or output-labelset the needed resampling code can be added easy.

GCVSPL (Woltring filter)

Natural B-spline data smoothing, using the Generalized Cross-Validation and Mean-Squared Prediction Error Criteria of Craven & Wahba (1979).

Attribute Default Description Required
order cubic linear, cubic, quintic, heptic No
derivative 0 0= no derivative, 1=first derivative, 2=second derivative, … No
cutoffFrequency auto cut off frequency in [Hz] or „auto“ for automatic determination No
errorVariance GCV With the default value „GCV“ the degree of smoothing to minimize the generalized cross validation function is determined. This is asymptotically the same as minimizing the true mean squared error (Craven & Wahba, 1979) or set error variance explicit as double value >= 0 No
interpolateGaps true If set to true, then gaps will be interpolated No

The following parameters are determined and can be printed in the log-file:

CutOffFrequency, if it is autodetected GeneralizedCrossValidationValue (WK(1) ) MeanSquaredResidual (WK(2) ) ResidualSumSquaresDimension (WK(3)) = Estimate of the number of degrees of freedom of the residual sum of squares per dataset, with 0.lt.WK(3).lt.N-M. SmoothingParameter (WK(4)) = Smoothing parameter p, multiplicative with the splines' derivative constraint. TrueMeanSquareError (WK(5) ) = Estimate of the true mean squared error (different formula for |MD| = 3). GaussMarkovErrorVariance (WK(6))

MEMO: GCVSPL software package (C) COPYRIGHT 1985, 1986: H.J. Woltring

For large datasets (N » 0) and negligible boundary artefacts, the behaviour of a natural spline approximates that of a periodic spline. For the latter case, the frequency characteristic in the equidistantly sampled, uniformly weighted case is that of a double, phase-symmetric Butterworth filter, with transfer function H(w) = [1 + (w/wo)^2M]^-1, where w is the frequency, wo = (p*T)^(-0.5/M) the filter's cut-off frequency, p the smoothing parameter, T the sampling interval, and 2M the order of the spline. If T is expressed in seconds, the frequen- cies are expressed in radians/second.

It has been found empirically, that the effective number of estimated spline parameters Np is related to the Butterworth cut-off frequency wo as Np ~ M/2 + KM * wo * N * T, where Np ranges between M and N, and where KM is the integral over x from 0 to infinity of (1 + x^2M)^- divided by PI. For large M, KM approaches 1/PI from above; values for small M are: K1 = 1/2, K2 = 1/V8, K3 = 1/3. This relation has also been found to apply for uniformly weighted data which are sampled slightly anequidistantly, with T taken as the average sampling inter-val. For large Np, the relation with wo * N * T becomes nonlinear.

zero2nan

moverms

defaultemg

bandpass

rectification

removeoffset

Adding filters via external "Math-Engines" like Matlab

modellingcomponents/filter.1514392794.txt.gz · Zuletzt geändert: 2017/12/27 17:39 von oliver

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki