neurodsp.spectral.compute_spectral_hist

neurodsp.spectral.compute_spectral_hist(sig, fs, window='hann', nperseg=None, noverlap=None, nbins=50, f_range=[0.0, 100.0], cut_pct=[0.0, 100.0])[source]

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

Parameters
sig1d array

Time series of measurement values.

fsfloat

Sampling rate, in Hz.

windowstr or tuple or array_like, optional, default: ‘hann’

Desired window to use. See scipy.signal.get_window for a list of available windows. If array_like, the array will be used as the window and its length must be nperseg.

npersegint, optional

Length of each segment, in number of samples. If None, and window is str or tuple, is set to 1 second of data. If None, and window is array_like, is set to the length of the window.

noverlapint, optional

Number of points to overlap between segments. If None, noverlap = nperseg // 2.

nbinsint, optional, default: 50

Number of histogram bins to use.

f_rangelist of [float, float], optional, default: [0, 100]

Frequency range of the spectrogram to compute the histograms, as [start, end], in Hz.

cut_pctlist of [float, float], optional, default: [0, 100]

Power percentile at which to draw the lower and upper bin limits, as [low, high], in Hz.

Returns
freqs1d array

Frequencies at which the measure was calculated.

power_bins1d array

Histogram bins used to compute the distribution.

spectral_hist2d array

Power distribution at every frequency, as [n_bins, freqs].

Notes

Histogram bins are the same for every frequency, evenly spacing the global min & max power.

Examples

Compute the distribution of power, which is the spectral histogram:

>>> from neurodsp.sim import sim_combined
>>> sig = sim_combined(n_seconds=10, fs=500,
...                    components={'sim_powerlaw': {}, 'sim_oscillation': {'freq': 10}})
>>> freqs, power_bins, spectral_hist = compute_spectral_hist(sig, fs=500)

Examples using neurodsp.spectral.compute_spectral_hist

Spectral Domain Analysis: Variance

Spectral Domain Analysis: Variance