fooof-tools / fooof

Parameterizing neural power spectra into periodic & aperiodic components.
https://fooof-tools.github.io/
Apache License 2.0
358 stars 97 forks source link

ValueError: Requested aperiodic mode not understood. #330

Closed AnnaPlieva closed 1 month ago

AnnaPlieva commented 2 months ago

Hello! Thank you for great toolbox! I want use new 'lorentzian' mode for component aperiodic_mode, but I have an error

fm_lorentzian = FOOOF( aperiodic_mode = 'lorentzian') fm_lorentzian.report(freqs, spectrum, freq_range, plt_log=True)

FOOOF WARNING: Lower-bound peak width limit is < or ~= the frequency resolution: 0.50 <= 0.49 Lower bounds below frequency-resolution have no effect (effective lower bound is the frequency resolution). Too low a limit may lead to overfitting noise as small bandwidth peaks. We recommend a lower bound of approximately 2x the frequency resolution.

Traceback (most recent call last):

Cell In[36], line 2 fm_lorentzian.report(freqs, spectrum, freq_range, plt_log=True)

File ~/.local/lib/python3.10/site-packages/fooof/objs/fit.py:418 in report self.fit(freqs, power_spectrum, freq_range)

File ~/.local/lib/python3.10/site-packages/fooof/objs/fit.py:481 in fit self.aperiodicparams = self._robust_ap_fit(self.freqs, self.power_spectrum)

File ~/.local/lib/python3.10/site-packages/fooof/objs/fit.py:988 in _robust_ap_fit popt = self._simple_ap_fit(freqs, power_spectrum)

File ~/.local/lib/python3.10/site-packages/fooof/objs/fit.py:953 in _simple_ap_fit aperiodicparams, = curve_fit(get_ap_func(self.aperiodic_mode),

File ~/.local/lib/python3.10/site-packages/fooof/core/funcs.py:188 in get_ap_func raise ValueError("Requested aperiodic mode not understood.")

ValueError: Requested aperiodic mode not understood.

I have 1.1.0 fooof version How can I use a new mode?

TomDonoghue commented 2 months ago

Hey @AnnaPlieva - thanks for trying out the package! I'm not sure what you are trying to do with the aperiodic_mode = 'lorentzian' setting though - that is not an available aperiodic mode. The current options are 'fixed' and 'knee'.

Information on using the available aperiodic modes is available here: https://fooof-tools.github.io/fooof/auto_tutorials/plot_05-AperiodicFitting.html

TomDonoghue commented 1 month ago

I'm going to close this issue since there is not a ToDo item here - but if you have any follow ups, feel free to add a new comment here @AnnaPlieva