BrainFlow: Replicating the pre-processing steps from the GUI

(I posted in the NeuroTechX Slack group and was asked to post here)
Hello, I have been tinkering with the OpenBCI head set for a little while in the GUI, and when I finally moved on to using the system without the GUI, I encountered some issues/discrepancies that I could use some help with. For reference, I am working on running a motor imagery experiment with a protocol very similar to that in the BCI2000 paper. I am wondering what processing steps need to be taken to get the data prior to loading into MNE to have the data represented as cleanly as in the GUI. Here is what I have done so far (I will try to add visualizations and sample code later in the day):

Record data

I have recorded data both from a synthetic board and from the Cyton board using BrainFlow. I loaded the data into MNE as per the tutorial on the BrainFlow website and plotted it to quickly realize that the signal was much too strong. So here is the first issue I noticed in the tutorials: the values saved to the CSV file by BrainFlow are represented as microvolts when MNE requires the input unit to be volts. So all of the eeg data should be multiplied by 1e-6 prior to loading into MNE.

Denoising and Filtering

The OpenBCI GUI saves data BEFORE filtering and provides no active de-noising so then in theory I should only need to filter the data at this step, however, I was suggested on the Slack group to also try de-noising the data. Should denoiding be done after the filter or before?

Filter the Data

In the GUI the data has a bandpass filter of 5-50 Hz and a notch filter at 60 Hz. The Brainflow API for bandpass takes "center frequency" and "bandwidth" as parameters so I used 26 and 25 to obtain a bandpass filter for 1-51 Hz. I then followed it up with a 4th order Bandstop at 60 Hz with a bandwidth of 1 Hz. It seems like I maybe need to increase the bandwidth for the bandstop.

Denoising the data

I am unsure what would be a good denoiseing algorithm to select so I am going to try all of them and see what looks best. I am wondering if the multitaper method was considered at all?

Full process

So Right now for the full process I have this:

  • Record and segment data
  • Convert data from uV to V
  • Bandpass Filter: (1-51 Hz, 3rd order)
  • Bandstop Filter: (59.5-60.5 Hz, 4th order)
  • Denoising (Undecided method)
  • Convert to RMS value (What sized window is uses in the GUI?)

Is this seemingly correct so far?

Comments

  • wjcroftwjcroft Mount Shasta, CA

    Jadin, thanks for your posts here.

    I'm mentioning @Andrey1994 Parfenov, who is the BrainFlow developer / creator, in case he might have additional comments.

    Regarding de-artifacting / denoising biosignals, this is a large subject area. Wavelet transforms are a part of the picture, but not a "single solution" that encompasses all artifacts. See this recent review paper link.

    https://res.mdpi.com/d_attachment/sensors/sensors-19-00987/article_deploy/sensors-19-00987.pdf
    “Removal of Artifacts from EEG Signals: A Review” 2019

    Band / notch filters should be applied before any denoising operations, as much of the noise in EEG comes from higher frequency scalp EMG, mains noise, etc. In general wavelets alone will not address eye blinks, jaw movement, etc. Check out this related thread. (Excuse some formatting glitches in the text, which resulted when our forum software upgraded.)

    https://openbci.com/forum/index.php?p=/discussion/1258/artifact-detection-thresholds-algorithms

    Regards, William

  • Thank you, I will read through these periodically throughout the day. I ran the steps above on Synthetic data, Cyton data recorded over Brainflow, and cyton data recorded and saved offline via the GUI. I had some strange behavior happening on a few channels so I am wondering if maybe its an issue in the headsets set up or maybe just recording some particularly strange EEG signals. I have images saved on my other computer that I will share later, unfortunately I am stuck in classes most of today. A few additional questions regarding some of the steps in the GUI:

    • For the notch filter at 60 Hz, what bandwidth is used in the GUI? I used 1 Hz but it did not seem to be wide enough.
    • For the RMS calculation, what size of a window is used?
  • I am not an expert in OpenBCI GUI, so I can comment only about this pipeline in general.

    • Record and segment data
    • Convert data from uV to V
    • Bandpass Filter: (1-51 Hz, 3rd order)
    • Bandstop Filter: (59.5-60.5 Hz, 4th order)
    • Denoising (Undecided method)
    • Convert to RMS value (What sized window is uses in the GUI?)

    Its ok and absolutely correct, for bandstop filter I think it makes sense to set width to smth like +- 2 or at least +- 1. But I have no idea how its implemented in GUI.
    Bandpass filter width can also be tuned a little if you know in front which freq range you need.
    About filter types and orders I can recommend to try several and choose the best one. (and the same for denoising)

Sign In or Register to comment.