fis*_*acp 5 python montage mne-python
我已经使用 Python 的 MNE 包加载了一些脑电图数据。该数据具有从 10-20 个剪辑中获得的 46 个记录通道,但我们已经识别出许多死通道,并且只想关注其余通道。
我可以删除频道,但我不知道如何绘制更新的蒙太奇。
首先,我加载 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'])
Run Code Online (Sandbox Code Playgroud)
我检查了一下,频道已被删除。我现在想做的是仅使用剩余的 23 个通道绘制更新的蒙太奇:
raw_temp.info["ch_names"]
Run Code Online (Sandbox Code Playgroud)
['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()
Run Code Online (Sandbox Code Playgroud)
其他蒙太奇选项列于
https://github.com/mne-tools/mne-python/blob/master/mne/channels/montage.py
但我没有看到 46 通道选项。
有没有办法以某种方式为我的 23 个频道绘制蒙太奇?
小智 1
读取原始脑电图文件时,您应该为原始数据分配一个蒙太奇(您也可以在创建纪元后执行此操作)。这可以使用每个电极和一些基准点的坐标来完成(请参阅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()
Run Code Online (Sandbox Code Playgroud)
我建议您分配一个蒙太奇(在拒绝任何通道之前查看原始数据)。这样,在丢弃不良通道后,您可以使用以下方法轻松地在预处理的任何点获得更新的蒙太奇:
raw = raw.set_montage(mont)
updated_mont = raw.get_montage() #also works with epo.get_montage()
Run Code Online (Sandbox Code Playgroud)
然后你可以简单地绘制更新的蒙太奇:
updated_mont.plot()
Run Code Online (Sandbox Code Playgroud)