-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdataproc_main_b_sample.m
40 lines (35 loc) · 1.34 KB
/
dataproc_main_b_sample.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
%% Main program for data processing on sample (online data)
% function [Sdimdata_sample] = dataproc_main_training (Binsize, Smat,
% SourceData)
%
% Inputs:
% Binsize and Smat are obtained from calling dataproc_main_training on the
% training data. They must be the same for both training and online sample
% SourceData = Matrix of Windowed Raw Data (#chans, #samps) or
% (#chans, #samps, #trials)
% Output: Sdimdata_sample is ready to be transformed by Fmat.
%
function [Sdimdata_sample] = dataproc_main_testing (Binsize, Smat, SourceData)
%% Gather the dimensions
if iscell(SourceData) || length(size(SourceData)) < 2
error('SourceData must be a 2D or 3D matrix');
end
%% Binning and reshaping
DimData = dataproc_func_binning(SourceData,Binsize);
%% Sphereing transformation
Sdimdata_sample = Smat * DimData;
clear('DimData');
%% Example code
% Fs = 200;
% M = 2; % Feature space dimension
% [Fmat, Flabel, Smat, Sinvmat, Binsize, Sdimdata_training] = dataproc_main_training(Fs, M, {TrainingEEG.moveleft, TrainingEEG.moveright});
% Ftrain = Fmat * Sdimdata_training;
% Sdimdata_online = dataproc_main_sample(Binsize, Smat, OnlineEEG);
% Fonline = Fmat * Sdimdata_online;
% CQ = classify(Fonline', Ftrain', Flabel, 'quadratic', 'empirical');
% switch CQ
% case 0
% disp('decoded to be LEFT');
% case 1
% disp('decoded to be RIGHT');
% end