Questions about fooof


In the code of fooof, the fit_peaks can help for finding the center_frequency, amplitude and std_dev. I want to fit the peaks for original PSD and get the above three parameters, how can I find the function in brainstorm? I try to modify the 'flat_spec' to 'spec(chan,:)' of line 408 in the picture. But the results show no peaks. What is the problem?

I am trying to fit peaks of model_fit by using 'fit_peaks', and there is also no peaks.

The function fit_peaks works on the PSD one the aperiodic component has been removed, not in the original PSD. You can try the steps as indicated in the FOOOF_matlab function:

  1. Fit aperiodic
  2. Remove aperiodic, then
  3. Fit peaks

I suggest you to run the FOOOF computation with example data as provide in this tutorial (link below), and use the Matlab debugger to plot and understand what is happening in each step. If you have questions about that please do not hesitate in sharing them with us.

Why this function does not work on the original PSD? Even it doesn't work on the model_fit. This is causing me some trouble. How can I get the peaks(center frequency and amplitude) of original PSD. I want to compare the differences of peak parameters between corrected PSD and original PSD. I try to find a useful method and always fall. I am looking forward to your answer.
best,
sguo

Because the function fit_peaks works ONLY for the flattened PSD, this is to say the PSD once the aperiodic has been removed. This is indicated in the function description, and it is part of the original FOOOF method.

This is the step number 2 in the diagram below.

Thank you for your answer. For fiting peaks for original PSD, do you have some suggestions? Is there a function in brainform that can do this? I am trying to restore the model fit based on periodic and aperiodic parameters and determine the amplitude of uncorrected PSD based on the center frequency. Is it feasible? I referred to the content in this FOOOF model, and PSD units - #6 by emokh1986 on how to restore model_fit. It seems that the equation is like this:
image
amp1、cf1、std1 refer to periodic parameters. Is this correct?

best wishes,
sguo

That's correct, amp1, cf1 and st1 are the parameters for peak1

Check this example:

Thank you for your patience. I will review the example you provided. So after obtaining the model fit, considering that it is the sum of aperiodic and periodic signals, it seems that the center frequency of the peaks of model_fit should be the same as it of peak_fit. By calculating the amplitude corresponding to the center frequency, we can estimate the amplitude of the peak of the original PSD and compare the power of the original PSD and the corrected PSD. Is this understanding correct?

But I'm exploring the differences between the conventional approach PSD (both aperiodic and periodic components) and corrected PSD(only periodic components). Do you have any suggestions on the comparison?or any recommended methods for calculating the peak amplitude, center frequency, and bandwidth of the original PSD?
Best wishes,
Sguo

That's correct, it will give the power difference for that frequency between the original PSD and the FOOOF model.

While it may be a translation perk, the PSD is not corrected with FOOOF. The FOOOF approach just fits a parametrized model for the PSD, thus its rebranded name "specparam" (Spectral parameterization)

For each PSD that is modeled, the MSE (mean squared error) is computed, you can use that metric of how good is the model fit to the original PSD, i.e., how similar these two PSDs are.