-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsimulationSEED.m
87 lines (72 loc) · 2.36 KB
/
simulationSEED.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
%% SETUP
clc;
clear;
%close all;
seedPath = 'D:\Downloads\databases\seed\SEED\Preprocessed_EEG\';
fprintf('The path of the database: "%s"\n', seedPath)
% add directories 'utils' and 'libs' to path
% setting the path
rootDir = fileparts(matlab.desktop.editor.getActiveFilename);
eval(['cd ' rootDir])
addpath(genpath([rootDir '/lib']));
addpath(genpath([rootDir '/utils']));
rate = 200;
% Number of samples is different per samples
% Electrodes 62 channels
% todo read csv file
%electrodes = struct()
%% SEED Load Single Analysis
idParticipant = 10; % range 1-15
idSession = 3; % range 1-3
idVideo = 7; % range 1-15
idChannel = 60; % range 1-62
[fullsignal,bands] = loadAndDecomposeSEED(seedPath,idParticipant,idSession,idVideo,idChannel);
gamma = bands(1); beta= bands(2); alpha = bands(3); theta = bands(4); delta = bands(5);
%% DWT Coefficients
titleDescription = {'Gamma (32-64 Hz)' 'Beta (16-32 Hz)' 'Alpha (8-16 Hz)' 'Theta (4-8 Hz)' 'Delta (0-4 Hz)'};
figure
for i = 1:1:5
subplot(5,1,i)
plot(bands(i).coeff)
axis tight; title(titleDescription(i))
end
sgtitle(['Brain Rythms DWT Coefficients | Label: ' fullsignal.label])
%% Reconstruct coefficients in time domain
step = 1/rate;
titleDescription = {'Original full signal' 'Gamma (32-64 Hz)' 'Beta (16-32 Hz)' 'Alpha (8-16 Hz)' 'Theta (4-8 Hz)' 'Delta (0-4 Hz)'};
figure
for i = 1:1:6
subplot(6,1,i)
if i == 1
plot(0:step:step*(numel(fullsignal.samples)-1),fullsignal.samples)
else
plot(0:step:step*(numel(bands(i-1).samples)-1),bands(i-1).samples)
end
axis tight; title(titleDescription(i))
end
sgtitle(['Brain Rythms Time domain | Label: ' fullsignal.label])
%% Bispectrum Direct
%clc;
fprintf('Bispectrum Direct started ...\n')
% Available options to pass:
% 'fullsignal','gamma','beta','alpha','theta','delta'
signalToTest = fullsignal;
samples = signalToTest.samples;
M = fix(numel(signalToTest.samples)/16)
nfft = 2^nextpow2(M);
freqBins = rate/(2^nextpow2(M))
overlap = 10;
display = 1;
tic
[bispd, waxis] = bispecd(samples,nfft,5,M,rate,overlap,display);
toc
tic
%[bicod, waxis] = bicoher(samples,nfft,0,M,rate,overlap,display);
toc
% frequency spectrum
% nfft = 2^nextpow2(numel(samples))
% psd = abs(fftshift(fft(samples)));
% fshift = [-nfft/2:nfft/2-1]'*rate/nfft;
% figure
% plot(fshift,psd);
fprintf('Bispectrum Direct finished ...\nWaiting for the plots ...\n')