Skip to content

Commit 4b6e497

Browse files
committed
Rename min_peak_amplitude -> min_peak_height (to drop reference to amplitude)
1 parent a5e8e3e commit 4b6e497

File tree

11 files changed

+25
-25
lines changed

11 files changed

+25
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ FOOOF.report() fits the model, plots the original power spectrum with the associ
114114
FOOOF also accepts parameters for fine-tuning the fit. For example:
115115

116116
```python
117-
fm = FOOOF(peak_width_limits=[1.0, 8.0], max_n_peaks=6, min_peak_amplitude=0.1, peak_threshold=2.0)
117+
fm = FOOOF(peak_width_limits=[1.0, 8.0], max_n_peaks=6, min_peak_height=0.1, peak_threshold=2.0)
118118
```
119119

120120
* `peak_width_limits` sets the possible lower- and upper-bounds for the fitted peak widths.
121121
* `max_n_peaks` sets the maximum number of peaks to fit.
122-
* `min_peak_amp` sets an absolute limit on the minimum amplitude (above aperiodic) for any extracted peak.
122+
* `min_peak_height` sets an absolute limit on the minimum amplitude (above aperiodic) for any extracted peak.
123123
* `peak_threshold`, also sets a threshold above which a peak amplitude must cross to be included in the model. This parameter is in terms of standard deviation above the noise of the flattened spectrum.
124124

125125
FOOOF also has convenience methods for running the FOOOF model across matrices of multiple power spectra, as well as functionality for saving and loading results, creating reports from FOOOF outputs, and utilities to further analize FOOOF results.

fooof/core/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def get_obj_desc():
1313
'r_squared_', 'error_',
1414
'_gaussian_params'],
1515
'settings' : ['peak_width_limits', 'max_n_peaks',
16-
'min_peak_amplitude', 'peak_threshold',
16+
'min_peak_height', 'peak_threshold',
1717
'aperiodic_mode'],
1818
'data' : ['power_spectrum', 'freq_range', 'freq_res'],
1919
'data_info' : ['freq_range', 'freq_res'],

fooof/core/strings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def gen_settings_str(f_obj, description=False, concise=False):
5959
# Parameter descriptions to print out, if requested
6060
desc = {'peak_width_limits' : 'Enforced limits for peak widths, in Hz.',
6161
'max_n_peaks' : 'The maximum number of peaks that can be extracted.',
62-
'min_peak_amplitude' : 'Minimum absolute amplitude of a peak, above aperiodic component.',
62+
'min_peak_height' : 'Minimum absolute amplitude of a peak, above aperiodic component.',
6363
'peak_threshold' : 'Threshold at which to stop searching for peaks.',
6464
'aperiodic_mode' : 'The aproach taken to fitting the aperiodic component.'}
6565

@@ -81,8 +81,8 @@ def gen_settings_str(f_obj, description=False, concise=False):
8181
'{}'.format(desc['peak_width_limits']),
8282
'Max Number of Peaks : {}'.format(f_obj.max_n_peaks),
8383
'{}'.format(desc['max_n_peaks']),
84-
'Minimum Amplitude : {}'.format(f_obj.min_peak_amplitude),
85-
'{}'.format(desc['min_peak_amplitude']),
84+
'Minimum Amplitude : {}'.format(f_obj.min_peak_height),
85+
'{}'.format(desc['min_peak_height']),
8686
'Amplitude Threshold: {}'.format(f_obj.peak_threshold),
8787
'{}'.format(desc['peak_threshold']),
8888
'Aperiodic Mode : {}'.format(f_obj.aperiodic_mode),

fooof/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
###################################################################################################
77

88
FOOOFSettings = namedtuple('FOOOFSettings', ['peak_width_limits', 'max_n_peaks',
9-
'min_peak_amplitude', 'peak_threshold',
9+
'min_peak_height', 'peak_threshold',
1010
'aperiodic_mode'])
1111
FOOOFSettings.__doc__ = """\
1212
The user defined settings for a FOOOF object.
@@ -17,7 +17,7 @@
1717
Limits on possible peak width, as (lower_bound, upper_bound).
1818
max_n_peaks : int, optional, default: inf
1919
Maximum number of gaussians to be fit in a single spectrum.
20-
min_peak_amplitude : float, optional, default: 0
20+
min_peak_height : float, optional, default: 0
2121
Minimum amplitude threshold for a peak to be modeled.
2222
peak_threshold : float, optional, default: 2.0
2323
Threshold for detecting peaks, units of standard deviation.

fooof/fit.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ class FOOOF(object):
6767
Limits on possible peak width, as (lower_bound, upper_bound).
6868
max_n_peaks : int, optional, default: inf
6969
Maximum number of gaussians to be fit in a single spectrum.
70-
min_peak_amplitude : float, optional, default: 0
71-
Minimum amplitude threshold for a peak to be modeled.
70+
min_peak_height : float, optional, default: 0
71+
Minimum height threshold for a peak to be modeled, in units of the input data.
7272
peak_threshold : float, optional, default: 2.0
73-
Threshold for detecting peaks, units of standard deviation.
73+
Threshold for detecting peaks, in units of standard deviation of the input data.
7474
aperiodic_mode : {'fixed', 'knee'}
7575
Which approach to take for fitting the aperiodic component.
7676
verbose : boolean, optional, default: True
@@ -111,7 +111,7 @@ class FOOOF(object):
111111
get smoother power spectra, as this will give better FOOOF fits.
112112
"""
113113

114-
def __init__(self, peak_width_limits=(0.5, 12.0), max_n_peaks=np.inf, min_peak_amplitude=0.0,
114+
def __init__(self, peak_width_limits=(0.5, 12.0), max_n_peaks=np.inf, min_peak_height=0.0,
115115
peak_threshold=2.0, aperiodic_mode='fixed', verbose=True):
116116
"""Initialize FOOOF object with run parameters."""
117117

@@ -124,7 +124,7 @@ def __init__(self, peak_width_limits=(0.5, 12.0), max_n_peaks=np.inf, min_peak_a
124124
# Set input parameters
125125
self.peak_width_limits = peak_width_limits
126126
self.max_n_peaks = max_n_peaks
127-
self.min_peak_amplitude = min_peak_amplitude
127+
self.min_peak_height = min_peak_height
128128
self.peak_threshold = peak_threshold
129129
self.aperiodic_mode = aperiodic_mode
130130
self.verbose = verbose
@@ -644,7 +644,7 @@ def _fit_peaks(self, flat_iter):
644644
guess_amp = max_amp
645645

646646
# Halt fitting process if candidate peak drops below minimum amp size.
647-
if not guess_amp > self.min_peak_amplitude:
647+
if not guess_amp > self.min_peak_height:
648648
break
649649

650650
# Data-driven first guess BW

fooof/plts/fm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def plot_peak_iter(fm):
8686
plot_spectrum(fm.freqs, flatspec, linewidth=2.0, label='Flattened Spectrum', ax=ax)
8787
plot_spectrum(fm.freqs, [fm.peak_threshold * np.std(flatspec)]*len(fm.freqs),
8888
color='orange', linestyle='dashed', label='Relative Threshold', ax=ax)
89-
plot_spectrum(fm.freqs, [fm.min_peak_amplitude]*len(fm.freqs),
89+
plot_spectrum(fm.freqs, [fm.min_peak_height]*len(fm.freqs),
9090
color='red', linestyle='dashed', label='Absolute Threshold', ax=ax)
9191

9292
maxi = np.argmax(flatspec)

tutorials/plot_03-FOOOFAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
###################################################################################################
5555

5656
# Initialize a FOOOF object, with some settings
57-
fm = FOOOF(peak_width_limits=[1, 8], max_n_peaks=6 , min_peak_amplitude=0.15)
57+
fm = FOOOF(peak_width_limits=[1, 8], max_n_peaks=6 , min_peak_height=0.15)
5858

5959
###################################################################################################
6060
#

tutorials/plot_04-MoreFOOOF.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
# Once a candidate peak drops below this threshold, the peak search is halted (without
7676
# including the most recent candidate).
7777
#
78-
# **min_peak_amplitude (units of power - same as the input spectrum)** default: 0
78+
# **min_peak_height (units of power - same as the input spectrum)** default: 0
7979
#
8080
# The minimum amplitude, above the aperiodic fit, that a peak must have to be extracted
8181
# in the initial fit stage. Once a candidate peak drops below this threshold, the peak
@@ -182,7 +182,7 @@
182182
###################################################################################################
183183

184184
# Initialize FOOOF model, with some specified settings
185-
fm = FOOOF(peak_width_limits=[1, 8], max_n_peaks=6, min_peak_amplitude=0.15)
185+
fm = FOOOF(peak_width_limits=[1, 8], max_n_peaks=6, min_peak_height=0.15)
186186

187187
# Fit FOOOF
188188
fm.report(freqs, spectrum, freq_range)

tutorials/plot_06-FOOOFGroup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
###################################################################################################
8888

8989
# Initialize a FOOOFGroup object - it accepts all the same settings as FOOOF
90-
fg = FOOOFGroup(peak_width_limits=[1, 8], min_peak_amplitude=0.05, max_n_peaks=6)
90+
fg = FOOOFGroup(peak_width_limits=[1, 8], min_peak_height=0.05, max_n_peaks=6)
9191

9292
###################################################################################################
9393

tutorials/plot_07-TroubleShooting.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
# - Setting a maximum number of peaks that the algorithm may fit: `max_n_peaks`
119119
#
120120
# - If set, the algorithm will fit (up to) the `max_n_peaks` highest power peaks.
121-
# - Setting a minimum absolute amplitude for peaks: `min_peak_amplitude`
121+
# - Setting a minimum absolute amplitude for peaks: `min_peak_height`
122122
#
123123

124124
###################################################################################################
@@ -157,7 +157,7 @@
157157
###################################################################################################
158158

159159
# Update settings to fit a more constrained FOOOF model, to reduce overfitting
160-
fm = FOOOF(peak_width_limits=[1, 8], max_n_peaks=6, min_peak_amplitude=0.4)
160+
fm = FOOOF(peak_width_limits=[1, 8], max_n_peaks=6, min_peak_height=0.4)
161161
fm.report(freqs, spectrum)
162162

163163
###################################################################################################
@@ -185,7 +185,7 @@
185185
# relative amplitude check (`min_peak_threshold`) is very liberal at keeping gaussian fits.
186186
#
187187
# If you expect, or know, you have power spectra without peaks in your data,
188-
# we therefore recommend making sure you set some value for `min_peak_amplitude`,
188+
# we therefore recommend making sure you set some value for `min_peak_height`,
189189
# as otherwise FOOOF is unlikely to appropriately fit power spectra as having
190190
# no peaks. Setting this value requires checking the scale of your power spectra,
191191
# allowing you to define an absolute threshold for extracting peaks.
@@ -197,7 +197,7 @@
197197
#
198198
# If you are finding that FOOOF is underfitting:
199199
#
200-
# - First check and perhaps loosen any restrictions from `max_n_peaks` and `min_peak_amplitude`
200+
# - First check and perhaps loosen any restrictions from `max_n_peaks` and `min_peak_height`
201201
# - Try updating `peak_threshold` to a lower value
202202
# - Bad fits may come from issues with aperiodic signal fitting
203203
#
@@ -219,7 +219,7 @@
219219
freqs, spectrum = gen_power_spectrum([1, 50], ap_params, gauss_params, nlv=nlv)
220220

221221
# Update settings to make sure they are sensitive to smaller peaks in smoother power spectra
222-
fm = FOOOF(peak_width_limits=[1, 8], max_n_peaks=6, min_peak_amplitude=0.2)
222+
fm = FOOOF(peak_width_limits=[1, 8], max_n_peaks=6, min_peak_height=0.2)
223223
fm.report(freqs, spectrum)
224224

225225
###################################################################################################

0 commit comments

Comments
 (0)