0

我目前正在做一个关于 BCI 运动图像数据集的项目。我的兴趣是通过 ICA 方法提取必要的组件。我目前正在为此目的使用 EEGLAB。您能否帮助我了解如何将自变量从 GUI 提取到 MATLAB 的工作区?

4

2 回答 2

1

在 eeglab 中的数据集上运行 ICA 后,ICA 权重保存在结构中的icaweights矩阵中EEG(当您的数据加载到 eeglab 中时,您可以在工作区中看到EEG结构),以便转换icaweights为您在 中看到的信号plot>Component Activations,假设这是您要提取,请执行以下操作:

  1. 首先,您需要加载数据,file>load existing dataset.
  2. 选择要提取的组件并将它们保存为矢量。作为示例,我将选择组件 5 和 9:

    comp_idx = [5 9]; %id of channels we extract
    
  3. 将通道数据(此处表示Y)转换为 ICA 激活(Y_ICA),如下所示:

    Y = EEG.data;   % set channel data to matrix Y
    ica_weights = EEG.icaweights; % copy icaweights matrix
    Y_ICA = ica_weights*Y; % Component Activations
    
  4. Y_ICA 现在包含所有组件激活,用于Y_ICA(comp_idx,:)仅提取您需要的组件,您可以对这个新矩阵进行操作,例如对两个组件求和并绘制:

    %% Mix components and plot
    figure;
    S = sum( Y_ICA(comp_idx,:) );
    plot(EEG.times, S, 'r')    % EEG.times contains the time data
    title('Mix of all Channels')
    
  5. 或者分别绘制每个组件:

    %% Plot each component
    figure;
    plot( EEG.times, Y_ICA(comp_idx(1),:))
    hold on
    plot( EEG.times, Y_ICA(comp_idx(2),:))
    

注意:如果您的数据由时期组成,那么EEG.data矩阵将是一个三维矩阵,第三维是时期集,因此您必须对每个时期执行上述过程,即Y = EEG.data(:,:,epoch_i)迭代epoch_i = 1:size(EEG.data,3)

于 2017-04-04T20:49:09.920 回答
0

我不确定 ReZzT 的回答是否完全正确。

查看 eeg_getdatact.m 文件

edit eeg_getdatact

可以看出,组件激活是通过额外的矩阵乘法计算的(使用 icasphere)。查看第 179-180 行:

data = eeg_getdatact( EEG ); 
data = (EEG.icaweights(opt.component,:)*EEG.icasphere)*data(EEG.icachansind,:);

简化后,最后一行可以写成:

data = (EEG.icaweights*EEG.icasphere)*eegdata;
于 2019-05-17T22:22:20.470 回答