This tutorial covers :mod:`neurodsp.sim.aperiodic` """ ################################################################################################### from neurodsp import sim, spectral from neurodsp.utils import create_times from neurodsp.plts.spectral import plot_power_spectra from neurodsp.plts.time_series import plot_time_series ################################################################################################### # Set the random seed, for consistency simulating data sim.set_random_seed(0) # Set some general settings, to be used across all simulations fs = 1000 n_seconds = 10 ################################################################################################### # # Simulate 1/f Activity # --------------------- # # Often, we want to simulate noise that is comparable to what we see in neural recordings. # # Neural signals display 1/f-like activity, whereby power decreases linearly across # increasing frequencies, when plotted in log-log. #
# Simulating Data # ~~~~~~~~~~~~~~~ # # We will use simulated data for this example, to create some example aperiodic signals, # that we can then apply filters to. First, let's simulate some data. # ################################################################################################### # Simulation settings s_rate = 1000 n_seconds = 4 times = create_times(n_seconds, s_rate) # Set random seed, for consistency generating simulated data set_random_seed(21) ################################################################################################### # Simulate a signal of aperiodic activity: pink noise sig = sim_powerlaw(n_seconds, s_rate, exponent=-1) ################################################################################################### # Plot our simulated time series plot_time_series(times, sig) ################################################################################################### # Filtering Aperiodic Signals # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# Import burst detection functions from neurodsp.burst import detect_bursts_dual_threshold, compute_burst_stats # Import simulation code for creating test data from neurodsp.sim import set_random_seed, sim_combined from neurodsp.utils import create_times # Import utilities for loading and plotting data from neurodsp.utils.download import load_ndsp_data from neurodsp.plts.time_series import plot_time_series, plot_bursts ################################################################################################### # Set the random seed, for consistency simulating data set_random_seed(0) ################################################################################################### # Simulate a Bursty Oscillation # ----------------------------- # # First, we'll simulate a combined signal with a bursty oscillation in the alpha range, # with an aperiodic component. # ################################################################################################### # Simulation settings fs = 1000 n_seconds = 5
# sphinx_gallery_thumbnail_number = 3 # Import numpy import numpy as np # Use NeuroDSP for time series simulations & analyses from neurodsp import sim from neurodsp.utils import create_times from neurodsp.spectral import compute_spectrum_welch from neurodsp.plts import plot_time_series, plot_power_spectra ################################################################################################### # Set random seed, for consistency generating simulated data sim.set_random_seed(21) # Simulation Settings n_seconds = 2 s_rate = 1000 # Compute an array of time values, for plotting, and check length of data times = create_times(n_seconds, s_rate) n_points = len(times) ################################################################################################### # Frequency Representations of Aperiodic Signals # ---------------------------------------------- # # Let's start with aperiodic signals, and examine how different types of aperiodic # signals are represented in the frequency domain.