Switch to unified view

a b/code/preprocessing/EEG/EEG_main2.m
1
clear;clc;
2
target_fs = 500; %Hz
3
raw_fs=512;
4
%% 1. prepare files
5
% 1.1 load data
6
data_path='E:\LeftRight_Hand_MI';
7
data_file = 's01.mat';
8
fid = [data_path, filesep, data_file];
9
load(fid);
10
11
fs = eeg.srate;
12
EEG_channels = 1:64;
13
EEG_data1 = eeg.movement_left; % there are multiple datasets in eeg, make sure use all of them. eg: eeg.movement_right
14
EEG_data1 = EEG_data1(EEG_channels, :);
15
16
EEG_data2 = eeg.movement_right; % there are multiple datasets in eeg, make sure use all of them. eg: eeg.movement_right
17
EEG_data2 = EEG_data2(EEG_channels, :);
18
19
EEG_data3 = eeg.imagery_left; % there are multiple datasets in eeg, make sure use all of them. eg: eeg.movement_right
20
EEG_data3 = EEG_data3(EEG_channels, :);
21
22
EEG_data4 = eeg.imagery_right; % there are multiple datasets in eeg, make sure use all of them. eg: eeg.movement_right
23
EEG_data4 = EEG_data4(EEG_channels, :);
24
25
EEG_data5 = eeg.rest; % there are multiple datasets in eeg, make sure use all of them. eg: eeg.movement_right
26
EEG_data5 = EEG_data5(EEG_channels, :);
27
28
29
30
% 1.2 prepare electrodes locations
31
load('biosemi_template.mat');
32
% check if the locations are the same to data description
33
topoplot([], locs, 'electrodes', 'ptslabels', 'plotdisk', 'on');
34
35
%% Use the method of ICA and IClabel
36
37
38
EEG_epochs1 = IC_label_artifact_removal( EEG_data1, fs, target_fs,locs,EEG_channels);
39
EEG_epochs2 = IC_label_artifact_removal( EEG_data2, fs, target_fs,locs,EEG_channels);
40
EEG_epochs3 = IC_label_artifact_removal( EEG_data3, fs, target_fs,locs,EEG_channels);
41
EEG_epochs4 = IC_label_artifact_removal( EEG_data4, fs, target_fs,locs,EEG_channels);
42
EEG_epochs5 = IC_label_artifact_removal( EEG_data5, fs, target_fs,locs,EEG_channels);
43
44
EEG_epochsall=[EEG_epochs1;EEG_epochs2;EEG_epochs3;EEG_epochs4;EEG_epochs5;]
45
46
47
%% 3. visual check
48
EEG_epochsall = visual_check(EEG_epochsall, target_fs);
49
50
51
%% save
52
53
output = 'C:\DL_denoising_data_cut\EEG_output';
54
save([output, filesep, 'EEG_epochs_s01','.mat'], 'EEG_epochsall');
55
%writeNPY(EEG_epochs, [output, filesep, 'EEG_epochs_Cz', char(film_list(film_id)),'.npy']);
56
57