Hi everyone, I'm trying to run FOOOF, but I'm having an error. I computed Welch PSD. I have a resting state signal of 438 seconds, and I have simply used 2 sec window with 50% overlap. However when I tried to use FOOOF over the PSD file, I receive an error message. I attached the picture.
In fact, the only part giving problem is this one: mod(sum(abs(round(Freqs.*10)./10-[1;2;3].*str2double(opt.power_line)) >= 2),3)
I believe that this part is related to the removal of the frequencies of power line, in fact if I simply create the mask with the frequencies of interest in the following way, it works correctly:
Of course with the limitation that it is not removing the power line frequency.
I do not know if it is a bug related to my matlab version or something else. Hope this can be useful in some way.
Hi Gian Marco, hope you've been doing well lately!
It looks like you've come across an interesting error: I've been able to recreate it by defining the Freqs variable as a column vector (i.e., nx1; instead of a row vector, 1xn). Brainstorm usually stores frequencies in a row vector, is there a particular way you set up your script that would have changed the format of your Freqs variable?
To summarize, you can still remove power line frequencies by formatting the Freqs variable as a 1xn row vector. If you still have any issues, please just let me know!
Such a great pleasure to hear you Luc! It is strange because indeed my Freqs array, when I do the debug, is a row vector of 1x257.
When I run this part separately just to check:
I must admit, I have no idea what could be causing this issue! As a temporary fix, I've written some custom code for you to add to your process_fooof.m script if you'd still like to ignore power lines.
First, you can add the following function to the end of process_fooof.m:
function mask = ignore_pl_GM(Freqs,pl)
mask = ones(size(Freqs));
for k = 1:3
mask = mask & (abs(round(Freqs.*10)./10-k.*pl) >= 2);
end
end
Then, you can replace replace line 232 with the following code:
Together, this should eliminate the issue (for now). What version of MATLAB are you running, out of curiosity? In the meantime, I'll try to find a long-term solution that fixes this issue (though I still haven't determined how it happens).
Hi @Luc sorry for bothering you again. I was trying to use the FOOOF on another pc, but I have the problem of the optimization toolbox. Due to licence problem it is not available for me on this new pc. But if you tell me which functions of the optimization toolbox you use in the FOOOF process, I can try to copy them from my previous toolbox on my new workstation.
Thanks
No worries: if I recall correctly it should only require fmincon.m, though there may be more dependencies embedded in this function.
I believe fooof should still work without bounded optimization, though the outputs will not be exactly the same. You can also test the various options for “guess weight”, which operate as a form of ridge regression.
Hi @Luc , sorry for bothering you again, but this time is for a conceptual interpretation of the exponent of the aperiodic part. Usually in literature, even the papers from Voytek, a low exponent of the aperiodic is related with an imbalance in direction of the excitation, while the opposite for higher exponent.
Strangely while comparing the exponent of patients with temporal epilepsy in different dataset I found a consistent result namely,a higher exponent of the aperiodic part for the patients compared to the controls specifically in the temporal areas. I was expecting the opposite, since a higher exponent shoul be related with a higher inhibition.
Then I saw the line 285 of the fooof process where it takes the abs of the aperiodic parts:
aperiodic_pars(2) = abs(aperiodic_pars(2));
In this case the exponent would be flipped, and so the interpretation can be misleaded.
But probably I not understanding correctly the whole picture both on the code and the interpretation of the exponent value.
Since you worked a bit on this topic, can you help me in better understaing the interpretation and the value of the exponent of the aperiodic parts?
Thank you
Without having looked closely at the code, what comes to mind is the relatively recent feature of Matlab to automatically do "singleton expansion" with basic operators (+-* etc). Previously, we had to use bsxfun to do that (or repmat), and since Brainstorm aims for compatibility with older Matlab, we still should use it. In other words, I suspect there's a matrix mismatch in these operations that newer versions of Matlab "fix" automatically - whether it's the right way or not is something that we should confirm! And then replace with the appropriate bsxfun.
Hi @Luc can we please schedule a videocall to discuss about the functioning of the FOOOF itself in brainstorm?
There are some results that I would need to discuss with you about the fitting itself.
We can text each other directly. My address is gianmarco.duma@lanostrafamiglia.it
Thanks