FIR Filter

Forum for discussion on different signal processing algorithms
Locked
aloplop
Posts: 41
Joined: 03 Sep 2008, 07:20

FIR Filter

Post by aloplop » 25 Nov 2008, 12:46

Hi,

I have looked the code for the last FIRFilter.cpp version.

1º) There, it appears for the integrations:

Code: Select all

case mean:
        Output( channel, 0 ) = result.sum() / inputLength;
        break;

  case rms:
        result *= result;
        Output( channel, 0 ) = ::sqrt( result.sum() ) / inputLength;
        break;
also inputLength = Input.Elements();

I agree with the mean, but looking in the wikipedia for the root mean square: http://en.wikipedia.org/wiki/Root_mean_square
it seems that the definition don´t fit with the one in the code, because the square root should include the inputLength paremeter.

I don´t know if I am wrong, maybe it´s just another way to obtain the rms value.


2º) Does inputLength = Input.Elements() correspond to the parameter SampleBlockSize ??

In that case the first Samples of the EEG in the buffer are just considered to perform the convolution...



Thanks.

mellinger
Posts: 1208
Joined: 12 Feb 2003, 11:06

Post by mellinger » 26 Nov 2008, 11:45

ad 1)
Thanks, fixed.

ad 2)
Buffer length is chosen to be filterLength+inputLength-1. Thus, when convolving from the beginning of the buffer, the most recent input sample will enter into the last output sample.

Input.Elements() will only match SampleBlockSize if there is no prior filter in the chain that reduces the number of samples (elements) in its output (typically, this is not the case).
Last edited by mellinger on 26 Nov 2008, 12:17, edited 1 time in total.

aloplop
Posts: 41
Joined: 03 Sep 2008, 07:20

Post by aloplop » 26 Nov 2008, 12:02

Hi again,

thanks Jürgen for your quick response.

I still have doubts about how can we now what is the number of samples of the EEG signal which are used for the convolution (i.e. the inputLength parameter).

Code: Select all

for( int sample = 0; sample < inputLength; ++sample )
      result[sample] = inner_product( &mFilter[channel][0], &mFilter[channel][filterLength-1], &mBuffer[channel][sample], 0 );
If there is only the SpatialFilter before the FIR Filter I assume that the number of samples at the input of the FIR is the same as the SampleBlockSize. Am I wrong??

Thanks again.

mellinger
Posts: 1208
Joined: 12 Feb 2003, 11:06

Post by mellinger » 26 Nov 2008, 12:33

The input signal is continuously convolved with the FIR coefficients, i.e. for each input sample, the scalar product of the coefficient vector is computed with an appropriate number of past samples up to, and including, the current input sample. Then, the computed scalar product is the output sample corresponding to the current input sample.
(http://www.dinkumware.com/manuals/?manu ... er_product might help in verifying the code.)

Yes, the FIRFilter's input length matches SampleBlockSize when there is only the SpatialFilter present before it.

Locked

Who is online

Users browsing this forum: No registered users and 2 guests