neurodsp.spectral.compute_scv_rs¶
- neurodsp.spectral.compute_scv_rs(sig, fs, window='hann', nperseg=None, noverlap=0, method='bootstrap', rs_params=None)[source]¶
Compute a resampled version of the spectral coefficient of variation (SCV).
- 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, default: 0
Number of points to overlap between segments.
- method{‘bootstrap’, ‘rolling’}, optional
Method of resampling:
‘bootstrap’ randomly samples a subset of the spectrogram repeatedly.
‘rolling’ takes the rolling window scv.
- rs_paramstuple, (int, int), optional
Parameters for resampling algorithm, depending on the method used:
If ‘bootstrap’, rs_params = (n_slices, n_draws), defaults to (10% of slices, 100 draws).
If ‘rolling’, rs_params = (n_slices, n_steps), defaults to (10, 5).
Where:
n_slices is the number of slices per draw
n_draws is the number of random draws
n_steps is the number of slices to step forward.
- Returns
- freqs1d array
Frequencies at which the measure was calculated.
- t_inds1d array or None
Time indices at which the measure was calculated. This is only returned for ‘rolling’ resampling. If ‘bootstrap’, t_inds = None.
- scv_rs2d array
Resampled spectral coefficient of variation.
Notes
In the resampled version, instead of a single estimate of mean and standard deviation, the spectrogram is resampled.
Resampling can be done either randomly (method=’bootstrap’) or in a time-stepped manner (method=’rolling’).
Examples
Compute the resampled spectral coefficient of variation, using the bootstrap method:
>>> from neurodsp.sim import sim_combined >>> sig = sim_combined(n_seconds=10, fs=500, ... components={'sim_powerlaw': {}, 'sim_oscillation' : {'freq': 10}}) >>> freqs, t_inds, scv_rs = compute_scv_rs(sig, fs=500, method='bootstrap')
Examples using neurodsp.spectral.compute_scv_rs
¶
Spectral Domain Analysis: Variance