pactools.dar_model.extract_driver

pactools.dar_model.extract_driver(sigs, fs, low_fq, n_cycles=None, bandwidth=1.0, fill=2, whitening='after', ordar=10, normalize=False, extract_complex=True, random_state=None, draw='', max_low_fq=None, enf=50.0)[source]

Extract the driver with filtering and fill the rest of the signal.

The driver is extracted with a bandpass filter, subtracted from the signal, and the frequency gap is filled with filtered white noise.

Parameters
sigsarray, shape (n_epochs, n_points)

Input array to filter

fsfloat

Sampling frequency

low_fqfloat

Center frequency of bandpass filters.

bandwidthfloat

Bandwidth of the bandpass filters. Use it to have a constant bandwidth for all filters. Should be None if n_cycles is not None.

n_cyclesfloat

Number of cycles of the bandpass filters. Use it to have a bandwidth proportional to the center frequency. Should be None if bandwidth is not None.

fillin {0, 1, 2}

Filling strategy for the full band signal high_sigs: 0 : keep the signal unchanged: high_sigs = sigs 1 : remove the bandpass filtered signal: high_sigs = sigs - low_sigs 2 : remove and replace by bandpass filtered Gaussian white noise

whiteningin {‘before’, ‘after’, None}

Define when the whitening is done compared to the filtering.

ordarint >= 0

Order of the AR model used for whitening

normalizeboolean

Whether to scale the signals to have unit norm high_sigs. The low_sigs are scaled with the same scales.

extract_complexboolean

Whether to extract a complex driver (low_sigs and low_sigs_imag)

random_stateNone, int or np.random.RandomState instance

Seed or random number generator for the white noise filling strategy.

drawstring

Add a letter to the string to draw the corresponding figures:

  • ‘e’ : extraction of the driver

  • ‘g’ : gap filling

  • ‘w’ : whitening step

  • ‘z’ : all

max_low_fqfloat or None

Maximum low_fq over a potential cross-validation scheme.

Returns
low_sigsarray, shape (n_epochs, n_points)

Bandpass filtered signal (aka driver)

high_sigsarray, shape (n_epochs, n_points)

Bandstop filtered signal

low_sigs_imagarray, shape (n_epochs, n_points)

Imaginary part of the bandpass filtered signal Returned only if extract_complex is True.

Examples

>>> low_sig, high_sig, low_sigs_imag = extract_driver(sigs, fs, 3.0)