Python-EEG tool library MNE Chinese Tutorial (8) - reference electrode Profile

@(table of Contents)

This tutorial is a brain-computer learner Rose Original (reprint please contact the author's permission) published in the public number: BCI community (Micro Signal: Brain_Computer) .QQ exchange group: 903 290 195

Reference electrode Profile

Scalp electrode is disposed on the working electrode (active electrode). Placed in the body opposite the zero potential point of the electrode is the reference electrode (reference electrode), also called a reference electrode or reference electrode.
I.e., to record EEG is the difference between the working electrode and the reference electrode (potential difference).

More detailed reference electrode profiles, please see the MNE-Python reference electrode

Set EEG Reference

The tutorial describes how to set or change the EEG in reference MNE-Python.

set_eeg_reference(self, 
                  ref_channels='average',
                  projection=False, 
                  ch_type='auto', 
                  verbose=None)
指定用于EEG信号的参考。

参数
ref_channels: list of str | str
用于构造参考的通道名称。如果要应用平均参考,就在此处指定"average"(默认情况就是使用average)。
如果指定了空列表,则表示您已假定该数据已经具有正确的引用,并且MNE将不会尝试对该数据进行任何重新参考。
默认为平均参考。

projection:bool
如果ref_channels ='average',则此参数指定是否应将平均参考计算为projection(True)或不作为projection(False;默认)。
如果projection = True,则将平均参考作为projection添加,并且不应用于数据(后面可以使用apply_proj方法应用)。
如果projection = False,则将平均参考直接应用于数据。
如果ref_channels不是'average',则projection必须设置为False。
默认情况为False.

ch_type:'auto' | 'eeg' | 'ecog' | 'seeg'
要应用参考的通道类型的名称。如果选择'auto',则会选择(按此顺序)找到的第一个eeg,egg或seeg的通道类型。


返回值
Raw对象实例 | Epochs对象实例| Evoked对象实例

注:
1.如果请求的参考不是平均参考,则此函数将移除任何预先存在的平均参考投影。
2.在源定位期间,EEG信号应具有平均参考值。
3.为了应用参考,必须预先加载数据。如果ref_channels ='average'且projection = True,则无需执行此操作。
4.对于一般参考,如果在info['bads']中设置了错误的EEG频道,则会自动排除这它们。

Case - reference electrode

import os
import mne
import matplotlib.pyplot as plt
%matplotlib auto

"""
设置原始数据地址
"""
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
                                    'sample_audvis_raw.fif')
"""
读取数据生成raw对象实例
"""
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False)
raw.crop(tmax=60).load_data()
raw.pick(['EEG 0{:02}'.format(n) for n in range(41, 60)])

Set or change the reference channel

If you want to recalculate data (recording is not to use the already calculated or reference electrodes used to save the data), it is provided MNE-Python set_eeg_reference () method and mne.add_reference_channels () method Raw object.

If a scalp electrode as a reference, but not saved along with the original data (usually no reference channel), then you may want to reference before re-add it back to the data set.
For example, if your system uses channels Fp1 EEG recorded as a reference, but not included in the data file Fp1, use set_eeg_reference () set.
For example, Cz is set to a new reference, and then subtracting the signal at Cz, without resuming signal at Fp1. In this case, use add_reference_channels () before re-add the reference back plane channels Fp1.

(Because there is no sample data electrodes 10-20 naming system, the following example EEG 999 add the missing reference, then the reference to EEG 050)

This data is displayed in its original state:

raw.plot()
plt.show()

By default, add_reference_channels () returns a copy, so later we can return to the original object.

Raw If you want to change an existing object, you can specify the copy = False.

# 添加一个新的参考通道(新添的参考通道中的所有值均为0)
raw_new_ref = mne.add_reference_channels(raw, ref_channels=['EEG 999'])
raw_new_ref.plot()
plt.show()

As shown above, the newly added channel EEG 999 as the reference electrode, the effect is a flat.

# 设置 `EEG 050` 作为参考电极
raw_new_ref.set_eeg_reference(ref_channels=['EEG 050'])
raw_new_ref.plot()
plt.show()

As FIG effect, a new reference channel (EEG 050) is flat now, we added back to the original data of the reference channel (EEG 999) having a non-zero signal.
Note also that, EEG 053 is a bad signal (raw.info [ 'bads'] labeled as "bad") is not affected by the re-reference.

The average reference set

Wants to set a "virtual reference", i.e. the average of all the channels, may be used set_eeg_reference () and ref_channels = 'average'.
As above stated, it will not affect any marked as "bad" channel, the channel may not be included in calculating the average failure.
However, it does place Raw modify objects, so we will first create a copy of an object in order to still be able to return to Raw unmodified later:

# 使用所有通道的平均值作为参考
raw_avg_ref = raw.copy().set_eeg_reference(ref_channels='average')
raw_avg_ref.plot()
plt.show()

Projector created as the average reference (projection) has the following advantages:

You can open or close Projector (projection) when the drawing, it is easy to visualize the influence of the average reference data.

If additional channels labeled as "bad", or after selecting a subset of the channels will be recalculated Projector (projection) to account for these variations (so as to ensure a zero mean signal).

If other previously unused Projector (projection) also affect the EEG channels (e.g. heart SSP projector for eliminating or blink artifacts (projected)), the application or removal of these Projector (projection), the reference can not be performed again EEG ; add a projector reference EEG (projection) is not so limited.

for title, proj in zip(['Original', 'Average'], [False, True]):
    fig = raw.plot(proj=proj, n_channels=len(raw))
    # make room for title
    fig.subplots_adjust(top=0.9)
    fig.suptitle('{} reference'.format(title), size='xx-large', weight='bold')


Reference: MNE in Python --reference electrode

脑机学习者Rose笔记分享,QQ交流群:903290195
更多分享,请关注公众号

Guess you like

Origin www.cnblogs.com/RoseVorchid/p/12018417.html