栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

mne进行ica分析

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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()

生成的图 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/767109.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号