From d7e3d2893daeddde991ca0018a4ff09ba34568dd Mon Sep 17 00:00:00 2001 From: ryanhammonds Date: Fri, 5 Feb 2021 15:54:46 -0800 Subject: [PATCH] move warning to note --- neurodsp/sim/periodic.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/neurodsp/sim/periodic.py b/neurodsp/sim/periodic.py index 26e627a7..3d76c01f 100644 --- a/neurodsp/sim/periodic.py +++ b/neurodsp/sim/periodic.py @@ -1,6 +1,5 @@ """Simulating time series, with periodic activity.""" -import warnings from itertools import repeat import numpy as np @@ -39,6 +38,13 @@ def sim_oscillation(n_seconds, fs, freq, cycle='sine', phase=0, **cycle_params): sig : 1d array Simulated oscillation. + Notes + ----- + When `freq` and `fs` are not evenly divisible, there will non-integer number of samples + per cycle. In the frequency domain, this can lead to power in non-simulated frequencies in the + power spectrum. Consider updating ``freq and ``fs`` to an integer divisor/multiple when + investigating spectral properties. + Examples -------- Simulate a continuous sinusoidal oscillation at 5 Hz: @@ -51,9 +57,6 @@ def sim_oscillation(n_seconds, fs, freq, cycle='sine', phase=0, **cycle_params): ... cycle='asine', phase=0.5, rdsym=0.75) """ - # Check if tiling can produce full oscillations - _check_tiling(fs, freq) - # Figure out how many cycles are needed for the signal n_cycles = int(np.ceil(n_seconds * freq)) @@ -154,9 +157,6 @@ def sim_bursty_oscillation(n_seconds, fs, freq, burst_def='prob', burst_params={ if burst_def == 'prob' and burst_param not in burst_params: burst_params[burst_param] = temp - # Check if tiling can produce full oscillations - _check_tiling(fs, freq) - # Simulate a normalized cycle to use for bursts n_seconds_cycle = 1/freq osc_cycle = sim_normalized_cycle(n_seconds_cycle, fs, cycle, **cycle_params) @@ -310,15 +310,3 @@ def get_burst_samples(is_oscillating, fs, freq): bursts = np.repeat(is_oscillating, n_samples_cycle) return bursts - - -def _check_tiling(fs, freq): - """Check if tiling will produce an integer number of cycles for the simulated oscillation.""" - - if not (fs/freq).is_integer(): - - warnings.warn(''' - The settings for the frequency and sampling rate are not evenly divisible. In the frequency - domain, this can lead to power in non-simulated frequencies in the power spectrum. Consider - updating freq and fs to an integer divisor/multiple pair." - ''', category=RuntimeWarning)