[英]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)
讀取原始 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.