mne进行ica分析

最近在做有关的项目,根据mne文档写的内容 就不写注释了。这里我用的是csv的数据直接读取。

import numpy as np
import mne
import matplotlib.pyplot as plt
from mne.preprocessing import ICA
from mne.time_frequency import tfr_morlet
import pandas as pd
from itertools import chain

# Read the CSV file as a NumPy array 需要电信号
data1 = []
for i in range(1, 23):
    data = pd.read_csv('data.csv', usecols=[str(i)])
    list1 = data.values.tolist()
    final_list = list(chain.from_iterable(list1))
    data1.append(final_list)

# Some information about the channels
# ch_names = []
# for i in range(1, 20):
#     ch_names.append("ch " + str(i))
ch_names=['Fz', 'FC3', 'FC1', 'FCz', 'FC2', 'FC4', 'C5', 'C3', 'C1', 'Cz', 'C2', 'C4', 'C6', 'CP3', 'CP1','CPz', 'CP2', 'CP4', 'P1', 'Pz', 'P2', 'POz']


# Sampling rate of the Nautilus machine 采样频率
sfreq = 100  # Hz 


# Create the info structure needed by MNE
info = mne.create_info(ch_names, sfreq,ch_types='eeg') 

# Finally, create the Raw object
raw = mne.io.RawArray(data1, info)

# #电极信息
montage = mne.channels.make_standard_montage("standard_1020")
raw.set_montage(montage)



#ICA
ica = mne.preprocessing.ICA(n_components=22, random_state=97, max_iter=800)
ica.fit(raw)
ica.exclude = [1, 2,3]  # details on how we picked these are omitted here
ica.plot_properties(raw, picks=ica.exclude)
plt.show()

生成的图 

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值