API Documentation

This is the API reference for the neurodsp module.

Table of Contents

Filtering

Functions and utilities in the filt module, for filtering time series.

General Filter Function

filter_signal(sig, fs, pass_type, f_range[, …])

Apply a bandpass, bandstop, highpass, or lowpass filter to a neural signal.

FIR Filters

filter_signal_fir(sig, fs, pass_type, f_range)

Apply an FIR filter to a signal.

design_fir_filter(fs, pass_type, f_range[, …])

Design an FIR filter.

IIR Filters

filter_signal_iir(sig, fs, pass_type, …[, …])

Apply an IIR filter to a signal.

design_iir_filter(fs, pass_type, f_range, …)

Design an IIR filter.

Check Filter Properties

check_filter_definition(pass_type, f_range)

Check a filter definition for validity, and get filter frequency range of the filter.

check_filter_properties(filter_coefs, …[, …])

Check a filters properties, including pass band and transition band.

Filter Utilities

compute_frequency_response(filter_coefs, …)

Compute the frequency response of a filter.

compute_pass_band(fs, pass_type, f_range)

Compute the pass bandwidth of a filter.

compute_transition_band(f_db, db[, low, high])

Compute transition bandwidth of a filter.

compute_nyquist(fs)

Compute the Nyquist frequency.

remove_filter_edges(sig, filt_len)

Drop the edges, by making NaN, from a filtered signal, to avoid edge artifacts.

Time-Frequency Analyses

Functions and utilities in the timefrequency module, for time-frequency analyses.

Hilbert Methods

robust_hilbert(sig[, increase_n])

Compute the Hilbert transform, ignoring any boundaries that are NaN.

phase_by_time(sig, fs[, f_range, …])

Compute the instantaneous phase of a time series.

amp_by_time(sig, fs[, f_range, …])

Compute the instantaneous amplitude of a time series.

freq_by_time(sig, fs[, f_range, …])

Compute the instantaneous frequency of a time series.

Wavelet Methods

compute_wavelet_transform(sig, fs, freqs[, …])

Compute the time-frequency representation of a signal using morlet wavelets.

convolve_wavelet(sig, fs, freq[, n_cycles, …])

Convolve a signal with a complex wavelet.

Spectral Analyses

Functions and utilities in the spectral module, for spectral analyses.

Spectral Power Measures

compute_spectrum(sig, fs[, method, avg_type])

Compute the power spectral density of a time series.

compute_spectrum_welch(sig, fs[, avg_type, …])

Compute the power spectral density using Welch’s method.

compute_spectrum_wavelet(sig, fs, freqs[, …])

Compute the power spectral density using wavelets.

compute_spectrum_medfilt(sig, fs[, …])

Compute the power spectral density as a smoothed FFT.

Spectral Variance Measures

compute_scv(sig, fs[, window, nperseg, …])

Compute the spectral coefficient of variation (SCV) at each frequency.

compute_scv_rs(sig, fs[, window, nperseg, …])

Compute a resampled version of the spectral coefficient of variation (SCV).

compute_spectral_hist(sig, fs[, window, …])

Compute the distribution of log10 power at each frequency from the signal spectrogram.

Spectral Utilities

trim_spectrum(freqs, power_spectra, f_range)

Extract a frequency range of interest from power spectra.

trim_spectrogram(freqs, times, spg[, …])

Extract a frequency or time range of interest from a spectrogram.

rotate_powerlaw(freqs, spectrum, delta_exponent)

Rotate the power law exponent of a power spectrum.

Burst Detection

Functions and utilities in the burst module, for detection bursts in time series.

Burst Detection Algorithms

detect_bursts_dual_threshold(sig, fs, …[, …])

Detect bursts in a signal using the dual threshold algorithm.

Burst Utilities

compute_burst_stats(bursting, fs)

Compute statistics of bursts.

Rhythm Analyses

Functions and utilities in the rhythm module, for finding and analyzing rhythmic and recurring patterns in time series.

Sliding Window Matching

sliding_window_matching(sig, fs, win_len, …)

Find recurring patterns in a time series using the sliding window matching algorithm.

Lagged Coherence

compute_lagged_coherence(sig, fs, freqs[, …])

Compute lagged coherence, reflecting the rhythmicity across a frequency range.

Aperiodic Analyses

Functions and utilities in the aperiodic module, for analyzing aperiodic activity in time series.

Simulations

Functions and utilities in the sim module, for simulating time series.

Periodic Signals

sim_oscillation(n_seconds, fs, freq[, …])

Simulate an oscillation.

sim_bursty_oscillation(n_seconds, fs, freq)

Simulate a bursty oscillation.

Aperiodic Signals

sim_powerlaw(n_seconds, fs[, exponent, f_range])

Simulate a power law time series, with a specified exponent.

sim_poisson_pop(n_seconds, fs[, n_neurons, …])

Simulate a Poisson population.

sim_synaptic_current(n_seconds, fs[, …])

Simulate a signal as a synaptic current, which has 1/f characteristics with a knee.

sim_random_walk(n_seconds, fs[, theta, mu, …])

Simulate a mean-reverting random walk, as an Ornstein-Uhlenbeck process.

Transients & Cycles

sim_synaptic_kernel(n_seconds, fs, tau_r, tau_d)

Simulate a synaptic kernel with specified time constants.

sim_cycle(n_seconds, fs, cycle_type, …)

Simulate a single cycle of a periodic pattern.

sim_sine_cycle(n_seconds, fs)

Simulate a cycle of a sine wave.

sim_asine_cycle(n_seconds, fs, rdsym)

Simulate a cycle of an asymmetric sine wave.

sim_sawtooth_cycle(n_seconds, fs, width)

Simulate a cycle of a sawtooth wave.

sim_gaussian_cycle(n_seconds, fs, std)

Simulate a cycle of a gaussian.

Combined Signals

sim_combined(n_seconds, fs, components[, …])

Simulate a signal by combining multiple component signals.

Utilities

create_times(n_seconds, fs[, start_val])

Create an array of time indices.

create_samples(n_samples[, start_val])

Create an array of sample indices.

Random Seed

set_random_seed([seed_val])

Set the random seed value.

Plots

Functions in the plts module, for plotting time series and analysis outputs.

Time Series

plot_time_series(times, sigs[, labels, …])

Plot a time series.

plot_instantaneous_measure(times, sigs[, …])

Plot an instantaneous measure, of phase, amplitude or frequency.

plot_bursts(times, sig, bursting[, ax])

Plot a time series, with labeled bursts.

Spectral

plot_power_spectra(freqs, powers[, labels, …])

Plot power spectra.

plot_scv(freqs, scv[, ax])

Plot spectral coefficient of variation.

plot_scv_rs_lines(freqs, scv_rs[, ax])

Plot spectral coefficient of variation, from the resampling method, as lines.

plot_scv_rs_matrix(freqs, t_inds, scv_rs[, ax])

Plot spectral coefficient of variation, from the resampling method, as a matrix.

plot_spectral_hist(freqs, power_bins, …[, …])

Plot spectral histogram.

Filter

plot_filter_properties(f_db, db, fs, …)

Plot filter properties, including frequency response and filter kernel.

plot_frequency_response(f_db, db[, ax])

Plot the frequency response of a filter.

plot_impulse_response(fs, impulse_response)

Plot the impulse response of a filter.

Rhythm

plot_swm_pattern(pattern[, ax])

Plot the resulting pattern from a sliding window matching analysis.

plot_lagged_coherence(freqs, lcs[, ax])

Plot lagged coherence values across frequencies.