Open sjspielman opened 1 year ago
@AndiMcGrunt the GitHub repo you sent is in MatLab code, so it's not possible for me to directly run anything and compare. I can look generally at the approach the code takes, but it does NOT surprise me that there would be different pre-processing between this app which uses an R app for and an entirely separate matlab plug in. I am not able to evaluate the precise differences here. I can look into my calculations and see if there's a bug with signs and make sure everything is being pulled from the right place. To clarify, do you mean matlab doens;t change signs or my app doesn't change signs? I see in the matlab code they they are taking the mean of an absolute value, so I would expect their sign would never change and would in fact always be positive. I can probably get my code matching this: https://github.com/michtesar/asymmetry_toolbox/blob/b81de0aca232b57b42adfbccb7f123d335414895/faa/faa_index.m#L60-L61
The information I need to get as close as possible is literally EVERY, and I mean, EVERY, step you take in matlab to get these calculations. The best way to communicate is most likely a video screen-recording of you uploading data and doing the calculations.
Right, I referenced the GitHub link for the FAA toolbox in case the blog linked from there might have info re: the formula for calculating FAA-- should have just linked to this from the start, sorry: https://neurosciencemike.wordpress.com/2016/07/20/frontal-alpha-asymmetry-toolbox-for-eeglab/
I think it's a Matlab bug with the +/- because the output doesn't change when I reverse the order of the electrodes. I don't think I can do that in your app, because it's all done in the background. I don't math a lot, but shouldn't the signs change if you reverse the calculation? Conceptually a neg value is possible, because the point is to see which side has more alpha than the other.
let me know if you need a video now or if you want to look at things on your end first, I'll get one to you soon if that will help.
The code you sent me was fine, just letting you know that I can't directly use it since it's MatLab! But, I know enough that I can generally follow it.
I don't math a lot, but shouldn't the signs change if you reverse the calculation?
Literally just depends on what the correct formula is, so can't say.
Conceptually a neg value is possible, because the point is to see which side has more alpha than the other.
Sounds to me like matlab may have the bug then, if you expect negatives. Their code entirely disallows negatives.
Video sooner is better! I can look at all this in earnest sometime next week or weekend, probably.
Heads up that I am not likely to have time for this until next weekend 11/5-11/6.
I've had a chance for a quick look to see if I can try and match my code with MatLab's, but there are too many moving parts that are a bit above my pay grade/understanding of EEG. Here's what I can discern:
Matlab calculates power separately for each chosen electrode, for example here:
https://github.com/michtesar/asymmetry_toolbox/blob/b81de0aca232b57b42adfbccb7f123d335414895/faa/faa_index.m#L53-L56
The exact content of R
is not clear to me (I am assuming it's a 1D vector of signals but not sure).
In the eegUtils
code I am using, hamming window is also part of the internal calculations of compute_psd()
, so that should be comparable if calculations are done in the same way (this is above my pay grade). What I am not able to deal with is that the PSD calculations are using different algorithms for the FFT - matlab's spectrogram
function is using short-time fourier transform and eegUtils
uses Welch's method. I have no context to weigh in on differences between these algorithms.
HI! I have been slowly but steadily working on answering these questions. Here's what I now understand!
Now, for our purposes right now, looking at average FAA over the entire signal, I think Welch's method is fine. But down the line I would like to get FAA plotted over time as well.
Still working on why the +/- signs are the way they are in EEGlab, but maybe if they go over 2.0 the power flips; signal analysis is interesting, too much to explain, lots of trig happening with imaginary numbers that makes +/- seem kind arbitrary at times. Both EEGlab and our app seem to get proportional values in the same direction . My students just collected some more data in class so I'll see if we can plot more values for comparison. Here are the values from the dataset I shared at the start of this thread.
From #2: https://github.com/sjspielman/eeg_classroom_app/issues/2#issuecomment-1295142583