Skip to content

Commit 9e8f487

Browse files
authored
Merge pull request #129 from fooof-tools/audit
Audit & misc fixes for 1.0 release
2 parents c028b72 + b14a840 commit 9e8f487

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+548
-438
lines changed

doc/api.rst

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,25 @@ FOOOFGroup Object
3131

3232
FOOOFGroup
3333

34-
FOOOF Object Functions
35-
----------------------
34+
Bands
35+
-----
36+
37+
.. currentmodule:: fooof.bands
38+
39+
.. autosummary::
40+
:toctree: generated/
41+
42+
Bands
43+
44+
FOOOF Functions
45+
---------------
3646

3747
.. currentmodule:: fooof.funcs
3848

3949
.. autosummary::
4050
:toctree: generated/
4151

52+
average_fg
4253
combine_fooofs
4354
fit_fooof_group_3d
4455

@@ -51,16 +62,20 @@ Analysis Functions
5162
:toctree: generated/
5263

5364
get_band_peak
65+
get_band_peak_fm
66+
get_band_peak_fg
5467
get_band_peak_group
5568
get_highest_peak
5669

57-
Synth Code
58-
----------
70+
Sim Code
71+
--------
72+
73+
Code & utilities for simulating power spectra.
5974

6075
Generating Power Spectra
6176
~~~~~~~~~~~~~~~~~~~~~~~~
6277

63-
.. currentmodule:: fooof.synth.gen
78+
.. currentmodule:: fooof.sim.gen
6479

6580
.. autosummary::
6681
:toctree: generated/
@@ -72,27 +87,28 @@ Generating Power Spectra
7287
Parameter Management
7388
~~~~~~~~~~~~~~~~~~~~
7489

75-
.. currentmodule:: fooof.synth.params
90+
.. currentmodule:: fooof.sim.params
7691

7792
.. autosummary::
7893
:toctree: generated/
7994

8095
Stepper
8196
param_iter
8297
param_sampler
98+
update_sim_ap_params
8399

84100
Transforming Power Spectra
85101
~~~~~~~~~~~~~~~~~~~~~~~~~~
86102

87-
.. currentmodule:: fooof.synth.transform
103+
.. currentmodule:: fooof.sim.transform
88104

89105
.. autosummary::
90106
:toctree: generated/
91107

92108
translate_spectrum
93-
translate_syn_spectrum
109+
translate_sim_spectrum
94110
rotate_spectrum
95-
rotate_syn_spectrum
111+
rotate_sim_spectrum
96112
compute_rotation_offset
97113

98114
Plotting Functions
@@ -117,7 +133,5 @@ Utility Functions
117133
:toctree: generated/
118134

119135
trim_spectrum
120-
get_settings
121-
get_data_info
122-
compare_settings
123-
compare_data_info
136+
get_info
137+
compare_info

examples/plot_fit_fooof_3d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
# FOOOF imports
1313
from fooof import FOOOFGroup
1414
from fooof.funcs import fit_fooof_group_3d, combine_fooofs
15-
from fooof.synth.gen import gen_group_power_spectra
16-
from fooof.synth.params import param_sampler
15+
from fooof.sim.gen import gen_group_power_spectra
16+
from fooof.sim.params import param_sampler
1717

1818
###################################################################################################
1919

20-
# Settings for creating synthetic data
20+
# Settings for creating simulated data
2121
n_spectra = 10
2222
freq_range = [3, 40]
2323
ap_opts = param_sampler([[0, 1.0], [0, 1.5], [0, 2]])
2424
gauss_opts = param_sampler([[], [10, 1, 1], [10, 1, 1, 20, 2, 1]])
2525

2626
###################################################################################################
2727

28-
# Generate some synthetic power spectra, and organize into a 3D matrix
28+
# Generate some simulated power spectra, and organize into a 3D matrix
2929
spectra = []
3030
for ind in range(3):
3131
fs, ps, _ = gen_group_power_spectra(n_spectra, freq_range, ap_opts, gauss_opts)

examples/plot_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
###################################################################################################
1515

16-
# Create a couple synthetic power spectra to explore plotting with
16+
# Create a couple simulated power spectra to explore plotting with
1717
# Here we create two spectra, with different aperiodic components
1818
# but each with the same oscillations (a theta, alpha & beta)
19-
from fooof.synth.gen import gen_group_power_spectra
19+
from fooof.sim.gen import gen_group_power_spectra
2020
fs, ps, _ = gen_group_power_spectra(2, [3, 40], [[0.75, 1.5], [0.25, 1]],
2121
[6, 0.2, 1, 10, 0.3, 1, 25, 0.15, 3])
2222
ps1, ps2 = ps

examples/plot_synth_params.py renamed to examples/plot_sim_params.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
"""
2-
Synthetic Parameters
2+
Simulated Parameters
33
====================
44
5-
Manage parameters for creating synthetic power spectra.
5+
Manage parameters for creating simulated power spectra.
66
"""
77

88
###################################################################################################
99

1010
# Import fooof functions for creating spectra and managing parameters
11-
from fooof.synth.params import param_sampler, param_iter, Stepper
12-
from fooof.synth.gen import gen_power_spectrum, gen_group_power_spectra
11+
from fooof.sim.params import param_sampler, param_iter, Stepper
12+
from fooof.sim.gen import gen_power_spectrum, gen_group_power_spectra
1313

1414
# Import some fooof plotting functions
1515
from fooof.plts.spectra import plot_spectrum, plot_spectra
1616

1717
###################################################################################################
18-
# SynParams
18+
# SimParams
1919
# ~~~~~~~~~
2020
#
21-
# When you synthesize multiple power spectra, FOOOF uses `SynParams` objects to
21+
# When you simulate multiple power spectra, FOOOF uses `SimParams` objects to
2222
# keep track of the parameters used for each power spectrum.
2323
#
24-
# SynParams objects are named tuples with the following fields:
24+
# SimParams objects are named tuples with the following fields:
2525
# - `aperiodic_params`
2626
# - `gaussian_params`
2727
# - `nlv`
2828
#
2929

3030
###################################################################################################
3131

32-
# Set up settings for synthesizing a group of power spectra
32+
# Set up settings for simulating a group of power spectra
3333
n_spectra = 2
3434
freq_range = [3, 40]
3535
ap_params = [[0.5, 1], [1, 1.5]]
@@ -38,19 +38,19 @@
3838

3939
###################################################################################################
4040

41-
# Synthesize a group of power spectra
42-
fs, ps, syn_params = gen_group_power_spectra(n_spectra, freq_range, ap_params, gauss_params, nlv)
41+
# Simulate a group of power spectra
42+
fs, ps, sim_params = gen_group_power_spectra(n_spectra, freq_range, ap_params, gauss_params, nlv)
4343

4444
###################################################################################################
4545

46-
# Print out the SynParams objects that track the parameters used to create power spectra
47-
for syn_param in syn_params:
48-
print(syn_param)
46+
# Print out the SimParams objects that track the parameters used to create power spectra
47+
for sim_param in sim_params:
48+
print(sim_param)
4949

5050
###################################################################################################
5151

52-
# You can also use a SynParams object to regenerate a particular power spectrum
53-
cur_params = syn_params[0]
52+
# You can also use a SimParams object to regenerate a particular power spectrum
53+
cur_params = sim_params[0]
5454
fs, ps = gen_power_spectrum(freq_range, *cur_params)
5555

5656
###################################################################################################
@@ -83,7 +83,7 @@
8383
###################################################################################################
8484

8585
# Generate some power spectra, using the param samplers
86-
fs, ps, syn_params = gen_group_power_spectra(10, [3, 40], ap_opts, gauss_opts)
86+
fs, ps, sim_params = gen_group_power_spectra(10, [3, 40], ap_opts, gauss_opts)
8787

8888
###################################################################################################
8989

@@ -113,7 +113,7 @@
113113
###################################################################################################
114114

115115
# Generate some power spectra, using param iter
116-
fs, ps, syn_params = gen_group_power_spectra(len(cf_steps), [3, 40], ap_params, gauss_params)
116+
fs, ps, sim_params = gen_group_power_spectra(len(cf_steps), [3, 40], ap_params, gauss_params)
117117

118118
###################################################################################################
119119

examples/plot_synthetic_power_spectra.py renamed to examples/plot_simulated_power_spectra.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
"""
2-
Creating Synthetic Power Spectra
2+
Creating Simulated Power Spectra
33
================================
44
5-
Use FOOOF to create synthetic power spectra.
5+
Use FOOOF to create simulated power spectra.
66
"""
77

88
###################################################################################################
99

10-
# Import fooof functions for creating synthetic power spectra
11-
from fooof.synth.gen import gen_power_spectrum, gen_group_power_spectra
10+
# Import fooof functions for creating simulated power spectra
11+
from fooof.sim.gen import gen_power_spectrum, gen_group_power_spectra
1212

1313
# Import some fooof plotting functions
1414
from fooof.plts.spectra import plot_spectrum, plot_spectra
1515

1616
###################################################################################################
17-
# Creating Synthetic Power Spectra
17+
# Creating Simulated Power Spectra
1818
# --------------------------------
1919
#
20-
# FOOOF has utilities to create synthetic power spectra, whereby spectra
20+
# FOOOF has utilities to create simulated power spectra, whereby spectra
2121
# are simulated with an aperiodic component with overlying peaks,
2222
# using specified parameters.
2323
#
24-
# The :func:`gen_power_spectrum` function can be used to synthesize a power
24+
# The :func:`gen_power_spectrum` function can be used to simulate a power
2525
# spectrum with specified parameters.
2626
#
27-
# Note that all FOOOF functions that synthesize power spectra take in
27+
# Note that all FOOOF functions that simulate power spectra take in
2828
# gaussian parameters, not the modified peak parameters.
2929
#
3030

3131
###################################################################################################
3232

33-
# Settings for creating a synthetic power spectrum
33+
# Settings for creating a simulated power spectrum
3434
freq_range = [3, 40] # The frequency range to simulate
3535
aperiodic_params = [1, 1] # Parameters defining the aperiodic component
3636
gaussian_params = [10, 0.3, 1] # Parameters for any periodic components
3737

3838
###################################################################################################
3939

40-
# Generate a synthetic power spectrum
40+
# Generate a simulated power spectrum
4141
fs, ps = gen_power_spectrum(freq_range, aperiodic_params, gaussian_params)
4242

4343
###################################################################################################
4444

45-
# Plot the synthetic power spectrum
45+
# Plot the simulated power spectrum
4646
plot_spectrum(fs, ps, log_freqs=True, log_powers=False)
4747

4848
###################################################################################################
4949
# Simulating With Different Parameters
5050
# ------------------------------------
5151
#
52-
# Power spectra can be synthesized with any desired parameters for the FOOOF power spectra model.
52+
# Power spectra can be simulated with any desired parameters for the FOOOF power spectra model.
5353
#
5454
# The aperiodic mode for the simulated power spectrum is inferred from the parameters provided.
5555
# If two parameters are provided, this is interpreted as [offset, exponent] for simulating
@@ -67,19 +67,19 @@
6767

6868
###################################################################################################
6969

70-
# Set up new settings for creating a different synthetic power spectrum
70+
# Set up new settings for creating a different simulated power spectrum
7171
freq_range = [1, 60]
7272
aperiodic_params = [1, 500, 2] # Specify three values as [offset, knee, exponent]
7373
gaussian_params = [9, 0.4, 1, 24, 0.2, 3] # Add peaks - can also be [[9, 0.4, 1], [24, 0.2, 3]]
7474
nlv = 0.01 # The amount of noise to add to the spectrum
7575
freq_res = 0.25 # Specific the frequency resolution to simulate
7676

77-
# Generate the new synthetic power spectrum
77+
# Generate the new simulated power spectrum
7878
fs, ps = gen_power_spectrum(freq_range, aperiodic_params, gaussian_params, nlv, freq_res)
7979

8080
###################################################################################################
8181

82-
# Plot the new synthetic power spectrum
82+
# Plot the new simulated power spectrum
8383
plot_spectrum(fs, ps, log_powers=True)
8484

8585
###################################################################################################
@@ -100,7 +100,7 @@
100100

101101
###################################################################################################
102102

103-
# Create some new settings for synthesizing a group of power spectra
103+
# Create some new settings for simulating a group of power spectra
104104
n_spectra = 2
105105
freq_range = [3, 40]
106106
ap_params = [[0.5, 1], [1, 1.5]]
@@ -109,8 +109,8 @@
109109

110110
###################################################################################################
111111

112-
# Synthesize a group of power spectra
113-
fs, ps, syn_params = gen_group_power_spectra(n_spectra, freq_range, ap_params, gauss_params, nlv)
112+
# Simulate a group of power spectra
113+
fs, ps, sim_params = gen_group_power_spectra(n_spectra, freq_range, ap_params, gauss_params, nlv)
114114

115115
###################################################################################################
116116

@@ -119,8 +119,8 @@
119119

120120
###################################################################################################
121121
#
122-
# Note that when you simulate a group of power spectra, FOOOF returns SynParam objects that
122+
# Note that when you simulate a group of power spectra, FOOOF returns SimParam objects that
123123
# keep track of the simulations. This, and other utilties to manage parameters and provide
124-
# parameter definitions for synthesizing groups of power spectra are covered in the
125-
# `Synthetic Parameters` example.
124+
# parameter definitions for simulating groups of power spectra are covered in the
125+
# `Simulated Parameters` example.
126126
#

examples/plot_transforms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
###################################################################################################
99

1010
# Imports
11-
from fooof.synth.gen import gen_power_spectrum
12-
from fooof.synth.transform import rotate_spectrum
11+
from fooof.sim.gen import gen_power_spectrum
12+
from fooof.sim.transform import rotate_spectrum
1313

1414
from fooof.plts.spectra import plot_spectra
1515

1616
###################################################################################################
1717

18-
# Generate a synthetic power spectrum
18+
# Generate a simulated power spectrum
1919
fs, ps = gen_power_spectrum([3, 40], [1, 1], [10, 0.5, 1])
2020

2121
###################################################################################################

fooof/analysis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_band_peak_fm(fm, band, ret_one=True, attribute='peak_params'):
2929
return get_band_peak(getattr(fm, attribute + '_'), band, ret_one)
3030

3131

32-
def get_band_peaks_fg(fg, band, attribute='peak_params'):
32+
def get_band_peak_fg(fg, band, attribute='peak_params'):
3333
"""Extract peaks from a band of interest from a FOOOF object.
3434
3535
Parameters
@@ -47,10 +47,10 @@ def get_band_peaks_fg(fg, band, attribute='peak_params'):
4747
Peak data. Each row is a peak, as [CF, Amp, BW].
4848
"""
4949

50-
return get_band_peaks_group(fg.get_all_data(attribute), band, len(fg))
50+
return get_band_peak_group(fg.get_params(attribute), band, len(fg))
5151

5252

53-
def get_band_peaks_group(peak_params, band, n_fits):
53+
def get_band_peak_group(peak_params, band, n_fits):
5454
"""Extracts peaks within a given band of interest.
5555
5656
Parameters

0 commit comments

Comments
 (0)