-
Notifications
You must be signed in to change notification settings - Fork 4
/
train_HEAR.m
63 lines (46 loc) · 1.71 KB
/
train_HEAR.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
% HEAR traning demonstration script
% Copyright (C) 2019 Reinmar Kobler, Graz University of Technology, Austria
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as published
% by the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
%
st = dbstack;
if length(st) < 2
clear all
close all
clc
% parameters
file_name = 'demo_simrest';
is_causal = true;
data_root_dir = './';
end
%% load the dataset
EEG = pop_loadset([file_name '.set'], data_root_dir);
[ALLEEG, EEG, CURRENTSET] = eeg_store({}, EEG);
ALL_DS_IDX = CURRENTSET;
EEG = pop_select(EEG, 'trial', 1:8);
EEG.etc = struct;
if exist('eeg_chantype', 'file') % eeglab version 14 and before
eeg_chan_idxs = eeg_chantype(EEG, 'EEG');
else % eeglab version 2019
eeg_chan_idxs = eeg_decodechan(EEG.chanlocs, 'EEG', 'type');
end
EEG = pop_select(EEG, 'channel', eeg_chan_idxs);
%% load the channels interpolation distance matrix
D = utl_chaninterpmatrix(EEG.chanlocs, 4);
%% fit HEAR to the calibration data
hear_mdl = HEAR(EEG.srate, is_causal, [], [], D);
hear_mdl.train(EEG.data(:,:));
save([data_root_dir 'mdl_HEAR.mat'], 'hear_mdl');
disp('HEAR successfully trained.');