Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lower bound peak inconsistency #244

@SomeUserName1

Description

@SomeUserName1

Hi,

the following warning is very confusing to me as it contains a logically false statement:

FOOOF WARNING: Skipping frequency == 0, as this causes a problem with fitting.

FOOOF WARNING: Lower-bound peak width limit is < or ~= the frequency resolution: 97.66 <= 0.50
	Lower bounds below frequency-resolution have no effect (effective lower bound is the frequency resolution).
	Too low a limit may lead to overfitting noise as small bandwidth peaks.
	We recommend a lower bound of approximately 2x the frequency resolution.

Obviously 97.66 > 0.50. Maybe the error message is wrong and should be 99.76 > 12 and about the upper bound.

Context:
I'm analyzing LFPs recorded of a slice stimulated chemically with NMDA and recorded with a 252-electrode MEA with an electrode distance of 200 mu.

Code to exec FOOOF:

def show_periodic_aperiodic_decomp(data):
    fms = []
    for idx in range(data.data.shape[0]):
        fms.append(compute_periodic_aperiodic_decomp(data.data[idx], data.sampling_rate))

    np.array(fms)
    names = get_selected_electrode_names(data)

    proc = Process(target=plot_periodic_aperiodic_decomp, args=(fms, names, len(data.selected_rows)))
    proc.start()

def compute_periodic_aperiodic_decomp(data_row, fs):
    fm = FOOOF(aperiodic_mode='knee')
    psd = sg.welch(data_row, fs=fs)
    fm.add_data(psd[0], psd[1])
    fm.fit()

    return fm

plotting code (for completeness):

def plot_periodic_aperiodic_decomp(fms, names, n_electrodes):
    use('TkAgg')

    grid_sz = int(np.ceil(np.sqrt(n_electrodes)))
    fig, ax_array = plt.subplots(grid_sz, grid_sz, sharey=True, sharex=True)
    if grid_sz == 1:
        ax_array = np.atleast_2d(ax_array)

    for i in range(grid_sz):
        if i * grid_sz >= n_electrodes:
            break

        for j in range(grid_sz):
            if i * grid_sz + j >= n_electrodes:
                break

            fms[i * grid_sz + j].plot(plot_aperiodic=True, plot_peaks='shade', plt_log=False, ax=ax_array[i, j])
            ax_array[i, j].legend(loc='upper right')

    fig.tight_layout()
    plt.show()
    plt.close()

Attached is a 5s snipped of an LFP, the corresponding PSD and what FOOOF spits out.

fooof
psd
raw

Should I adjust the upper limit?

Am I doing sth. else wrong?

Thanks in advance & cheers,
Fabian

Metadata

Metadata

Assignees

No one assigned

    Labels

    answeredReflects a question that has been answered (left open for response / but can close soon)question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions