Page 1 of 1

From Raw to Absolute Band Powers

Posted: Thu Oct 14, 2021 6:47 pm
by jb-3000
Hello,

I am currently working on a research project as a research assistant and it is my first time using the Muse. We have collected data and just for me to learn, I am trying to replicate the graph of a specific channel and a specific from the online plotting tool mind monitor provides.

To do so, I import my data into Matlab EEGLAB and preprocess the data first (removing the offset, applying a highpass filter of 0.5 Hz and rejecting artifacts manually). Then I go back into the normal matlab scripting window and use a hanning tapering method and a short-time Fourier transform to get the power values distributed into 129 bins (using the approach from mike x cohen as a guideline):

fft_y = fft(yHan,NFFT)./numel(yHan); % take FFT normalize by length
pow_y = fft_y.*conj(fft_y); % mult by complex conjigut to get power (p)
P(ii,:) = pow_y(1:NFFT/2+1);


Afterwards I take the log10 of the sum of each frequency range for each point in time (here I am using the delta waves and the TP10 channel as an example):
delta_log=log10(sum(P(b.delta(1):b.delta(2),:)));

I then convert the values from a {-1:+1} scale to a {0,-100} scale like suggested.

When averaging the values per second (I think that is what the online tool does, since it only displays one value per second), I still do not get a graph that looks anything like the one shown online. Obviously if I just take the values of the first columns that represent the alpha, beta, ... values for each channel, I end up with the same plot as the one online. But I would seriously be interested in how to get there myself just using the raw data.

So I was wondering what pipeline/procedure is used in the online plotting tool to go from raw data to the absolute band power graph. I have looked through the forum and the archive plenty of times, but am still clueless.

I am looking forward to an answer,

Sincerely,
Jan

Re: From Raw to Absolute Band Powers

Posted: Thu Oct 14, 2021 9:36 pm
by James
To be able to calculated absolutes, you need to first record your RAW EEG at the full 256Hz rate. To do that, change the "Recording Interval" in settings to "Constant". If you're only using 1Hz (the default) RAW EEG, you won't be able to calculate anything useful.

Regarding the Math; Interaxon's API calculates the absolute band powers, so I can't give you the exact math that they use to go from RAW to absolute sorry.

Interaxon's absolute band powers are calculated from a sliding set of 256 values, calculated at 10Hz. You can find their very sparse documentation on that in the web archived version of their now decomissioned developer site here: https://web.archive.org/web/20181105231 ... and_Powers
On top of what's written on the developer site, I know they drop packets when a blink or jaw clench is detected, but beyond that I'm not quite sure how they group the binned data to get their exact absolute values. If you figure it out, I'd love to know!

The online viewer just loads the data and displays it in the chart, there not really any data processing. It's all done in client side javascript and no data is sent to my server. In order to make it render ok on both high end and low end devices, the only things it does math wise is it averages values per minute by default, or if you select "All Data Points" it'll give you average per second, which I know isn't technically all the data points, but it's about as granular as you can get and not crash the web browser on a cell phone/ipad ;-)

Re: From Raw to Absolute Band Powers

Posted: Fri Oct 15, 2021 1:13 pm
by jb-3000
Hey James,

thanks for the really quick response!

My data is recorded at a full 256Hz sampling rate. Too bad, that interaxons documentation doesn't give more infos. The site you have cited is the one I have already been working with. My script also drops the rows which get classified with a blink or jaw clench.

I will continue to look into it, I just feel like my approach is already pretty accurate, that's why I am confused. However, thanks again for the reply and if I figure something out, I'll let you know.

Cheers,
Jan

Re: From Raw to Absolute Band Powers

Posted: Wed Dec 22, 2021 4:04 pm
by Soll
I am trying to use matlab to do Fourier analysis for me. I am having trouble getting the fast Fourier transform function to act on my data set. Do you know how I would do this?

Re: From Raw to Absolute Band Powers

Posted: Thu Dec 23, 2021 3:48 am
by James
I don't have MATLAB, any more sorry. My free trial expired a long time ago. Perhaps someone else here can help.

Re: From Raw to Absolute Band Powers

Posted: Thu Feb 03, 2022 11:49 pm
by stargazer
GNU Octave (https://www.gnu.org/software/octave/) is 95% interchangeable with Matlab. FFT and related functions are included in Octave. At least when your data is a 1D array, the FFT is quite straightforward to perform.

Re: From Raw to Absolute Band Powers

Posted: Tue Aug 30, 2022 12:02 am
by jim_bullock
jb-3000 wrote: Fri Oct 15, 2021 1:13 pm Hey James,

thanks for the really quick response!

My data is recorded at a full 256Hz sampling rate. Too bad, that interaxons documentation doesn't give more infos. The site you have cited is the one I have already been working with. My script also drops the rows which get classified with a blink or jaw clench.

I will continue to look into it, I just feel like my approach is already pretty accurate, that's why I am confused. However, thanks again for the reply and if I figure something out, I'll let you know.

Cheers,
Jan
Hi jan, could you explain how you removed sorted lines with a snap or a jaw clench. Did you use a neural network perhaps?