Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8bcf8a8
Merge remote-tracking branch 'origin/master' into audit
TomDonoghue Feb 18, 2019
e23f54f
Update langauge in tests & fix plot_fg_bg name
TomDonoghue Feb 18, 2019
df7341e
Misc fixes
TomDonoghue Feb 18, 2019
26ed4f7
Linting
TomDonoghue Mar 1, 2019
9da4135
Linting related updates
TomDonoghue Mar 17, 2019
24b1b44
Make all test objects verbose=False, so they are not trying to print
TomDonoghue Mar 17, 2019
d94be5d
Merge branch 'master' into audit
TomDonoghue Mar 20, 2019
cc90f83
Change 'synth' -> 'sim'
TomDonoghue Mar 27, 2019
d26ee62
Synth -> sim in examples & tutorials
TomDonoghue Mar 27, 2019
dd93c31
Revert some name changes in analysis
TomDonoghue Apr 3, 2019
85d7264
Update synth & syn -> sim in functions
TomDonoghue Apr 7, 2019
9522506
SynParams -> SimParams
TomDonoghue Apr 7, 2019
1a0b476
Update tutorials & examples for Syn -> Sim
TomDonoghue Apr 7, 2019
938ebab
Extend some tests, & associated code updates
TomDonoghue Apr 7, 2019
c795b88
Small clean ups, systematize docs / headers
TomDonoghue Apr 7, 2019
182300b
Lint updates
TomDonoghue Apr 7, 2019
587d7a1
Update API listing for code updates
TomDonoghue Apr 7, 2019
029cf39
Fix tutorial with sim updates
TomDonoghue Apr 7, 2019
78065f8
DataInfo -> MetaData
TomDonoghue Apr 14, 2019
c49d93a
Fix BW warning string
TomDonoghue Apr 14, 2019
e0f3e28
Add get_data to FOOOF object
TomDonoghue Apr 14, 2019
217909b
Bump version to pre-release specifier
TomDonoghue Apr 16, 2019
347f4b2
Graduate '_gaussian_params' -> 'gaussian_params_', for consistency
TomDonoghue Apr 16, 2019
9df8a1f
Update some str func names, for consistency
TomDonoghue Apr 17, 2019
23857c0
Make and ->
TomDonoghue Apr 17, 2019
b14a840
Update core.info names
TomDonoghue Apr 17, 2019
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
40 changes: 27 additions & 13 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,25 @@ FOOOFGroup Object

FOOOFGroup

FOOOF Object Functions
----------------------
Bands
-----

.. currentmodule:: fooof.bands

.. autosummary::
:toctree: generated/

Bands

FOOOF Functions
---------------

.. currentmodule:: fooof.funcs

.. autosummary::
:toctree: generated/

average_fg
combine_fooofs
fit_fooof_group_3d

Expand All @@ -51,16 +62,20 @@ Analysis Functions
:toctree: generated/

get_band_peak
get_band_peak_fm
get_band_peak_fg
get_band_peak_group
get_highest_peak

Synth Code
----------
Sim Code
--------

Code & utilities for simulating power spectra.

Generating Power Spectra
~~~~~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: fooof.synth.gen
.. currentmodule:: fooof.sim.gen

.. autosummary::
:toctree: generated/
Expand All @@ -72,27 +87,28 @@ Generating Power Spectra
Parameter Management
~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: fooof.synth.params
.. currentmodule:: fooof.sim.params

.. autosummary::
:toctree: generated/

Stepper
param_iter
param_sampler
update_sim_ap_params

Transforming Power Spectra
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: fooof.synth.transform
.. currentmodule:: fooof.sim.transform

.. autosummary::
:toctree: generated/

translate_spectrum
translate_syn_spectrum
translate_sim_spectrum
rotate_spectrum
rotate_syn_spectrum
rotate_sim_spectrum
compute_rotation_offset

Plotting Functions
Expand All @@ -117,7 +133,5 @@ Utility Functions
:toctree: generated/

trim_spectrum
get_settings
get_data_info
compare_settings
compare_data_info
get_info
compare_info
8 changes: 4 additions & 4 deletions examples/plot_fit_fooof_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
# FOOOF imports
from fooof import FOOOFGroup
from fooof.funcs import fit_fooof_group_3d, combine_fooofs
from fooof.synth.gen import gen_group_power_spectra
from fooof.synth.params import param_sampler
from fooof.sim.gen import gen_group_power_spectra
from fooof.sim.params import param_sampler

###################################################################################################

# Settings for creating synthetic data
# Settings for creating simulated data
n_spectra = 10
freq_range = [3, 40]
ap_opts = param_sampler([[0, 1.0], [0, 1.5], [0, 2]])
gauss_opts = param_sampler([[], [10, 1, 1], [10, 1, 1, 20, 2, 1]])

###################################################################################################

# Generate some synthetic power spectra, and organize into a 3D matrix
# Generate some simulated power spectra, and organize into a 3D matrix
spectra = []
for ind in range(3):
fs, ps, _ = gen_group_power_spectra(n_spectra, freq_range, ap_opts, gauss_opts)
Expand Down
4 changes: 2 additions & 2 deletions examples/plot_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

###################################################################################################

# Create a couple synthetic power spectra to explore plotting with
# Create a couple simulated power spectra to explore plotting with
# Here we create two spectra, with different aperiodic components
# but each with the same oscillations (a theta, alpha & beta)
from fooof.synth.gen import gen_group_power_spectra
from fooof.sim.gen import gen_group_power_spectra
fs, ps, _ = gen_group_power_spectra(2, [3, 40], [[0.75, 1.5], [0.25, 1]],
[6, 0.2, 1, 10, 0.3, 1, 25, 0.15, 3])
ps1, ps2 = ps
Expand Down
34 changes: 17 additions & 17 deletions examples/plot_synth_params.py → examples/plot_sim_params.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
"""
Synthetic Parameters
Simulated Parameters
====================

Manage parameters for creating synthetic power spectra.
Manage parameters for creating simulated power spectra.
"""

###################################################################################################

# Import fooof functions for creating spectra and managing parameters
from fooof.synth.params import param_sampler, param_iter, Stepper
from fooof.synth.gen import gen_power_spectrum, gen_group_power_spectra
from fooof.sim.params import param_sampler, param_iter, Stepper
from fooof.sim.gen import gen_power_spectrum, gen_group_power_spectra

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

###################################################################################################
# SynParams
# SimParams
# ~~~~~~~~~
#
# When you synthesize multiple power spectra, FOOOF uses `SynParams` objects to
# When you simulate multiple power spectra, FOOOF uses `SimParams` objects to
# keep track of the parameters used for each power spectrum.
#
# SynParams objects are named tuples with the following fields:
# SimParams objects are named tuples with the following fields:
# - `aperiodic_params`
# - `gaussian_params`
# - `nlv`
#

###################################################################################################

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

###################################################################################################

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

###################################################################################################

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

###################################################################################################

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

###################################################################################################
Expand Down Expand Up @@ -83,7 +83,7 @@
###################################################################################################

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

###################################################################################################

Expand Down Expand Up @@ -113,7 +113,7 @@
###################################################################################################

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

###################################################################################################

Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
"""
Creating Synthetic Power Spectra
Creating Simulated Power Spectra
================================

Use FOOOF to create synthetic power spectra.
Use FOOOF to create simulated power spectra.
"""

###################################################################################################

# Import fooof functions for creating synthetic power spectra
from fooof.synth.gen import gen_power_spectrum, gen_group_power_spectra
# Import fooof functions for creating simulated power spectra
from fooof.sim.gen import gen_power_spectrum, gen_group_power_spectra

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

###################################################################################################
# Creating Synthetic Power Spectra
# Creating Simulated Power Spectra
# --------------------------------
#
# FOOOF has utilities to create synthetic power spectra, whereby spectra
# FOOOF has utilities to create simulated power spectra, whereby spectra
# are simulated with an aperiodic component with overlying peaks,
# using specified parameters.
#
# The :func:`gen_power_spectrum` function can be used to synthesize a power
# The :func:`gen_power_spectrum` function can be used to simulate a power
# spectrum with specified parameters.
#
# Note that all FOOOF functions that synthesize power spectra take in
# Note that all FOOOF functions that simulate power spectra take in
# gaussian parameters, not the modified peak parameters.
#

###################################################################################################

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

###################################################################################################

# Generate a synthetic power spectrum
# Generate a simulated power spectrum
fs, ps = gen_power_spectrum(freq_range, aperiodic_params, gaussian_params)

###################################################################################################

# Plot the synthetic power spectrum
# Plot the simulated power spectrum
plot_spectrum(fs, ps, log_freqs=True, log_powers=False)

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

###################################################################################################

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

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

###################################################################################################

# Plot the new synthetic power spectrum
# Plot the new simulated power spectrum
plot_spectrum(fs, ps, log_powers=True)

###################################################################################################
Expand All @@ -100,7 +100,7 @@

###################################################################################################

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

###################################################################################################

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

###################################################################################################

Expand All @@ -119,8 +119,8 @@

###################################################################################################
#
# Note that when you simulate a group of power spectra, FOOOF returns SynParam objects that
# Note that when you simulate a group of power spectra, FOOOF returns SimParam objects that
# keep track of the simulations. This, and other utilties to manage parameters and provide
# parameter definitions for synthesizing groups of power spectra are covered in the
# `Synthetic Parameters` example.
# parameter definitions for simulating groups of power spectra are covered in the
# `Simulated Parameters` example.
#
6 changes: 3 additions & 3 deletions examples/plot_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
###################################################################################################

# Imports
from fooof.synth.gen import gen_power_spectrum
from fooof.synth.transform import rotate_spectrum
from fooof.sim.gen import gen_power_spectrum
from fooof.sim.transform import rotate_spectrum

from fooof.plts.spectra import plot_spectra

###################################################################################################

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

###################################################################################################
Expand Down
6 changes: 3 additions & 3 deletions fooof/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_band_peak_fm(fm, band, ret_one=True, attribute='peak_params'):
return get_band_peak(getattr(fm, attribute + '_'), band, ret_one)


def get_band_peaks_fg(fg, band, attribute='peak_params'):
def get_band_peak_fg(fg, band, attribute='peak_params'):
"""Extract peaks from a band of interest from a FOOOF object.

Parameters
Expand All @@ -47,10 +47,10 @@ def get_band_peaks_fg(fg, band, attribute='peak_params'):
Peak data. Each row is a peak, as [CF, Amp, BW].
"""

return get_band_peaks_group(fg.get_all_data(attribute), band, len(fg))
return get_band_peak_group(fg.get_params(attribute), band, len(fg))


def get_band_peaks_group(peak_params, band, n_fits):
def get_band_peak_group(peak_params, band, n_fits):
"""Extracts peaks within a given band of interest.

Parameters
Expand Down
Loading