日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

脑电数据预处理和后续处理(EEGLAB)

發布時間:2023/12/31 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 脑电数据预处理和后续处理(EEGLAB) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄

    • EEGLAB
      • 下載與安裝
      • 載入數據
      • 繪制腦地形圖
      • 腦電數據預處理
        • 參考轉換(Re-reference)
        • 濾波
        • 改變采樣率
        • 移除無用電極
        • 分段
        • 基線校正
        • 偽跡去除
        • 剔除壞段
        • 疊加平均
        • 保存數據
      • 腦電分類
        • 特征提取
        • 分類

由于我的畢設涉及到腦電信號的處理與分類,所以在這記錄一下我的學習過程。不得不說我留給畢設的時間好像不足以支撐到我完全理解eeglab的使用…

EEGLAB

下載與安裝

我的matlab版本是R2018a,在eeglab官網下載了之后放到了matlab文件夾下toolbox里邊,然后再添加路徑就可以使用了。
出現的問題
當打開eeglab時,界面提醒 R2018a需要升級,同時eeglab運行到關掉某個進行過程時,matlab會崩潰

然后我下載了R2018a升級的壓縮包,解決了這個問題。

載入數據

  • 采集之后我得到的數據是cnt的文件,在界面的file–>import data下可以選擇導入cnt格式的數據,如下圖:

    載入數據之后,可以看到界面顯示為:

    這里我出現了個問題,我采集腦電設備的電極是64極的,但是eeglab顯示是67個通道,其中多了三個通道,觀察數據發現有三行值是100到500多的,搞不懂為什么,如果有知道的朋友希望評論一下,謝謝🌹 我感覺這個問題是個雷,可能之后的處理操作就因為這個都錯了…
    更新:
    參考:link
    這個網頁中描述的問題和我的相似,他采集設備的電極是128,但是導入后eeglab顯示有132個通道?;卮鹫fFidNz = the fiducial marker near the nose (nasion),eeglab會自動檢測出三個隱藏通道,然后建議是選擇比采集電極多的電極位置圖,不過也要保證電極位置的正確。
  • plot–>channel data(scroll) 可以觀察對應電極通道的序列圖。

繪制腦地形圖

edit --> channel location --> read locations --> 選擇位置文件
這里需要注意的是如果要選擇位置文件的話(也可以不選擇,eeglab有自動匹配),在eeglab的文件夾中的sample_locs下可以選擇對應的文件。被試佩戴腦電帽的通道數為 64 導,電極位置遵照國際 10-20 標準分布。
因為我沒有找到對應的電極位置文件,所以我并沒有選擇 Read Location,直接用的eeglab自動對準的。

腦電數據預處理

參考轉換(Re-reference)

濾波

這部分具體應該選擇的頻率范圍我不是很確定,我選擇了0.25~30Hz,依次在第一框中填入0.25和第二個框中填入30進行計算,兩個一起填代表進行帶通濾波,建議分開進行,先高通濾波再低通濾波。

改變采樣率

原數據的采樣率是1000Hz,很占內存,所以我將采樣率改為120Hz。
降低采樣率需要注意:

  • 一是降低采樣率要在濾波之后。因為降低采樣率會使我們丟失高頻信息,使高頻信息變得扭曲,所以最好在保留了我們感興趣波段之后再去降低采樣率,這樣可以保證信號最大程度不會失真。
  • 二是根據負荷采樣定理:選擇是我們想要分析的波段頻率的3,4倍以上,理論上來說,我們的采樣率必須是我們想要分析的波段的兩倍,比如我們想要分析60Hz的波,那數據采樣率為120Hz就足夠了。實際上,建議采樣率最好在分析波段的三到四倍。

移除無用電極

移除眼電通道

分段


一般的ERP分段在事件前200毫秒到事件后1000毫秒這個時間段就足夠了,因為幾乎所有的ERP成分,都是在1秒以內產生的。但是如果后期還要做時頻分析的話,則需要將分段時間拉長,擴大到事件前1秒到事件后2秒這個時間段內,因為時頻分析的算法,要求數據要有一定的長度。

基線校正

分段之后就會跳出基線校正的操作框。

偽跡去除

使用ICA算法分解數據。

繪制2-D Component Scalp Maps,這一步需要對每一個成分進行查看和判斷,然后將想要剔除的成分先標記起來。

剔除ICA成分

剔除哪些成分,我是借助了Adjust插件(Adjust 需要自己安裝,不是 EEGLAB 默認攜帶的。)

繪制 component spectra and maps,了解哪些獨立成分對特定的頻段貢獻最大,這里我設置需要隨機選擇的數據的百分比為100%。
command line上顯示的結果如下:

Component 1 percent relative variance: 83.77 Component 2 percent relative variance: 12.14 Component 3 percent relative variance: 6.57 Component 4 percent relative variance: 7.76 Component 5 percent relative variance: 8.08 Component 6 percent relative variance: 14.21 Component 7 percent relative variance: 2.81 Component 8 percent relative variance: 6.20 Component 9 percent relative variance: 4.55 Component 10 percent relative variance: 1.20 Component 11 percent relative variance: 3.25 Component 12 percent relative variance: 2.63 Component 13 percent relative variance: 1.39 Component 14 percent relative variance: 2.48 Component 15 percent relative variance: 2.11 Component 16 percent relative variance: 1.41 Component 17 percent relative variance: 1.35 Component 18 percent relative variance: 1.64 Component 19 percent relative variance: 0.24 Component 20 percent relative variance: 0.82 Component 21 percent relative variance: 0.38 Component 22 percent relative variance: 0.60 Component 23 percent relative variance: 0.89 Component 24 percent relative variance: 1.27 Component 25 percent relative variance: 0.44 Component 26 percent relative variance: 0.54 Component 27 percent relative variance: 0.61 Component 28 percent relative variance: 0.22 Component 29 percent relative variance: 0.45 Component 30 percent relative variance: 0.32 Component 31 percent relative variance: 1.13 Component 32 percent relative variance: 0.09 Component 33 percent relative variance: 0.67 Component 34 percent relative variance: 0.22 Component 35 percent relative variance: 0.21 Component 36 percent relative variance: 0.28 Component 37 percent relative variance: 0.50 Component 38 percent relative variance: 0.16 Component 39 percent relative variance: 0.26 Component 40 percent relative variance: 0.14 Component 41 percent relative variance: 0.18 Component 42 percent relative variance: 0.18 Component 43 percent relative variance: 0.07 Component 44 percent relative variance: 0.02 Component 45 percent relative variance: 0.17 Component 46 percent relative variance: 0.05 Component 47 percent relative variance: 0.02 Component 48 percent relative variance: 0.10 Component 49 percent relative variance: 0.04 Component 50 percent relative variance: 0.02 Component 51 percent relative variance: 0.01 Component 52 percent relative variance: 0.00 Component 53 percent relative variance: 0.01 Component 54 percent relative variance: 0.01 Component 55 percent relative variance: 0.00 Component 56 percent relative variance: 0.00 Component 57 percent relative variance: 0.00

為了得到獨立成分的 ERP 對數據的 ERP 的貢獻,我們需要選擇 Plot > Component ERPs> with component maps。
command line上顯示:

Comparing maximum projections for components: IC1 maximum mean power of back-projection: 72.2738 IC2 maximum mean power of back-projection: 40.3074 IC3 maximum mean power of back-projection: 118.629 IC4 maximum mean power of back-projection: 20.5741 IC5 maximum mean power of back-projection: 16.7698 IC6 maximum mean power of back-projection: 4.04828 IC7 maximum mean power of back-projection: 5.03374 IC8 maximum mean power of back-projection: 27.3447 IC9 maximum mean power of back-projection: 12.9047 IC10 maximum mean power of back-projection: 2.4831 IC11 maximum mean power of back-projection: 5.01077 IC12 maximum mean power of back-projection: 3.94776 IC13 maximum mean power of back-projection: 5.80443 IC14 maximum mean power of back-projection: 10.3948 IC15 maximum mean power of back-projection: 11.8145 IC16 maximum mean power of back-projection: 1.14692 IC17 maximum mean power of back-projection: 2.63034 IC18 maximum mean power of back-projection: 4.09341 IC19 maximum mean power of back-projection: 2.35853 IC20 maximum mean power of back-projection: 1.54849 IC21 maximum mean power of back-projection: 0.761995 IC22 maximum mean power of back-projection: 1.22335 IC23 maximum mean power of back-projection: 1.50031 IC24 maximum mean power of back-projection: 6.12206 IC25 maximum mean power of back-projection: 0.449215 IC26 maximum mean power of back-projection: 1.05872 IC27 maximum mean power of back-projection: 0.574225 IC28 maximum mean power of back-projection: 0.44772 IC29 maximum mean power of back-projection: 0.545843 IC30 maximum mean power of back-projection: 0.624281 IC31 maximum mean power of back-projection: 1.91398 IC32 maximum mean power of back-projection: 0.356062 IC33 maximum mean power of back-projection: 0.483526 IC34 maximum mean power of back-projection: 0.403002 IC35 maximum mean power of back-projection: 0.166475 IC36 maximum mean power of back-projection: 0.393186 IC37 maximum mean power of back-projection: 0.468765 IC38 maximum mean power of back-projection: 0.336584 IC39 maximum mean power of back-projection: 0.495862 IC40 maximum mean power of back-projection: 0.29598 IC41 maximum mean power of back-projection: 0.115158 IC42 maximum mean power of back-projection: 0.191568 IC43 maximum mean power of back-projection: 0.0438948 IC44 maximum mean power of back-projection: 0.073342 IC45 maximum mean power of back-projection: 0.0760424 IC46 maximum mean power of back-projection: 0.238884 IC47 maximum mean power of back-projection: 0.0109103 IC48 maximum mean power of back-projection: 0.0265037 IC49 maximum mean power of back-projection: 0.016949 IC50 maximum mean power of back-projection: 0.00671989 IC51 maximum mean power of back-projection: 0.00366287 IC52 maximum mean power of back-projection: 22.7095 IC53 maximum mean power of back-projection: 0.00337244 IC54 maximum mean power of back-projection: 0.00276348 IC55 maximum mean power of back-projection: 0.00112066 IC56 maximum mean power of back-projection: 0.000727603 IC57 maximum mean power of back-projection: 0.000860832 in the interval -1000 ms to 1992 ms. Plotting envelopes of 7 component projections. Topo maps will show components: 52 5 2 8 4 1 3 with max var at times (ms): 8 242 675 692 1617 1750 1783 epoch frames: 122 150 202 204 315 331 335 Component sortvar in interval: 72.27 40.31 118.63 20.57 16.77 4.05 5.03 Summed component 'ppaf' in interval [-1000 1991.67] ms: 53.83%Plot limits (sec, sec, uV, uV) [-1,1.99167,-20.1883,13.5947]

繪制Component ERP-image

剔除壞段

最后一個步驟就是要剔除掉波幅超過100微幅的trial(要求嚴格一點也可以定位80),因為波幅起伏這么大的活動,已經不是由認知活動引起的了,肯定是由于其他的動作引起的,所以可以直接剔除掉。
這一步操作一定要在插值壞導和ICA去除眼電成分之后再做,因為有可能被試眨眼比較頻繁,那這么操作下來,有可能就需要刪掉接近一半的trials數了,刪掉的trials數太多,這個數據也就廢了。所以要將它留到最后一步才做,同時,這個操作也能用來檢查我們前兩步操作是否足夠有效。
我采用的是絕對閾值法,選擇剔除掉超出±100μV的trial。
2020版本的eeglab中默認沒有顯示reject data,file>preference中可以設置用以前版本的GUI界面,如下圖:

然后選擇reject data epochs>reject extreme values

command line顯示:

250/540 trials marked for rejection

也太多了吧…這就要刪掉近一半的trial了,那我還是觀察時域波形,手動刪除不良片段吧。如何確定壞段呢?

疊加平均

保存數據

腦電分類

起初我一直在糾結的是我腦電數據對應的標簽要怎么弄,后來我明白了分段之后EEG數據下有個epoch的字段就是事件類型。
eeglab中可以看到數據的event type,截圖如下:第一位代表的是變量一的標簽,第二位表示變量二的標簽,這個取決于腦電采集過程中的打標設置(255好像是個意外)。其余部分后續補上。

特征提取

分類

  • 劃分訓練集和測試集
  • 調庫,選擇多種分類器訓練以及測試
    參考:
    https://blog.csdn.net/zyb228/article/details/106216744
    https://www.jianshu.com/p/0df08244614a
    https://roses.blog.csdn.net/article/details/106216744
  • 總結

    以上是生活随笔為你收集整理的脑电数据预处理和后续处理(EEGLAB)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。