|
a |
|
b/preprocessing/BCIIV2b.m |
|
|
1 |
% An example to get the BCI competition IV datasets 2b, only for reference |
|
|
2 |
% Data from: http://www.bbci.de/competition/iv/ |
|
|
3 |
% using open-source toolbox Biosig on MATLAB: http://biosig.sourceforge.net/ |
|
|
4 |
% Just an example, you should change as you need. |
|
|
5 |
|
|
|
6 |
% get processed T data |
|
|
7 |
function data = process(subject_index) |
|
|
8 |
|
|
|
9 |
%% BioSig Get the data |
|
|
10 |
% T data |
|
|
11 |
% subject_index = 1; %1-9 |
|
|
12 |
session_type = 'E'; |
|
|
13 |
dir = ['D:\MI\BCICIV_2b_gdf\B0',num2str(subject_index),'05',session_type,'.gdf']; |
|
|
14 |
[s, HDR] = sload(dir); |
|
|
15 |
|
|
|
16 |
% Label |
|
|
17 |
% label = HDR.Classlabel; |
|
|
18 |
labeldir = ['D:\MI\2b_true_labels\B0',num2str(subject_index),'05',session_type,'.mat']; |
|
|
19 |
load(labeldir); |
|
|
20 |
label = classlabel; |
|
|
21 |
|
|
|
22 |
% construct sample - data Section 1000*22*288 |
|
|
23 |
Pos = HDR.EVENT.POS; |
|
|
24 |
% Dur = HDR.EVENT.DUR; |
|
|
25 |
Typ = HDR.EVENT.TYP; |
|
|
26 |
|
|
|
27 |
k = 0; |
|
|
28 |
data_1 = zeros(1000,3,120); |
|
|
29 |
for j = 1:length(Typ) |
|
|
30 |
if Typ(j) == 768 |
|
|
31 |
k = k+1; |
|
|
32 |
data_1(:,:,k) = s((Pos(j)+750):(Pos(j)+1749),1:3); |
|
|
33 |
end |
|
|
34 |
end |
|
|
35 |
|
|
|
36 |
% wipe off NaN |
|
|
37 |
data_1(isnan(data_1)) = 0; |
|
|
38 |
|
|
|
39 |
data = data_1; |
|
|
40 |
pindex = randperm(120); |
|
|
41 |
data = data(:, :, pindex); |
|
|
42 |
label = label(pindex); |
|
|
43 |
|
|
|
44 |
% 4-40 Hz |
|
|
45 |
fc = 250; |
|
|
46 |
fb_data = zeros(1000,3,120); |
|
|
47 |
|
|
|
48 |
Wl = 4; Wh = 40; % ͨΧ |
|
|
49 |
Wn = [Wl*2 Wh*2]/fc; |
|
|
50 |
[b,a]=cheby2(6,60,Wn); |
|
|
51 |
for j = 1:120 |
|
|
52 |
fb_data(:,:,j) = filtfilt(b,a,data(:,:,j)); |
|
|
53 |
end |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
% eeg_mean = mean(fb_data,3); |
|
|
57 |
% eeg_std = std(fb_data,1,3); |
|
|
58 |
% fb_data = (fb_data-eeg_mean)./eeg_std; |
|
|
59 |
|
|
|
60 |
data = fb_data; |
|
|
61 |
|
|
|
62 |
saveDir = ['D:\MI\standard_2b_data\strict_TE\B0',num2str(subject_index),'05E.mat']; |
|
|
63 |
save(saveDir,'data','label'); |
|
|
64 |
|
|
|
65 |
end |
|
|
66 |
|
|
|
67 |
|