コード例 #1
0
ファイル: utils.py プロジェクト: EdSheeranla/beapp
def default_group_params():
    """Create default parameters for generating a test group of power spectra."""

    freq_range = [3, 50]
    bgp_opts = param_sampler([[20, 2], [50, 2.5], [35, 1.5]])
    gauss_opts = param_sampler([[10, 0.5, 2], [10, 0.5, 2, 20, 0.3, 4]])

    return freq_range, bgp_opts, gauss_opts
コード例 #2
0
###############################################################################

# Reload some data and fit a FOOOF model to use
freqs = np.load('dat/freqs_lfp.npy')
spectrum = np.load('dat/spectrum_lfp.npy')
fm = FOOOF(peak_width_limits=[2, 8])
fm.fit(freqs, spectrum, [3, 30])

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

# Generate some synthetic power spectra and fit a FOOOFGroup to use
freqs, spectra, _ = gen_group_power_spectra(
    n_spectra=10,
    freq_range=[3, 40],
    background_params=param_sampler([[20, 2], [35, 1.5]]),
    gauss_params=param_sampler([[], [10, 0.5, 2]]))
fg = FOOOFGroup(peak_width_limits=[1, 8],
                min_peak_amplitude=0.05,
                max_n_peaks=6,
                verbose=False)
fg.fit(freqs, spectra)

###############################################################################
# FOOOF Analysis Utilities
# ------------------------
#
# FOOOF is packaged with minimal analysis utility functions.
#
# The plan is for the FOOOF module to stay this way, as supporting further analysis of FOOOF-derived results is largely outside the scope of the current module.
#
コード例 #3
0
# - Check your data, across the frequency range of interest, for what the aperiodic signal looks like.
#     - If it looks roughly linear (in log-log space), fit without a knee.
#         - This is likely across smaller frequency ranges, such as 3-30.
#         - Do not perform no-knee fits across a range in which this does not hold.
#     - If there is a clear knee, then use knee fits.
#         - This is likely across larger fitting ranges such as 1-150 Hz.
# - Be wary of ambiguous ranges, where there may or may not be a knee.
#     - Trying to fit without a knee, when there is not a single consistent aperiodic signal, can lead to very bad fits. But it is also a known issue that trying to fit with a knee can lead to suboptimal fits when no knee is present.
#         - We therefore currently recommend picking frequency ranges in which the expected aperiodic signal process is relatively clear.

###############################################################################
# Checking Fits Across a Group
# ----------------------------

# Set the parameters options for aperiodic signal and Gaussian peaks
bgp_opts = param_sampler([[20, 2], [50, 2.5], [35, 1.5]])
gauss_opts = param_sampler([[], [10, 0.5, 2], [10, 0.5, 2, 20, 0.3, 4]])

# Generate a group of power spectra
freqs, power_spectra, syn_params = gen_group_power_spectra(10, [3, 50], bgp_opts, gauss_opts)

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

# Initialize a FOOOFGroup
fg = FOOOFGroup(peak_width_limits=[1, 6])

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

# Fit FOOOF and report on the group
fg.report(freqs, power_spectra)