-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrgData.asv
More file actions
39 lines (31 loc) · 1.17 KB
/
OrgData.asv
File metadata and controls
39 lines (31 loc) · 1.17 KB
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
39
function [EEG,LABELS] = OrgData(fileFolder,trial_num,t_pre,t_post)
SampleRate = 256;
channel_num = 16;
dirOutput=dir(fullfile(fileFolder,'*.mat'));
fileNames={dirOutput.name}';
num_of_sets = length(fileNames);
tp_each_trial = SampleRate*(t_post-t_pre);
LABELS = []; % labels for trials
EEG = []; % data for trials
for count = 1:num_of_sets
load([fileFolder, char(fileNames(count))]);
Temp_EEG = zeros(trial_num, tp_each_trial, channel_num);
% denoise through eeglab
EEGData = Denoise(EEGData,13,30);
onset_stimuli = Stimulus_TimeMark(2:2:end);
for i=1:channel_num
for j=1:trial_num
startPoint = floor(((onset_stimuli(j)+t_pre)*SampleRate+1));
endPoint = floor((onset_stimuli(j)+t_post)*SampleRate);
Temp_EEG(j,:,i)=EEGData(startPoint:endPoint,i);
end
end
if exist Stimulus_Type
Temp_Label = Stimulus_Type(1:trial_num);
else
Temp_Label = [zeros(trial_num,1) -1];
end
LABELS = [LABELS; Temp_Label];
EEG = [EEG; Temp_EEG];
end
end