Page 1 of 1

FFT from raw data - Alpha problem

Posted: Thu Sep 12, 2024 12:39 pm
by banhorvathattila
Dear James!
Thank you for the amazing app!

I'm trying to do my own FFT from the raw data because eventually I will need more detailed bands for a meditation study. (alpha1, alpha2, beta1, beta2 etc) First I tried to reproduce the precalculated bands from Muse to check my method and the closest I got is this:
Clipboard_09-12-2024_01.png
Clipboard_09-12-2024_01.png (169.56 KiB) Viewed 1057 times
The continous lines are my calculations, the dashed lines are the precalculated bands from the csv.
As you can see the shape of the lines mostly match but the values and the relative positions don't. Any idea what goes wrong?

The FFT method (calculate_band_powers_fft):
It uses a window size of 256 samples with a 90% overlap (step size of 22 samples).
It applies a Hanning window to each segment.
It calculates the FFT for each windowed segment.
It computes the power spectral density (PSD) from the FFT results.
The bands: ('Delta', (1, 4)),
('Theta', (4, 8)),
('Alpha', (7.5, 13)),
('Beta', (13, 30)),
('Gamma', (30, 44))
It takes the log10 of this sum to get the power in Bels.

I'd appreciate any help/hint/info you can give me!

Re: FFT from raw data - Alpha problem

Posted: Thu Sep 12, 2024 1:12 pm
by James
Interaxon's exact FFT algorythm is closed source, so I can't tell you exactly what they're doing, other than I know they're filtering jaw clench, blinks and powerline noise.

But, this looks good to me! You've got Theta pretty much spot on.
There are a ton of options for FFT, so there is no "correct" way, it's all just math.
With that said, if you do manage to find out their exact math, please post it here! I'm sure people would love to know!

Re: FFT from raw data - Alpha problem

Posted: Thu Sep 12, 2024 6:13 pm
by banhorvathattila
I do some amplitude artifact removal and bandpass filtering. I also just cut out any section of the data that seems to contain blinks or jaw clench. What grinds my gears is that my beta is constantly way higher than my alpha. Even my gamma is higher than my alpha. The Muse bands are the exact opposite, their alpha is higher than their beta and gamma. That doesn't seem like a minor difference, specially regarding meditation. Since the order difference is constant, I don't see how this could be related to momentary artifacts. Am I getting something fundamentally wrong with log scales? I'm not very good at you know... math.

Re: FFT from raw data - Alpha problem

Posted: Thu Sep 12, 2024 11:49 pm
by James
I don't think you're doing anything wrong, but you are doing something differently to them. That doesn't mean it's wrong. You could try emailing their tech support and just asking if they'll share the basic concepts of how they're doing it. If they answer, post it here! It's that or Ghidra and a lot of digging.