Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promote on dataset1(Dataset 2a) S05 #15

Open
Sacamore opened this issue Jun 12, 2023 · 2 comments
Open

promote on dataset1(Dataset 2a) S05 #15

Sacamore opened this issue Jun 12, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Sacamore
Copy link

I found that using my preprocessing program below

% 获取文件夹中的所有 gdf 文件
gdfFolder = './BCICIV_2a_gdf/'; % 指定文件夹路径
matFolder = './true_labels/';
outFolder = './Data/';
gdfFiles = dir(fullfile(gdfFolder, '*.gdf')); % 获取文件夹中的所有 gdf 文件
nfiles = length(gdfFiles); % 获取文件个数
disp(nfiles);
% 逐个处理 gdf 文件
for k = 1:nfiles
    % 获取当前文件名
    [gdfpath,gdfname,gdfExt] = fileparts(gdfFiles(k).name); % 获取文件名
    gdfpath = fullfile(gdfFolder, [gdfname,gdfExt]); % 获取完整路径
    matpath = fullfile(matFolder, [gdfname,'.mat']);
    % 读取 gdf 文件
    [signal, HDR] = sload(gdfpath); % 读取信号和头文件
    load(matpath);
    label = classlabel;

    % 获取事件信息
    % Event type   Description
    % 276   0x0114 Idling EEG (eyes open)
    % 277   0x0115 Idling EEG (eyes closed)
    % 768   0x0300 Start of a trial
    % 769   0x0301 Cue onset left (class 1)
    % 770   0x0302 Cue onset right (class 2)
    % 771   0x0303 Cue onset foot (class 3)
    % 772   0x0304 Cue onset tongue (class 4)
    % 783   0x030F Cue unknown
    % 1023  0x03FF Rejected trial
    % 1072  0x0430 Eye movements
    % 32766 0x7FFE Start of a new run
    event_pos = HDR.EVENT.POS; % 获取事件发生的位置(采样点)
    event_typ = HDR.EVENT.TYP; % 获取事件类型(数字编码)
    event_dur = HDR.EVENT.DUR; % 获取事件持续时间(数字)
    
    % 创建数据列表
    data = []; % 创建一个空列表
    cnt = 1;
    for i = 1:length(event_pos) % 对每个事件进行循环
        event_type = event_typ(i); % 获取事件类型
        if event_type == 768 % 如果事件类型为0x0300
            start_pos = event_pos(i) + 500; % 获取事件开始位置
            end_pos = start_pos + event_dur(i) - 1 - 875; % 获取事件结束位置
            data(cnt,:,:) = transpose(signal(start_pos:end_pos,1:22)); % 将信号中对应的信息添加到列表中
            cnt =  cnt + 1;
        end
    end

    data = fillmissing(data,'constant',0);

    % 设计6阶切比雪夫II型带通滤波器
    Fs = HDR.SampleRate; % 采样频率
    Wp = [0.1 60] / (Fs/2); % 通带截止频率归一化
    Ws = [0.05 100] / (Fs/2); % 阻带截止频率归一化
    Rp = 1; % 通带纹波
    Rs = 40; % 阻带衰减
    [n, Wn] = cheb2ord(Wp, Ws, Rp, Rs); % 计算滤波器阶数和截止频率
    [b, a] = cheby2(n, Rp, Wn); % 计算滤波器系数

    % 对信号进行滤波
    for i = 1:length(label)
        data(i,:,:) = filter(b,a,data(i,:,:));
    end
    
    % 保存为 mat 文件
    save([outFolder,gdfname,'.mat'], 'data', 'label'); % 保存为 mat 文件,包括信号、头文件、标记数列和数据列表
    
    % 显示进度信息
    disp(['Processed file ' num2str(k) ' of ' num2str(nfiles)]);
end

% 完成处理
disp('All files processed.');

would efficiently promote on S05 as:

acc: 52.08% --> 76.02%

and the other maintain a mild fluctuation
I believe that it's only a preprocessing problem, hope this will help :D

@eeyhsong
Copy link
Owner

Thanks a lot for your help !!!
Best wishes for your work. 🤝

@eeyhsong eeyhsong pinned this issue Jun 12, 2023
@eeyhsong eeyhsong added the enhancement New feature or request label Jun 12, 2023
@eeyhsong eeyhsong unpinned this issue Jun 14, 2023
@eeyhsong
Copy link
Owner

  • The band-pass filter is different from the one we use, https://github.com/eeyhsong/EEG-Transformer/blob/main/getData.m.
  • The one above almost preserves the full band, but ours preserve ~4-30 Hz.
  • It will be meaningful to explore which frequency band is more suitable for motor imagery (including beta and mu).
    Thanks for your help! 🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants