-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssvep_classification.m
39 lines (32 loc) · 1.3 KB
/
ssvep_classification.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
%% Classification of SSVEP signals on my dataset using decision tree
clearvars
clc
close all
fs = 1000;
windowTimes = [1 2 3 4 5];
freqRanges = [.05 .1 .2 .3 .4];
figure()
t = tiledlayout(5,5, TileSpacing="compact", Padding="compact");
% For every window length
for windowTime = windowTimes
% For every frequency range
for freqRange = freqRanges
nexttile
% Create the [X,Y] matrices from my dataset
[X1,Y1] = createDataset(6, windowTime, freqRange, fs);
[X2,Y2] = createDataset(7.4, windowTime, freqRange, fs);
X = cat(2,X1,X2); % input matrix: maximum values of fft around targetFreqs
Y = Y1 + (2*Y2); % labels: 1=6Hz, 2=7.4Hz, 0=no_freq
% Find the best threshold for classification
bestThreshold6 = find_best_threshold(X1,Y1,1);
bestThreshold7_4 = find_best_threshold(X2,Y2,1);
% Classify the data
y_pred = SSVEP_classifier(X, bestThreshold6, bestThreshold7_4);
% Compute confusion matrix
C = confusionmat(Y, y_pred, "Order", [1 2 0]);
cm = confusionchart(C,["6 Hz" "7.4 Hz" "null"]);
cm.RowSummary = 'row-normalized';
cm.Title = sprintf("WindowTime = %ds, freqRange = %.2fHz", windowTime, freqRange);
end
end
title(t, "SSVEP classification on my dataset")