|
a |
|
b/preprocessing/seed.m |
|
|
1 |
% An example to get the SEED dataset |
|
|
2 |
% Just an example, you should change as you need. |
|
|
3 |
|
|
|
4 |
% band pass to 4-47 Hz, standardization |
|
|
5 |
% 15 subjects - 3 sessions - 15 trials |
|
|
6 |
% sample rate 200 Hz |
|
|
7 |
% label: -1 for negative, 0 for neutral and +1 for positive |
|
|
8 |
% label changes to 0 1 2 |
|
|
9 |
|
|
|
10 |
% Save file S1_1_1 (channels, samples) |
|
|
11 |
|
|
|
12 |
file_list = load('./seed_file/namefile_list.mat'); |
|
|
13 |
file_list = file_list.namefile_list; |
|
|
14 |
short_name = load('./seed_file/short_name.mat'); |
|
|
15 |
short_name = short_name.short_name; |
|
|
16 |
label = load('./seed_file/label.mat'); |
|
|
17 |
fc = 200; |
|
|
18 |
Wl = 4; Wh = 47; |
|
|
19 |
Wn = [Wl*2 Wh*2]/fc; |
|
|
20 |
[b,a]=cheby2(6,60,Wn); |
|
|
21 |
|
|
|
22 |
for i = 1:15 % subject |
|
|
23 |
for j = 1:3 % session |
|
|
24 |
file_pre = file_list(i,j); |
|
|
25 |
file_path = strcat('/Datasets/SEED/Preprocessed_EEG/',file_pre,'.mat'); |
|
|
26 |
session_data = load(file_path); |
|
|
27 |
for k = 1:15 % trial |
|
|
28 |
trial_data = eval(strcat('session_data.',short_name(i),'_eeg',num2str(k))); |
|
|
29 |
% trial_data = filtfilt(b,a,trial_data); |
|
|
30 |
trial_mean = mean(trial_data,2); |
|
|
31 |
trial_std = std(trial_data,1,2); |
|
|
32 |
trial_data = (trial_data-trial_mean)./trial_std; |
|
|
33 |
trial_data = filtfilt(b,a,trial_data); |
|
|
34 |
trial_label = label.label(k); |
|
|
35 |
saveDir = strcat('/Datasets/SEED/seed_save/S',num2str(i),'_',num2str(j),'_',num2str(k),'.mat'); |
|
|
36 |
save(saveDir,'trial_data','trial_label'); |
|
|
37 |
end |
|
|
38 |
end |
|
|
39 |
end |
|
|
40 |
|