【问题标题】:How can I plot a montage in Python MNE using a specified set of EEG channels?如何使用指定的 EEG 通道集在 Python MNE 中绘制蒙太奇?
【发布时间】:2021-07-22 09:25:57
【问题描述】:

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

我可以删除频道,但我不知道如何绘制更新后的蒙太奇。

首先我加载我的 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'])

我检查并删除了频道。我现在要做的是仅使用剩余的 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 频道选项。

有没有办法以某种方式为我的 23 个频道绘制蒙太奇?

【问题讨论】:

    标签: python montage mne-python


    【解决方案1】:

    如果只想绘制电极布局,可以使用Layout 类代替Montage 类:

    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 提供

    【讨论】:

      【解决方案2】:

      读取原始 eeg 文件时,您应该为原始数据分配蒙太奇(您也可以在创建 epochs 后执行此操作)。这可以使用每个电极的坐标和一些基准点来完成(参见https://mne.tools/stable/generated/mne.channels.make_dig_montage.html#mne.channels.make_dig_montage)。如果您的数据来自标准 10-20 系统,那么您可以使用内置函数 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()
      

      enter image description here

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

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

      然后您可以简单地绘制更新后的蒙太奇:

      updated_mont.plot()
      

      【讨论】:

        【解决方案3】:

        注意: 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 = [enumerate(mont1020.ch_names) 中 (i, channel) 的频道 印刷: 这是 ind :['Fp1','Fp2','F7','F3','Fz','F4','F8','C3','Cz','C4','P3',' Pz'、'P4'、'O1'、'Oz'、'O2'、'T3'、'T5'、'T4'、'T6']

        【讨论】:

        • 请添加更多解释以帮助我们了解更多
        猜你喜欢
        • 2022-10-06
        • 2012-03-10
        • 1970-01-01
        • 2015-11-04
        • 2023-03-19
        • 1970-01-01
        • 1970-01-01
        • 2020-05-07
        • 1970-01-01
        相关资源
        最近更新 更多