IIR or FIR filter, order / ERP polarity ?

wjcroftwjcroft Mount Shasta, CA
edited December 2018 in Software
This discussion was created from comments split from: large millivolt data values / FbEEG Full Band EEG.

Comments

  • Hi,

    I have a problem with a bandpass filter.
    I use a FIR filter with numtaps = 101 and cutoff frequencies 2.0 to 35Hz.
    The reason of 35Hz is to eliminate 50Hz power supply noise, and 2.0Hz is to eliminate the DC offset and slow DC drift.
    I can eliminate 50Hz now, but cannot eliminate the DC offset and slow DC drift, because the numtaps = 101 is not enough.
    I can increase it to 511 or so, but it makes the delay larger(about 1sec delay).
    Since I'm going to create real-time neurofeedback protocol, I should make the delay as little as possible.

    I tried to apply an IIR filter, then now I can eliminate the DC offset, but 50Hz noise remains...

    I'm not familiar with the signal processing, are there any good reference or sample implementation?
    And I should know the delay of IIR filter.

    I'm using python and referred some websites:

  • I wonder that the polarity ( plus and minus ) might be opposite.
    Does the cyton board's plus mean the conventional EEG's plus?
  • wjcroftwjcroft Mount Shasta, CA
    @Hiroki, hi.

    Almost all neurofeedback uses simple IIR filters, typically Butterworth with say 3, 4, or 5th order. The delay is reasonable, only a couple hundred milliseconds.

    There are many DSP tutorials on the web, some geared to Python scipy, etc.

    The reason you were seeing huge delays was your FIR filter with 100+ taps. That is just not something that is generally done.

    All Butterworth bandpass filters will have different "rolloff" bandpass skirts, depending on the order of the filter. Higher order gives you sharper edges on the bandpass. Another strategy you can use is just two successive filters, a highpass at say .5 hz, then a notch at 50 hz. In that case you do not need a bandpass filter.


    Regards,

    William

  • Hi,

    Several months ago, I posted about the polarity of openBCI.
    I wonder that the polarity might be upside down.

    When we hear sounds, the auditory evoked potentials are elicited.

    I calculated the auditory evoked potentials using openBCI.

    I presented 1,200 times of sinusoidal pure tones to a subject, and recorded the EEG ( with Cyton ).
    The EEG was band-pass filtered ( 2.0-35.0Hz ) and epochs which contain eye-blinks are omitted.

    Comparing the ERP I measured with the literatures, the polarity seems to be upside down.

    Do you have any good references?
    with best regards,
  • wjcroftwjcroft Mount Shasta, CA
    Do you understand the way the SRB2 bus works? It connects in common all the IN1P, IN2P, IN3P, etc. pins as the reference. Then all the IN1N, IN2N, IN3N pins are your channels. So yes, P is positive, N is negative, of the differential amplifier. It's not "upside down".

  • I connected each electrode to ... N1N, N2N???
    I took a picture -> http://bit.ly/2Bu0zej
    Is this correct?
    I referred to http://docs.openbci.com/Headware/01-Ultracortex-Mark-IV to connect electrodes.

    I'm not sure what is SRB2.
  • Ooops

    I might mistake to connect the right ear clip to the wrong pin.
    I think this is wrong ( the most right electrode )?.
  • I moved the electrode of the right ear clip from AGND to BIAS.

    I measured the auditory evoked potential again, but the waveform is similar to the previous one.

    I'm struggling with this problem...
  • wjcroftwjcroft Mount Shasta, CA
    There is nothing wrong with your waveform, you just need to invert it. The 'bottom' or 'closest to board' row of pins are the IN*N pins. The bottom SRB is SRB2. 'Top' row of pins are IN*P pins. Top SRB is SRB1. See TI data sheet if you want more specifics. You should never use AGND as 'Ground', that is the function of Bias.

    http://www.ti.com/lit/ds/symlink/ads1299.pdf

    Please re-read what I said on the last post. Your waveform is explained by the fact that SRB2 is a bus for the positive pins / electrodes. And IN*N pins are negative pins.
  • Thank you so much for the explanation.
    But I'm not familiar with electrical engineering,  I couldn't read the circuit.

    Let me confirm the function of ADS1299.
    I read 9.3.1.2 Analog Input and 10.2.2 Detailed Design Procedure of the data sheet.

    ADS1299 is the fully differential amplifier.
    There are two montages; one is a sequential montage and another is a referential montage.
    When I want to use the sequential montage, I should use SRB2(bottom).
    When I want to use the referential montage, I should use SRB1(top).

    In the sequential montage, I should connect the left ear clip to SRB2, and the right ear clip to BIAS2.
    In this montage, each channel represents the voltage difference between IN*P and IN*N ( IN1P-IN1N, IN2P-IN2N, ... )( Figure 72 ).

    In the referential montage, I should connect the left ear clip to SRB1, and the right ear clip to BIAS1.
    In this montage, I should connect the electrode to IN*P only( Figure 73 ).

    The above is my understanding. Please point out if I misunderstood.

    Then, what I want to do is to measure the voltage of one electrode ( in this case, Fz ).

    The below is what I tried. Tell me what is the best way.

    Firstly, I tried to the referential montage. I connected
    - the left ear clip to SRB1,
    - the right ear clip to BIAS1, and
    - Fz to IN1P.
    But the voltage of Fz was displayed as RAILED when I used OpenBCI_GUI.

    Secondly, I tried to the sequential montage while I wanted to the voltage not inverted, I connected
    - the left ear clip to SRB2,
    - the right ear clip to BIAS2, and
    - Fz to IN1P.
    Again, the voltage of Fz was displayed as RAILED.

    Thirdly, I added the P7 electrode and connected it to IN1N.
    - the left ear clip to SRB2,
    - the right ear clip to BIAS2,
    - Fz to IN1P, and
    - P7 to IN1N.
    Then, the voltage of Fz is displayed as expected, and I think the measured voltage is Fz - P7.

    The third configuration might work for me, but I have several questions.
    - Why the first configuration does not work?
    - Why the second configuration does not work?
    - If the second configuration doesn't work, why it works when I connect Fz to IN1N, not IN1P? I can't understand the difference between (none - IN1N) and (IN1P - none). I think they are the same except the polarity.
    - Why it does work when I connect the electrode only IN*N in the sequential montage? It requires at least two electrodes to measure the difference between them.
    - I don't want to use P7 if possible since the noise from P7 is contaminated. Then, the best way is, to use the sequential montage(SRB2) and connect Fz to IN1N and invert the voltage?
  • wjcroftwjcroft Mount Shasta, CA
    Whew. Please don't make this more complicated that you need. I suggest just using the default Cyton electrode setup as documented in the tutorials. And the same one you have been using: SRB2 is your reference, IN*N (bottom row) pins are your channels, Bias is your ground. That will give you AN INVERTED ERP signal, because your channels are on the negative side of the differential amplifier, and the references are all on the positive side of the differential amplifier.

    Please don't use SRB1 or the top row of pins. Your montage is referential (common reference on SRB2) and not sequential nor per channel differential.
  • Thank you.
    I'll use SRB2, BIAS2, and IN1N, and invert the signal.
Sign In or Register to comment.