Skip to content

Commit

Permalink
update docs for sim name update
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed May 10, 2021
1 parent d9d34de commit 32c0d2f
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 115 deletions.
4 changes: 2 additions & 2 deletions examples/manage/plot_failed_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from specparam import PSDGroup

# Import simulation code to create test power spectra
from specparam.sim.gen import gen_group_power_spectra
from specparam.sim import sim_group_power_spectra

# Import FitError, which we will use to help debug model fit errors
from specparam.core.errors import FitError
Expand All @@ -36,7 +36,7 @@
###################################################################################################

# Simulate some example power spectra to use for the example
freqs, powers = gen_group_power_spectra(25, [1, 50], [1, 1], [10, 0.25, 3],
freqs, powers = sim_group_power_spectra(25, [1, 50], [1, 1], [10, 0.25, 3],
nlvs=0.1, freq_res=0.25)

###################################################################################################
Expand Down
9 changes: 5 additions & 4 deletions examples/manage/plot_fit_fooof_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
from specparam.objs import fit_models_3d, combine_model_objs

# Import simulation & IO utilities to help with the example
from specparam.sim.gen import gen_freqs, gen_group_power_spectra
from specparam.sim import sim_group_power_spectra
from specparam.sim.utils import create_freqs
from specparam.sim.params import param_sampler
from specparam.utils.io import load_group

Expand Down Expand Up @@ -89,18 +90,18 @@
# Set up the shape of the data
n_conditions = 3
n_channels = 10
n_freqs = len(gen_freqs(freq_range, freq_res))
n_freqs = len(create_freqs(freq_range, freq_res))

# Define parameters for the simulated power spectra
ap_opts = param_sampler([[0, 1.0], [0, 1.5], [0, 2]])
pe_opts = param_sampler([[], [10, 0.25, 1], [10, 0.25, 1, 20, 0.15, 1]])

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

# Generate some simulated power spectra, and organize into a 3D array
# Simulate power spectra, and organize into a 3D array
spectra = []
for ind in range(n_conditions):
freqs, powers = gen_group_power_spectra(n_channels, freq_range, ap_opts,
freqs, powers = sim_group_power_spectra(n_channels, freq_range, ap_opts,
pe_opts, freq_res=freq_res)
spectra.append(powers)

Expand Down
8 changes: 4 additions & 4 deletions examples/manage/plot_freq_by_freq_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from specparam import PSD, PSDGroup

# Import simulation utilities to create some test data
from specparam.sim.gen import gen_power_spectrum, gen_group_power_spectra
from specparam.sim import sim_power_spectrum, sim_group_power_spectra

# Import functions to examine frequency-by-frequency error of model fits
from specparam.analysis.error import compute_pointwise_error, compute_pointwise_error_group
Expand Down Expand Up @@ -53,7 +53,7 @@
###################################################################################################

# Simulate an example power spectrum
freqs, powers = gen_power_spectrum([3, 50], [1, 1], [10, 0.25, 0.5])
freqs, powers = sim_power_spectrum([3, 50], [1, 1], [10, 0.25, 0.5])

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

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

# Simulate a group of power spectra
freqs, powers = gen_group_power_spectra(10, [3, 50], [1, 1], [10, 0.3, 1], nlvs=0.1)
freqs, powers = sim_group_power_spectra(10, [3, 50], [1, 1], [10, 0.3, 1], nlvs=0.1)

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

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

# Simulate a group of power spectra, with a knee
freqs, powers = gen_group_power_spectra(10, [1, 50], [0, 10, 2],
freqs, powers = sim_group_power_spectra(10, [1, 50], [0, 10, 2],
[10, 0.3, 1], nlvs=0.01)

# Parameterize our new group of power spectra
Expand Down
8 changes: 4 additions & 4 deletions examples/manage/plot_manipulating_fooofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from specparam.objs.utils import average_group, combine_model_objs, compare_model_objs

# Import simulation functions to create our example data
from specparam.sim.gen import gen_power_spectrum
from specparam.sim import sim_power_spectrum

###################################################################################################
#
Expand All @@ -46,11 +46,11 @@
freq_res = 0.25

# Create some example power spectra
freqs, powers_1 = gen_power_spectrum(freq_range, [0, 1.0], [10, 0.25, 2],
freqs, powers_1 = sim_power_spectrum(freq_range, [0, 1.0], [10, 0.25, 2],
nlv=0.00, freq_res=freq_res)
freqs, powers_2 = gen_power_spectrum(freq_range, [0, 1.2], [9, 0.20, 1.5],
freqs, powers_2 = sim_power_spectrum(freq_range, [0, 1.2], [9, 0.20, 1.5],
nlv=0.01, freq_res=freq_res)
freqs, powers_3 = gen_power_spectrum(freq_range, [0, 1.5], [11, 0.3, 2.5],
freqs, powers_3 = sim_power_spectrum(freq_range, [0, 1.5], [11, 0.3, 2.5],
nlv=0.02, freq_res=freq_res)

###################################################################################################
Expand Down
8 changes: 4 additions & 4 deletions examples/plots/plot_fooof_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
from specparam import PSD

# Import simulation functions to create some example data
from specparam.sim.gen import gen_power_spectrum
from specparam.sim import sim_power_spectrum

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

# Generate an example power spectrum
freqs, powers = gen_power_spectrum([3, 50], [1, 1],
# Simulate an example power spectrum
freqs, powers = sim_power_spectrum([3, 50], [1, 1],
[[9, 0.25, 0.5], [22, 0.1, 1.5], [25, 0.2, 1.]])

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

# Simulate a new power spectrum, over a broader frequency region
freqs, powers = gen_power_spectrum([1, 150], [0, 10, 1.5],
freqs, powers = sim_power_spectrum([1, 150], [0, 10, 1.5],
[[4, 0.25, 1], [12, 0.2, 1.5], [25, 0.1, 2]])

###################################################################################################
Expand Down
6 changes: 3 additions & 3 deletions examples/plots/plot_model_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from specparam.analysis import get_band_peak_group

# Import simulation utilities for making example data
from specparam.sim.gen import gen_group_power_spectra
from specparam.sim import sim_group_power_spectra
from specparam.sim.params import param_jitter

# Import plotting function for model parameters and components
Expand Down Expand Up @@ -60,8 +60,8 @@
###################################################################################################

# Simulate some test data, as two groups of power spectra
freqs, powers1 = gen_group_power_spectra(n_subjs, freq_range, g1_aps, g1_peaks)
freqs, powers2 = gen_group_power_spectra(n_subjs, freq_range, g2_aps, g2_peaks)
freqs, powers1 = sim_group_power_spectra(n_subjs, freq_range, g1_aps, g1_peaks)
freqs, powers2 = sim_group_power_spectra(n_subjs, freq_range, g2_aps, g2_peaks)

###################################################################################################
# Fit Power Spectrum Models
Expand Down
10 changes: 5 additions & 5 deletions examples/plots/plot_power_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from specparam.plts.spectra import plot_spectra, plot_spectra_shading

# Import simulation utilities for creating test data
from specparam.sim.gen import gen_power_spectrum, gen_group_power_spectra
from specparam.sim import sim_power_spectrum, sim_group_power_spectra
from specparam.sim.params import param_iter, Stepper

###################################################################################################
Expand Down Expand Up @@ -49,8 +49,8 @@
peaks = [[6, 0.2, 1], [10, 0.3, 1], [25, 0.15, 3]]

# Simulate two example power spectra
freqs, powers1 = gen_power_spectrum(freq_range, ap_1, peaks)
freqs, powers2 = gen_power_spectrum(freq_range, ap_2, peaks)
freqs, powers1 = sim_power_spectrum(freq_range, ap_1, peaks)
freqs, powers2 = sim_power_spectrum(freq_range, ap_2, peaks)

###################################################################################################
# Plotting Individual Power Spectra
Expand Down Expand Up @@ -142,12 +142,12 @@
ap_params = [1, 1]

# Simulate a single 10 Hz centered alpha
freqs_al10, powers_al10 = gen_power_spectrum(freq_range, ap_params,
freqs_al10, powers_al10 = sim_power_spectrum(freq_range, ap_params,
[10, 0.25, 1], nlv=0)

# Simulate spectra stepping across alpha center frequency
cf_steps = Stepper(8, 12.5, 0.5)
freqs_al, powers_al = gen_group_power_spectra(len(cf_steps), freq_range, ap_params,
freqs_al, powers_al = sim_group_power_spectra(len(cf_steps), freq_range, ap_params,
param_iter([cf_steps, 0.25, 1]))

###################################################################################################
Expand Down
12 changes: 6 additions & 6 deletions examples/processing/plot_line_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from specparam.utils import trim_spectrum, interpolate_spectrum

# Import simulation functions to create some example data
from specparam.sim.gen import gen_power_spectrum
from specparam.sim import sim_power_spectrum

# Import NeuroDSP functions for simulating & processing time series
from neurodsp.sim import sim_combined
Expand Down Expand Up @@ -45,11 +45,11 @@

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

# Generate an example power spectrum, with line noise
freqs1, powers1 = gen_power_spectrum([3, 75], [1, 1],
# Simulate an example power spectrum, with line noise
freqs1, powers1 = sim_power_spectrum([3, 75], [1, 1],
[[10, 0.75, 2], [60, 1, 0.5]])

# Visualize the generated power spectrum
# Visualize the simulated power spectrum
plot_spectra(freqs1, powers1, log_powers=True)

###################################################################################################
Expand Down Expand Up @@ -97,8 +97,8 @@

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

# Generate an example power spectrum, with line noise & harmonics
freqs2, powers2 = gen_power_spectrum([1, 150], [1, 500, 1.5],
# Simulate an example power spectrum, with line noise & harmonics
freqs2, powers2 = sim_power_spectrum([1, 150], [1, 500, 1.5],
[[10, 0.5, 2], [60, 0.75, 0.5], [120, 0.5, 0.5]])

# Interpolate away the line noise region & harmonics
Expand Down
26 changes: 13 additions & 13 deletions examples/sims/plot_sim_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
###################################################################################################

# Import simulation functions for creating spectra
from specparam.sim.gen import gen_power_spectrum, gen_group_power_spectra
from specparam.sim import sim_power_spectrum, sim_group_power_spectra

# Import simulation utilities for managing parameters
from specparam.sim.params import param_sampler, param_iter, param_jitter, Stepper
Expand Down Expand Up @@ -49,7 +49,7 @@
###################################################################################################

# Simulate a group of power spectra
freqs, powers, sim_params = gen_group_power_spectra(n_spectra, freq_range, ap_params,
freqs, powers, sim_params = sim_group_power_spectra(n_spectra, freq_range, ap_params,
pe_params, nlv, return_params=True)

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

# You can also use a SimParams object to regenerate a particular power spectrum
cur_params = sim_params[0]
freqs, powers = gen_power_spectrum(freq_range, *cur_params)
freqs, powers = sim_power_spectrum(freq_range, *cur_params)

###################################################################################################
# Managing Parameters
Expand Down Expand Up @@ -98,12 +98,12 @@

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

# Generate some power spectra, using param_sampler
freqs, powers = gen_group_power_spectra(10, freq_range, ap_opts, pe_opts)
# Simualte some power spectra, using param_sampler
freqs, powers = sim_group_power_spectra(10, freq_range, ap_opts, pe_opts)

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

# Plot some of the spectra that were generated
# Plot some of the spectra that were simulated
plot_spectra(freqs, powers[0:4, :], log_powers=True)

###################################################################################################
Expand Down Expand Up @@ -133,12 +133,12 @@

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

# Generate some power spectra, using param_iter
freqs, powers = gen_group_power_spectra(len(cf_steps), freq_range, ap_params, pe_params)
# Simulate some power spectra, using param_iter
freqs, powers = sim_group_power_spectra(len(cf_steps), freq_range, ap_params, pe_params)

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

# Plot the generated spectra
# Plot the simulated spectra
plot_spectra(freqs, powers, log_freqs=True, log_powers=True)

###################################################################################################
Expand All @@ -161,16 +161,16 @@

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

# Generate some power spectra, using param_jitter
freqs, powers = gen_group_power_spectra(5, freq_range, ap_params, pe_params)
# Simulate some power spectra, using param_jitter
freqs, powers = sim_group_power_spectra(5, freq_range, ap_params, pe_params)

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

# Plot the generated spectra
# Plot the simulated spectra
plot_spectra(freqs, powers, log_freqs=True, log_powers=True)

###################################################################################################
#
# We can see that in the generated spectra above, there is some jitter
# We can see that in the simulated spectra above, there is some jitter
# to the simulated aperiodic exponent values.
#
28 changes: 14 additions & 14 deletions examples/sims/plot_simulated_power_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
###################################################################################################

# Import functions for creating simulated power spectra
from specparam.sim.gen import gen_power_spectrum, gen_group_power_spectra
from specparam.sim import sim_power_spectrum, sim_group_power_spectra

# Import plotting functions
from specparam.plts.spectra import plot_spectra
Expand All @@ -32,7 +32,7 @@
#
# - each peak is defined with three parameters, as [center frequency, height, width]
#
# The :func:`~.gen_power_spectrum` function takes these parameters as input to
# The :func:`~.sim_power_spectrum` function takes these parameters as input to
# create and return a simulated power spectrum. Note that the parameters that define the peaks
# are labeled as gaussian parameters, as these parameters define the simulated gaussians
# directly, and are not the modified peak parameters that the model outputs.
Expand All @@ -47,8 +47,8 @@

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

# Generate a simulated power spectrum
freqs, powers = gen_power_spectrum(freq_range, aperiodic_params, periodic_params)
# Simulate a power spectrum
freqs, powers = sim_power_spectrum(freq_range, aperiodic_params, periodic_params)

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

Expand Down Expand Up @@ -93,8 +93,8 @@

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

# Generate the new simulated power spectrum
freqs, powers = gen_power_spectrum(freq_range, aperiodic_params,
# Simulate the new power spectrum
freqs, powers = sim_power_spectrum(freq_range, aperiodic_params,
periodic_params, nlv, freq_res)

###################################################################################################
Expand All @@ -106,16 +106,16 @@
# Simulating a Group of Power Spectra
# -----------------------------------
#
# For simulating multiple power spectra, the :func:`~.gen_group_power_spectra` can be used.
# For simulating multiple power spectra, the :func:`~.sim_group_power_spectra` can be used.
#
# This function takes the same kind of parameter definitions as
# :func:`~.gen_power_spectrum`, and in addition takes a number specifying
# :func:`~.sim_power_spectrum`, and in addition takes a number specifying
# how many power spectra to simulate, returning a 2D matrix containing the
# desired number of spectra.
#
# Parameters that are passed into :func:`~.gen_group_power_spectra` can be:
# Parameters that are passed into :func:`~.sim_group_power_spectra` can be:
#
# - a single definition, whereby the same value is used for all generated spectra
# - a single definition, whereby the same value is used for all simulated spectra
# - a list of parameters, whereby each successive entry is used for each successive spectrum
# - a function or generator that can be called to return parameters for each spectrum
#
Expand All @@ -136,12 +136,12 @@
###################################################################################################

# Simulate a group of power spectra
freqs, powers = gen_group_power_spectra(n_spectra, freq_range, aperiodic_params,
freqs, powers = sim_group_power_spectra(n_spectra, freq_range, aperiodic_params,
periodic_params, nlv)

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

# Plot the power spectra that were just generated
# Plot the power spectra that were just simulated
plot_spectra(freqs, powers, log_freqs=True, log_powers=True)

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

# Simulate a power spectrum, returning the simulation parameter information
freqs, powers, sp = gen_power_spectrum([1, 50], [1, 1], [10, 0.25, 1.5],
freqs, powers, sp = sim_power_spectrum([1, 50], [1, 1], [10, 0.25, 1.5],
0.01, return_params=True)

# Check the information stored in the simulation params object
Expand All @@ -168,7 +168,7 @@
###################################################################################################

# Simulate a group of power spectrum, returning the simulation parameter information
freqs, powers, sps = gen_group_power_spectra(3, [1, 150], [1, 100, 150],
freqs, powers, sps = sim_group_power_spectra(3, [1, 150], [1, 100, 150],
[4, 0.2, 2, 22, 0.15, 3],
0.01, return_params=True)

Expand Down
Loading

0 comments on commit 32c0d2f

Please sign in to comment.