繁体   English   中英

如何使用指定的 EEG 通道集在 Python MNE 中 plot 蒙太奇?

[英]How can I plot a montage in Python MNE using a specified set of EEG channels?

我已经使用 Python 的 MNE package 加载了一些 EEG 数据。 数据有 46 个记录通道,从 10-20 个蒙太奇中获得,但我们已经确定了许多死通道,只想关注剩余的通道。

我可以删除频道,但我不知道如何 plot 更新蒙太奇。

首先我加载我的 edf 文件,复制并删除所需的频道:

import mne as mn
raw = mn.io.read_raw_edf("patient_001.edf",preload=True)
raw_temp=raw.copy()
raw_temp.drop_channels(['E', 'LIO', 'RIO', 'X1', 'X2', 
'X3','X4''X5', 'X6', 'X7', 'X8', 'X9', 'X10', 'X11', 'O2%', 'HR', 
'DC03','DC04', 'EEG Mark1', 'EEG Mark2', 'BP1', 'BP2','STI 014'])

我检查并删除了频道。 我现在要做的是 plot 一个更新的蒙太奇,只使用我剩下的 23 个频道:

raw_temp.info["ch_names"]

['Fp1','Fp2','F3','F4','C3','C4','P3','P4','O1','O2','F7','F8',' T7'、'T8'、'P7'、'P8'、'Fz'、'Cz'、'Pz'、'A1'、'A2'、'T1'、'T2']

根据我对通道位置的极其有限的了解,我理解字母代表位置,数字代表半球,例如 F4 表示右侧额叶。

以下打印 10-20 93 通道布局的蒙太奇:

montage = mn.channels.read_montage("standard_1020")
raw_temp.set_montage(montage)
montage.plot()

其他蒙太奇选项列于

https://github.com/mne-tools/mne-python/blob/master/mne/channels/montage.py

但我没有看到 46 频道选项。

有没有办法 plot 我的 23 个频道的蒙太奇?

如果只想 plot 的电极布局,可以使用Layout class 代替Montage class:

import mne

layout = mne.channels.read_layout("EEG1005")
selection = [
    "Fp1",
    "Fp2",
    "F3",
    "F4",
    "C3",
    "C4",
    "P3",
    "P4",
    "O1",
    "O2",
    "F7",
    "F8",
    "T7",
    "T8",
    "P7",
    "P8",
    "Fz",
    "Cz",
    "Pz",
    "A1",
    "A2",
    "T1",
    "T2",
]
picks = []
for channel in selection:
    picks.append(layout.names.index(channel))
display = layout.plot(picks=picks)

这给了你在此处输入图像描述 至少对于mne==0.18.0

读取原始 eeg 文件时,您应该为原始数据分配蒙太奇(您也可以在创建 epoch 之后执行此操作)。 这可以使用每个电极的坐标和一些基准点来完成(参见https://mne.tools/stable/generated/mne.channels.make_dig_montage.html#mne.channels.make_dig_montage )。 如果您的数据取自标准 10-20 系统,那么您可以使用内置的 function mne.channels.make_standard_montage('standard_1020')获得 93 通道蒙太奇,然后使用以下代码仅保留您感兴趣的电极:

# Form the 10-20 montage
mont1020 = mne.channels.make_standard_montage('standard_1020')
# Choose what channels you want to keep 
# Make sure that these channels exist e.g. T1 does not exist in the standard 10-20 EEG system!
kept_channels = ['Fp1', 'Fp2', 'F3', 'F4', 'C3', 'C4', 'P3', 'P4', 'O1', 'O2', 'F7', 'F8', 'T7', 'T8', 'P7', 'P8', 'Fz', 'Cz', 'Pz', 'A1', 'A2', 'T1', 'T2']
ind = [i for (i, channel) in enumerate(mont1020.ch_names) if channel in kept_channels]
mont1020_new = mont1020.copy()
# Keep only the desired channels
mont1020_new.ch_names = [mont1020.ch_names[x] for x in ind]
kept_channel_info = [mont1020.dig[x+3] for x in ind]
# Keep the first three rows as they are the fiducial points information
mont1020_new.dig = mont1020.dig[0:3]+kept_channel_info
mont1020.plot()
mont1020_new.plot()

在此处输入图像描述

我建议您分配一个蒙太奇(在拒绝任何频道之前查看原始数据。这样,在删除不良频道后,您可以很容易地在预处理的任何时候使用以下方法获得更新的蒙太奇:

    raw = raw.set_montage(mont)
updated_mont = raw.get_montage() #also works with epo.get_montage()

然后你可以简单地 plot 更新蒙太奇:

updated_mont.plot()

注意:ind = [i for (i, channel) in enumerate(mont1020.ch_names) 打印:这是 ind: [0, 2, 15, 17, 19, 21, 23, 39, 41, 43, 61, 63, 65、80、81、82、86、87、88、89]

ind = [channel for (i, channel) in enumerate(mont1020.ch_names) prints: 这是 ind: ['Fp1', 'Fp2', 'F7', 'F3', 'Fz', 'F4', 'F8 ','C3','Cz','C4','P3','Pz','P4','O1','Oz','O2','T3','T5','T4', 'T6']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM