trial_ieeg

trial_ieeg(raw: Raw, event: str | list[str, ...], times: tuple[float, float] | list[float, float] | ndarray[2, float], verbose=None, **kwargs) Epochs[source][source]

Epochs data from a mne Raw iEEG instance.

Takes a mne Raw instance and epochs the data around a specified event. If baseline is specified, the data is also epoched around the baseline event and the baseline is subtracted from the data epochs.

Parameters:
  • raw (mne.io.Raw) – The raw data to epoch.

  • event (str) – The event to epoch around.

  • times (tuple[float, float]) – The time window to epoch around the event.

  • picks (str | array-like | slice | None) – Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g., ['MEG0111', 'MEG2623'] will pick the given channels. Can also be the string values 'all' to pick all channels, or 'data' to pick data channels. None (default) will pick all channels. Note that channels in info['bads'] will be included if their names or indices are explicitly provided.

  • reject (dict | None) –

    Reject epochs based on maximum peak-to-peak signal amplitude (PTP), i.e. the absolute difference between the lowest and the highest signal value. In each individual epoch, the PTP is calculated for every channel. If the PTP of any one channel exceeds the rejection threshold, the respective epoch will be dropped.

    The dictionary keys correspond to the different channel types; valid keys can be any channel type present in the object.

    Example:

    reject = dict(grad=4000e-13,  # unit: T / m (gradiometers)
                  mag=4e-12,      # unit: T (magnetometers)
                  eeg=40e-6,      # unit: V (EEG channels)
                  eog=250e-6      # unit: V (EOG channels)
                  )
    

    Note

    Since rejection is based on a signal difference calculated for each channel separately, applying baseline correction does not affect the rejection procedure, as the difference will be preserved.

    Note

    To constrain the time period used for estimation of signal quality, pass the reject_tmin and reject_tmax parameters.

    If reject is None (default), no rejection is performed.

  • flat (dict | None) –

    Reject epochs based on minimum peak-to-peak signal amplitude (PTP). Valid keys can be any channel type present in the object. The values are floats that set the minimum acceptable PTP. If the PTP is smaller than this threshold, the epoch will be dropped. If None then no rejection is performed based on flatness of the signal.

    Note

    To constrain the time period used for estimation of signal quality, pass the reject_tmin and reject_tmax parameters.

  • decim (int) –

    Factor by which to subsample the data.

    Warning

    Low-pass filtering is not performed, this simply selects every Nth sample (where N is the value passed to decim), i.e., it compresses the signal (see Notes). If the data are not properly filtered, aliasing artifacts may occur. See Resampling and decimating data for more information.

  • reject_tmin (float | None) –

    Start and end of the time window used to reject epochs based on peak-to-peak (PTP) amplitudes as specified via reject and flat. The default None corresponds to the first and last time points of the epochs, respectively.

    Note

    This parameter controls the time period used in conjunction with both, reject and flat.

  • reject_tmax (float | None) –

    Start and end of the time window used to reject epochs based on peak-to-peak (PTP) amplitudes as specified via reject and flat. The default None corresponds to the first and last time points of the epochs, respectively.

    Note

    This parameter controls the time period used in conjunction with both, reject and flat.

  • detrend (int | None) – If 0 or 1, the data channels (MEG and EEG) will be detrended when loaded. 0 is a constant (DC) detrend, 1 is a linear detrend. None is no detrending. Note that detrending is performed before baseline correction. If no DC offset is preferred (zeroth order detrending), either turn off baseline correction, as this may introduce a DC shift, or set baseline correction to use the entire time interval (will yield equivalent results but be slower).

  • proj (bool | 'delayed') – Apply SSP projection vectors. If proj is ‘delayed’ and reject is not None the single epochs will be projected before the rejection decision, but used in unprojected state if they are kept. This way deciding which projection vectors are good can be postponed to the evoked stage without resulting in lower epoch counts and without producing results different from early SSP application given comparable parameters. Note that in this case baselining, detrending and temporal decimation will be postponed. If proj is False no projections will be applied which is the recommended value if SSPs are not used for cleaning the data.

  • on_missing ('raise' | 'warn' | 'ignore') –

    What to do if one or several event ids are not found in the recording. Valid keys are ‘raise’ | ‘warn’ | ‘ignore’ Default is 'raise'. If 'warn', it will proceed but warn; if 'ignore', it will proceed silently.

    Note

    If none of the event ids are found in the data, an error will be automatically generated irrespective of this parameter.

  • verbose (bool | str | int | None) – Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

Returns:

The epoched data.

Return type:

mne.Epochs

Examples

>>> import mne
>>> from ieeg.io import raw_from_layout
>>> bids_root = mne.datasets.epilepsy_ecog.data_path(verbose=False)
>>> 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...
>>> epochs = trial_ieeg(raw, "AD1-4, ATT1,2", (-1, 2), verbose=True
... )
Used Annotations descriptions: ['AD1-4, ATT1,2', 'AST1,3', 'G16', 'PD',...
Not setting metadata
1 matching events found
No baseline correction applied
0 projection items activated
>>> epochs = trial_ieeg(raw, ['AST1,3', 'G16'], (-1, 2), verbose=True
... )
Used Annotations descriptions: ['AD1-4, ATT1,2', 'AST1,3', 'G16', 'PD', ...
Not setting metadata
2 matching events found
No baseline correction applied
0 projection items activated

Examples using ieeg.navigate.trial_ieeg

High Gamma Filter

High Gamma Filter

PCA-LDA Decoding

PCA-LDA Decoding

Time and Frequency Permutation Cluster Statistics

Time and Frequency Permutation Cluster Statistics

Joint pca decoding

Joint pca decoding

Morlet Wavelet spectrogram plot

Morlet Wavelet spectrogram plot

Morlet Wavelet spectrogram plot

Morlet Wavelet spectrogram plot

Time Permutation Cluster Statistics

Time Permutation Cluster Statistics