specparam.sim.sim_power_spectrum

specparam.sim.sim_power_spectrum(freq_range, aperiodic_params, periodic_params, nlv=0.005, freq_res=0.5, f_rotation=None, return_params=False)[source]

Simulate a power spectrum.

Parameters:
freq_rangelist of [float, float]

Frequency range to simulate power spectrum across, as [f_low, f_high], inclusive.

aperiodic_paramsdict of {strarray}

Mode definition and parameters to create the aperiodic component of a power spectrum. Should be organized as {mode : params}, where mode is a string label for a mode to simulate with and params is a set of parameter values of length aperiodic_mode.n_params.

periodic_paramsdict of {strlist of float or list of list of float}

Mode definition and parameters to create the periodic component of a power spectrum. Should be organized as {mode : params}, where mode is a string label for a mode to simulate with and params corresponds to the number of desired peaks, with a total number of values matching periodic_mode.n_params * n_peaks. This can can be a flat list (ex: [10, 1, 1, 20, 0.5, 1]) or be grouped into a list of lists (ex: [[10, 1, 1], [20, 0.5, 1]]).

nlvfloat, optional, default: 0.005

Noise level to add to generated power spectrum.

freq_resfloat, optional, default: 0.5

Frequency resolution for the simulated power spectrum.

f_rotationfloat, optional

Frequency value, in Hz, to rotate around. Should only be set if spectrum is to be rotated. Can only be used with powerlaw aperiodic mode.

return_paramsbool, optional, default: False

Whether to return the parameters for the simulated spectrum.

Returns:
freqs1d array

Frequency values, in linear spacing.

powers1d array

Power values, in linear spacing.

sim_paramsSimParams

Definition of parameters used to create the spectrum. Only returned if return_params is True.

Notes

  • See check_modes for more information on the available modes to use to simulate, as well as descriptions of the parameters for each mode.

Rotating Power Spectra:

  • For the powerlaw aperiodic component only, you can optionally specify a rotation frequency, such that power spectra will be simulated and rotated around that point to the specified aperiodic exponent. Any power spectra simulated with the same rotation frequency will relate to each other by having the specified rotation point.

  • Note that rotating power spectra changes the offset. If a simulated spectrum is rotated, the returned spectrum will NOT have the offset of the input parameters, and will instead have offset value required to create the given aperiodic exponent with the requested rotation point. If you return SimParams, the recorded offset will be the calculated offset of the data post rotation, and not the entered value.

Examples

Generate a power spectrum with a single peak, at 10 Hz:

>>> freqs, powers = sim_power_spectrum([1, 50], {'fixed' : [0, 2]},
...                                    {'gaussian' : [10, 0.5, 1]})

Generate a power spectrum with alpha and beta peaks:

>>> freqs, powers = sim_power_spectrum([1, 50], {'fixed' : [0, 2]},
...                                    {'gaussian' : [[10, 0.5, 1], [20, 0.5, 1]]})

Generate a power spectrum, that was rotated around a particular frequency point:

>>> freqs, powers = sim_power_spectrum([1, 50], {'fixed' : [None, 2]},
...                                    {'gaussian' : [10, 0.5, 1]}, f_rotation=15)

Examples using specparam.sim.sim_power_spectrum

Dealing with Line Noise

Dealing with Line Noise

Exporting Model Results

Exporting Model Results

Manipulating Objects

Manipulating Objects

Aperiodic Parameters

Aperiodic Parameters

Exploring Data Components

Exploring Data Components

Frequency-by-Frequency Errors

Frequency-by-Frequency Errors

Periodic Parameters

Periodic Parameters

Plot Power Spectrum Models

Plot Power Spectrum Models

Plot Power Spectra

Plot Power Spectra

Custom Algorithms

Custom Algorithms

Custom Metrics

Custom Metrics

Custom Modes

Custom Modes

Model Sub-Objects

Model Sub-Objects

Simulation Parameters

Simulation Parameters

Simulating Neural Power Spectra

Simulating Neural Power Spectra

Transforming Power Spectra

Transforming Power Spectra

01: Model Description

01: Model Description

10: Tuning & Troubleshooting

10: Tuning & Troubleshooting

12: Reporting & Referencing

12: Reporting & Referencing

Band-by-Band

Band-by-Band

Band Ratio Measures

Band Ratio Measures

Conflating Periodic & Aperiodic Changes

Conflating Periodic & Aperiodic Changes