資源簡(jiǎn)介
python中MNE庫(kù)中ICA和PCA的使用,資料包中提供了源代碼和數(shù)據(jù),可供調(diào)試使用。資料包中的數(shù)據(jù)來(lái)源與BCI競(jìng)賽中運(yùn)動(dòng)想象的公開(kāi)數(shù)據(jù)集,挑選了部分?jǐn)?shù)據(jù)進(jìn)行處理。
代碼片段和文件信息
import?mne
import?pickle
from?mne.decoding?import?UnsupervisedSpatialFilter
import?matplotlib.pyplot?as?plt
import?numpy?as?np
from?sklearn.decomposition?import?PCA?FastICA
#?設(shè)置log輸出等級(jí)
mne.set_log_level(False)
#?加載訓(xùn)練數(shù)據(jù)
with?open(r‘F:\BaiduNetdiskDownload\BCICompetition\BCICIV_2b_gdf\Train\CueLeftRight\trainData.pkl‘‘rb‘)?as?f:
????epochsTrain?=?pickle.load(f)
#?繪制原始數(shù)據(jù)的epochs均值,也就是evoked
epochsTrain.average().plot()
#?獲取訓(xùn)練數(shù)據(jù)(純數(shù)據(jù)非epoch格式)
trainData?=?epochsTrain.get_data([‘EEG:Cz‘?‘EEG:C3‘?‘EEG:C4‘])
#?創(chuàng)建PCA的計(jì)算模型
pca?=?UnsupervisedSpatialFilter(PCA(3)?average=False)
#?進(jìn)行PCA處理
pca_data?=?pca.fit_transform(trainData)
#?將其轉(zhuǎn)換為evoked類(lèi)型并繪圖
ev1?=?mne.EvokedArray(np.mean(pca_data?axis=0)mne.create_info(3?250?ch_types=‘eeg‘)?tmin=-0.2)
ev1.plot(show=False?win
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2020-03-31?12:20??Python中MNE庫(kù)的EEG數(shù)據(jù)(PCA和ICA)預(yù)處理\
?????文件????????1330??2020-03-31?11:54??Python中MNE庫(kù)的EEG數(shù)據(jù)(PCA和ICA)預(yù)處理\PCAandICA.py
?????文件????????3817??2020-03-31?11:15??Python中MNE庫(kù)的EEG數(shù)據(jù)(PCA和ICA)預(yù)處理\plot_decoding_unsupervised_spatial_filter.ipynb
?????文件????????2496??2020-03-31?11:15??Python中MNE庫(kù)的EEG數(shù)據(jù)(PCA和ICA)預(yù)處理\plot_decoding_unsupervised_spatial_filter.py
?????文件?????4031941??2020-01-17?13:49??Python中MNE庫(kù)的EEG數(shù)據(jù)(PCA和ICA)預(yù)處理\trainData.pkl
評(píng)論
共有 條評(píng)論