Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Aperiodic Knee Fit #235

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions fooof/core/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def expo_function(xs, *params):
xs : 1d array
Input x-axis values.
*params : float
Parameters (offset, knee, exp) that define Lorentzian function:
y = 10^offset * (1/(knee + x^exp))
Parameters (offset, knee_freq, exp) that define Lorentzian function:
y = 10^offset * (1/(knee_freq^exp + x^exp))

Returns
-------
Expand All @@ -62,9 +62,9 @@ def expo_function(xs, *params):

ys = np.zeros_like(xs)

offset, knee, exp = params
offset, knee_freq, exp = params

ys = ys + offset - np.log10(knee + xs**exp)
ys = ys + offset - np.log10(knee_freq**exp + xs**exp)

return ys

Expand Down
2 changes: 1 addition & 1 deletion fooof/objs/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(self, peak_width_limits=(0.5, 12.0), max_n_peaks=np.inf, min_peak_h
# Guess parameters for aperiodic fitting, [offset, knee, exponent]
# If offset guess is None, the first value of the power spectrum is used as offset guess
# If exponent guess is None, the abs(log-log slope) of first & last points is used
self._ap_guess = (None, 0, None)
self._ap_guess = (None, 1, None)
# Bounds for aperiodic fitting, as: ((offset_low_bound, knee_low_bound, exp_low_bound),
# (offset_high_bound, knee_high_bound, exp_high_bound))
# By default, aperiodic fitting is unbound, but can be restricted here, if desired
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if

self._ap_bounds = ((-np.inf, -np.inf, -np.inf), (np.inf, np.inf, np.inf))

should also be updated, as the knee parameters shouldn't be below 0 in any case?

Expand Down