-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMI_Class_draw.asv
50 lines (36 loc) · 1.46 KB
/
MI_Class_draw.asv
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
function [] = MI_Class_draw(directory_name,features,granularity_Hz)
[flat_data_signal, flat_categories] = MI_signal_processing(directory_name,features,false,true);
names = split(directory_name,'\');
frequency = mod(features,50);
res = reshape(flat_data_signal,size(flat_data_signal,1),513,[]);
cat_set = unique(flat_categories);
gavgA = reshape(mean(res(flat_categories==cat_set(1) ,:,:),1),513,[])';
gavgB = reshape(mean(res(flat_categories==cat_set(2) ,:,:),1),513,[])';
psd_A = pwelch(gavgA',512)';
psd_B = pwelch(gavgB',512)';
psd_A = movsum(psd_A,[0,granularity_Hz-1]);
psd_B = movsum(psd_B,[0,granularity_Hz-1]);
load('chanlocs16.mat');
freq_list = [];
for i=1:length(frequency)
if any(frequency(i) == freq_list)
continue
end
figure()
sgtitle(names(end-1) + ' Offline PSD with ' + num2str(frequency(i)) + '-' + num2str(frequency(i)+granularity_Hz-1) + 'Hz');
subplot(1,2,1)
title(cat_set(1));
topoplot(psd_A(17*(i-1)+1:17*i,frequency(i)),chanlocs16 );
subplot(1,2,2)
title(cat_set(2));
topoplot(psd_B(17*(i-1)+1:17*i,frequency(i)),chanlocs16 );
freq_list = [freq_list frequency(i)];
end
cat_set = unique(flat_categories);
A_DATA = flat_data_signal(flat_categories==cat_set(1),:);
B_DATA = flat_data_signal(flat_categories==cat_set(2),:);
end
function y = vec_linspace(start, goal, steps)
x = linspace(0,1,steps);
y = start * ones(1, steps) + (goal - start)*x;
end