Skip to content

[BUG] sim_oscillation bug in power spectrum #223

@ryanhammonds

Description

@ryanhammonds

I was simulating sine waves and computing spectra:

from neurodsp.spectral import compute_spectrum
from neurodsp.plts import plot_time_series, plot_power_spectra
from neurodsp.utils import create_times
from neurodsp.sim import sim_oscillation

n_seconds = 10
fs = 1000

times = create_times(n_seconds, fs)
sig_8hz = sim_oscillation(n_seconds, fs, 8)
sig_9hz = sim_oscillation(n_seconds, fs, 9)

freqs_8hz, spec_8hz = compute_spectrum(sig_8hz, fs)
freqs_9hz, spec_9hz = compute_spectrum(sig_9hz, fs)

plot_power_spectra(freqs_8hz, spec_8hz, title='8hz')
plot_power_spectra(freqs_9hz, spec_9hz, title='9hz')

And noticed strange spectra for odd freq waves:
spec

@rdgao Tracked this down to this line cycle = sim_cycle(n_seconds_cycle, fs, cycle, **cycle_params) in sim_oscillation and an interaction with sampling rate. When fs is increased to a large value, the odd spectra are corrected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions