Reading Channel Data: Fast Fourier Transforms, Sample Rate and Scale Factor

edited April 2016 in Software
It is typical to convert raw EEG channel data into various "brain waves" (alpha, delta, gama frequencies, etc.) using Fast Fourier Transform.

In reading the OpenBCI v3 Data Specs, it is not obvious to me whether or not the data pumped out by the RFduino is "raw" channel data, or whether it has already undergone FFT. Any ideas?

Also, regardless of whether the EEG data is "raw" or FFT, I have some similar questions about the following concepts:
  • the sample rate is explained to be 250 Hz by default, but the docs never explain what the sample rate actually is. what is it, and how does this sample rate relate to the FFT-decomposed frequencies like alpha waves, delta waves, etc.?
  • i'm not entirely sure I understand the "scale factor"; what are we scaling from? what are we scaling to? I would have expected the OpenBCI mainboard to sample EEG data in, say, microvolts, and for its outputs (24-bit signed integers) to simply be expressed as those units (again, say, microvolts). is this not the case?
Thanks for any and all help!

Comments

  • biomurphbiomurph Brooklyn, NY
    The data transmitted from the 32bit board over the RFduinos is 'raw' EEG data in ADC counts.
    The sample rate is 250Hz. That is the actual sample rate.

    The scale factor is used to convert the 'raw' ADC counts (24 bit result from the Analog Front End) into scientific units (uV)
  • Thanks @biomurph!

    However, I'm still a little confused!

    (1) It sounds like you are saying that I would need to apply my own Fast Fourier Transform (FFT) myself on this "raw" EEG data, so as to gain access to the various component frequencies (alpha waves, beta waves, etc.). Can you (or anyone else) please  confirm this?

    (2) It sounds like you are saying that the sample rate is not a variable, and is hardcoded/preconfigured at 250 Hz. Can you (or anyone else!) confirm that it is not adjustable?

    (3) I'm still really fuzzy on the scale factor stuff.  It would seem to me that the 24-bit ADC counts would always be within the same range. That is, at any given point in time, the hardware reads the value of one EEG channel to be, say, "36" units (not sure what the units would be) of something. But, on the application side, after we convert the 24-bits into a signed 32-bit integer, what units will that 32-bit signed integer be expressed in? Are you saying that the scale factor gives us the opportunity to determine its units?!? For instance:

    Let's just pretend (I'm too lazy to do the math for this example) that a 24-bit value of 36 is actually a 32-bit value of, say, 125, assuming our "scale factor" is 1 (x1 that is).  Perhaps this represents micro-volts, and so we would say that a 24-bit analog reading of 36 is actually the same as 125 uV when we use a scale factor of 1 and convert it to a 32-bit signed integer.  If my understanding here is correct, then that would mean using a scale factor of 1,000 would convert a 24-bit value of 36 into a 32-bit signed value of .125 mV (milli volts).

    Can you (or anyone else!) please confirm that my understanding of scale factor is correct, and if not, use a concrete example to help me understand it better?

    Thanks for any-and-all clarification/help here!
  • wjcroftwjcroft Mount Shasta, CA
    The OpenBCI_GUI source code is an excellent starting point to see how the raw data is filtered and transformed into FFT, etc. Other apps exist such as neuromore, BrainBay, BioEra, OpenViBE, etc. that can do these signal processing steps for you without any programming knowledge.

    https://en.wikipedia.org/wiki/Signal_processing

    As an example of a BrainBay signal flow, see,

    http://openbci.com/forum/index.php?p=/discussion/90/brainbay-install-neurofeedback-tutorial

    The scale factor calculation with example is shown at the end of this page,

    http://docs.openbci.com/software/02-OpenBCI_Streaming_Data_Format


  • wjcroftwjcroft Mount Shasta, CA
    The sample rate adjustment IS currently a constant 250 sps for 8 channels and 125 sps for 16 channels. These could be changed by altering the mainboard firmware. Note that data rates are currently constrained by the RFduino radio link throughput. Faster sample rates are available and have been implemented by some users, by recording directly to the SDcard, rather than over the radio.

  • Thanks for the confirmation on sampling rate being predefined @wjcroft!

    For the scale factor, I'm still struggling to understand what exactly is being scaled. Can you perhaps give me a concrete example of data output that is using two different scale factors? I think seeing a concrete example would clear everything up for me here, thanks again!
  • wjcroftwjcroft Mount Shasta, CA
    edited April 2016
    24 bits of resolution gives a huge range of values that covers +- 187 millivolts. This is plenty for both EEG and EMG EKG. So in general no adjustment of scale factors is needed. The only reason the tutorial shows a scale factor change in the GUI, is so that the EEG and EKG traces can all use the same graph scale. In reality the EKG data would have been recorded fine in the data file. Maximum +- of EKG data is a few millivolts. EEG data ranges typically +- 100 microvolts.

    Here's some comment lines in the BrainBay driver that I inserted during our mods,

    // OpenBCI ADS1299 samples are 24 bits, so +- (2^23 - 1)  max signed integers
    //
    // From TI data sheet: (Volts/count) = 4.5 Volts / gain / (2^23 - 1);
    //  default gain for the board is 24x,
    //  that gives 4.5 / 24 / (2^23 - 1) = .0223 uV per count
    //
    // So full scale +- range of microvolts in 24 bits is 2^23 * .02235 = +-187485.388 uV.

    https://github.com/ChrisVeigl/BrainBay/blob/master/src/ob_eeg.cpp

    OpenBCI_GUI code differs from this. But the GUI allows you to alter the firmware scale factor. The samples recorded in the file and shown on screen are adjusted by the scale factor you have chosen. Hence allowing both EEG and EKG to appear on a similar graph scaling. But in reality, recording both EEG and EKG simultaneously at the same default x24 scale factor, would work fine. No bits would be lost. The tutorial scale adjustment was just made for clarity of the GUI screen graph.

    Bottom line, you don't have to be concerned about scale factor. Just compute using the default values.

  • That makes *perfect* sense - thanks!
Sign In or Register to comment.