mne.set_eeg_reference

mne.set_eeg_reference(inst, ref_channels='average', copy=True, projection=False, ch_type='auto', verbose=None)[source]

Specify which reference to use for EEG data.

Use this function to explicitly specify the desired reference for EEG. This can be either an existing electrode or a new virtual channel. This function will re-reference the data according to the desired reference.

Parameters
instinstance of Raw | Epochs | Evoked

Instance of Raw or Epochs with EEG channels and reference channel(s).

ref_channelslist of str | str

The name(s) of the channel(s) used to construct the reference. To apply an average reference, specify 'average' here (default). Specify an empty list to remove a potentially existing average reference projection. Defaults to an average reference.

copybool

Specifies whether the data will be copied (True) or modified in-place (False). Defaults to True.

projectionbool

If ref_channels='average' this argument specifies if the average reference should be computed as a projection (True) or not (False; default). If projection=True, the average reference is added as a projection and is not applied to the data (it can be applied afterwards with the apply_proj method). If projection=False, the average reference is directly applied to the data. If ref_channels is not 'average', projection must be set to False (the default in this case).

ch_type‘auto’ | ‘eeg’ | ‘ecog’ | ‘seeg’

The name of the channel type to apply the reference to. If ‘auto’, the first channel type of eeg, ecog or seeg that is found (in that order) will be selected.

New in version 0.19.

verbosebool, str, int, or None

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

Returns
instinstance of Raw | Epochs | Evoked

Data with EEG channels re-referenced. If ref_channels='average' and projection=True a projection will be added instead of directly re-referencing the data.

ref_dataarray

Array of reference data subtracted from EEG channels. This will be None if ref_channels='average' and projection=True.

See also

mne.set_bipolar_reference

Convenience function for creating bipolar references.

Notes

Some common referencing schemes and the corresponding value for the ref_channels parameter:

  • Average reference:

    A new virtual reference electrode is created by averaging the current EEG signal by setting ref_channels='average'. Bad EEG channels are automatically excluded if they are properly set in info['bads'].

  • A single electrode:

    Set ref_channels to a list containing the name of the channel that will act as the new reference, for example ref_channels=['Cz'].

  • The mean of multiple electrodes:

    A new virtual reference electrode is created by computing the average of the current EEG signal recorded from two or more selected channels. Set ref_channels to a list of channel names, indicating which channels to use. For example, to apply an average mastoid reference, when using the 10-20 naming scheme, set ref_channels=['M1', 'M2'].

  1. If a reference is requested that is not the average reference, this function removes any pre-existing average reference projections.

  2. During source localization, the EEG signal should have an average reference.

  3. In order to apply a reference, the data must be preloaded. This is not necessary if ref_channels='average' and projection=True.

  4. For an average reference, bad EEG channels are automatically excluded if they are properly set in info['bads'].

New in version 0.9.0.