forked from idangrady/BrainIO_Hackd09_P300
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
39 lines (31 loc) · 878 Bytes
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
%% Load all data, segmenting into each trial
dat1 = load("./Data/S1.mat");
dat2 =load("./Data/S2.mat");
dat3 =load("./Data/S3.mat");
dat4 =load("./Data/S4.mat");
dat5 =load("./Data/S5.mat");
dat = {dat1,dat2,dat3,dat4,dat5};
findat = {};
fintar = {};
for indexs = 1:numel(dat)
gbp = dat{indexs};
A = gbp.trig;
A1 = gbp.y;
b = [1, -1];
c = ismember(A, b);
% Extract the elements of a at those indexes.
indexes = find(c);
start_index = [indexes; size(A, 1) + 1] - 25 %100ms pre;
end_index = start_index + 100; % 400ms post trigger
n = numel(start_index) - 1;
Result = cell(1, n);
for k = 1:n
Result{k} = A1(start_index(k):end_index(k)-1, :);
end
% adding segmented trials to data
gbp.dat = Result;
gbp.trig = nonzeros(gbp.trig);
gbp.y = [];
dat{indexs} = gbp;
end
save("data.mat",'dat');