extract

extract(data: ndarray, fs: float = None, passband: tuple[int, int] = (70, 150), copy: bool = True, spacing: float = 0.14285714285714285, n_jobs=-1, verbose: bool = True) ndarray[source][source]
extract(inst: BaseRaw, fs: int = None, passband: tuple[int, int] = (70, 150), copy: bool = True, n_jobs=-1, verbose: bool = True) Raw
extract(inst: BaseEpochs, fs: int = None, passband: tuple[int, int] = (70, 150), copy: bool = True, n_jobs=-1, verbose: bool = True) Epochs
extract(inst: Evoked, fs: int = None, passband: tuple[int, int] = (70, 150), copy: bool = True, n_jobs=-1, verbose: bool = True) Evoked

Extract gamma band envelope from data.

Parameters:
  • data ((np.ndarray, shape ((epochs) ,channels, samples)) | Signal) – Data to extract gamma envelope from. If Signal, will use the _data attribute.

  • fs (int, optional) – Sampling frequency of data. If Signal, will use the data.info[‘sfreq’]. Otherwise, must be provided.

  • passband (tuple[int, int], optional) – Passband in Hz, high gamma band by default (70, 150)

  • copy (bool, optional) – Whether to copy data or operate in place if False, by default True

  • n_jobs (int, optional) – Number of jobs to run in parallel, by default all available cores

  • spacing (float)

  • verbose (bool)

Returns:

Gamma envelope.

Return type:

np.ndarray

Notes

This function is a wrapper for filterbank_hilbert. It is a convenience function for extracting the gamma envelope from data. It is optimized for speed, but not memory. If you have a lot of data, you may want to epoch your data first and then extract the envelope.

Examples

>>> import mne
>>> import numpy as np
>>> from bids import BIDSLayout
>>> from ieeg.navigate import trial_ieeg
>>> from ieeg.io import raw_from_layout
>>> from ieeg.timefreq.utils import crop_pad
>>> bids_root = mne.datasets.epilepsy_ecog.data_path(verbose=50)
>>> layout = BIDSLayout(bids_root)
>>> raw = raw_from_layout(layout, subject="pt1",
... preload=True, extension=".vhdr", verbose=False)
Reading 0 ... 269079  =      0.000 ...   269.079 secs...
>>> trials = trial_ieeg(raw, "AD1-4, ATT1,2", (-0.5, 1),
... preload=True, verbose=False, picks=['AD2'])
>>> gamma = extract(trials, n_jobs=1)
>>> crop_pad(gamma, "0.5s")
<Epochs | 1 events (all good), 0 – 0.5 s (baseline off), ...
 'AD1-4, ATT1,2': 1>
>>> gamma.resample(100, verbose=50)
<Epochs | 1 events (all good), 0 – 0.49 s (baseline off), ...
 'AD1-4, ATT1,2': 1>
>>> expected = np.array([
... 3.5729, 3.8323, 4.0820, 5.4100, 8.0623, 12.579, 20.280, 31.027, 43.918,
... 56.523, 65.739, 68.678, 64.378, 54.357, 42.245, 32.177, 26.568, 23.578,
... 20.584, 17.003, 13.105, 9.6693, 6.9391, 4.8671, 3.6392, 3.0246, 2.8268,
... 2.9109, 3.2376, 3.6906, 4.1659, 4.5842, 4.9949, 5.3240, 6.0321, 7.1968,
... 8.0531, 8.4710, 8.3094, 7.8219, 7.3717, 7.1496, 7.0281, 7.0632, 7.0525,
... 7.2997, 7.7566, 7.7874, 7.3208, 6.4729]) * 1e-05
>>> np.abs(np.sum(gamma._data - expected)) < 1e-6
True

Examples using ieeg.timefreq.gamma.extract

High Gamma Filter

High Gamma Filter

PCA-LDA Decoding

PCA-LDA Decoding

Joint pca decoding

Joint pca decoding

Time Permutation Cluster Statistics

Time Permutation Cluster Statistics