mne.compute_raw_covariance

mne.compute_raw_covariance(raw, tmin=0, tmax=None, tstep=0.2, reject=None, flat=None, picks=None, method=’empirical’, method_params=None, cv=3, scalings=None, n_jobs=1, return_estimators=False, reject_by_annotation=True, verbose=None)[source]

Estimate noise covariance matrix from a continuous segment of raw data.

It is typically useful to estimate a noise covariance from empty room data or time intervals before starting the stimulation.

Note

This function will:

  1. Partition the data into evenly spaced, equal-length epochs.
  2. Load them into memory.
  3. Subtract the mean across all time points and epochs for each channel.
  4. Process the Epochs by compute_covariance().

This will produce a slightly different result compared to using make_fixed_length_events(), Epochs, and compute_covariance() directly, since that would (with the recommended baseline correction) subtract the mean across time for each epoch (instead of across epochs) for each channel.

Parameters:

raw : instance of Raw

Raw data

tmin : float

Beginning of time interval in seconds. Defaults to 0.

tmax : float | None (default None)

End of time interval in seconds. If None (default), use the end of the recording.

tstep : float (default 0.2)

Length of data chunks for artefact rejection in seconds. Can also be None to use a single epoch of (tmax - tmin) duration. This can use a lot of memory for large Raw instances.

reject : dict | None (default None)

Rejection parameters based on peak-to-peak amplitude. Valid keys are ‘grad’ | ‘mag’ | ‘eeg’ | ‘eog’ | ‘ecg’. If reject is None then no rejection is done. Example:

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

flat : dict | None (default None)

Rejection parameters based on flatness of signal. Valid keys are ‘grad’ | ‘mag’ | ‘eeg’ | ‘eog’ | ‘ecg’, and values are floats that set the minimum acceptable peak-to-peak amplitude. If flat is None then no rejection is done.

picks : array-like of int | None (default None)

Indices of channels to include (if None, data channels are used).

method : str | list | None (default ‘empirical’)

The method used for covariance estimation. See mne.compute_covariance().

New in version 0.12.

method_params : dict | None (default None)

Additional parameters to the estimation procedure. See mne.compute_covariance().

New in version 0.12.

cv : int | sklearn cross_validation object (default 3)

The cross validation method. Defaults to 3, which will internally trigger a default 3-fold shuffle split.

New in version 0.12.

scalings : dict | None (default None)

Defaults to dict(mag=1e15, grad=1e13, eeg=1e6). These defaults will scale magnetometers and gradiometers at the same unit.

New in version 0.12.

n_jobs : int (default 1)

Number of jobs to run in parallel.

New in version 0.12.

return_estimators : bool (default False)

Whether to return all estimators or the best. Only considered if method equals ‘auto’ or is a list of str. Defaults to False

New in version 0.12.

reject_by_annotation : bool

Whether to reject based on annotations. If True (default), epochs overlapping with segments whose description begins with 'bad' are rejected. If False, no rejection based on annotations is performed.

New in version 0.14.0.

verbose : bool | str | int | None (default None)

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).

Returns:

cov : instance of Covariance | list

The computed covariance. If method equals ‘auto’ or is a list of str and return_estimators equals True, a list of covariance estimators is returned (sorted by log-likelihood, from high to low, i.e. from best to worst).

See also

compute_covariance
Estimate noise covariance matrix from epochs