-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEEGtest.m
97 lines (83 loc) · 2.18 KB
/
EEGtest.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
88
89
90
91
92
93
94
%% 2014-09-26
%% edit 2017-01-14
%% agoramachina
%% Loads and plots EEG data
%% Initialization
clear ; close all; clc
%% Fixes Qt crash bug
graphics_toolkit('gnuplot')
%% Load EEG data
printf("loading EEG data...\n");
EEGdata = csvread('data.csv');
EEGdata = EEGdata(2:end,:);
%% Only include changes
%for m=1 : 15
% d = 1;
% for n=1 : size(EEGdata)(1,1)
% if n > 1 && EEGdata(n,m) != EEGdata(n-1,m)
% EEGdelta(d,m) = (EEGdata(n,m));
% d = d + 1;
% end
% %% debug stuff
% printf("%d: %d \n", m, n);
% fflush(stdout);
% end
%end
%% Set variables
printf("setting variables...\n");
timestampMs = EEGdata(:,1);
poorSignal = EEGdata(:,2);
eegRawValue = EEGdata(:,3);
eegRawValueVolts = EEGdata(:,4);
attention = EEGdata(:,5);
meditation = EEGdata(:,6);
blinkStrength = EEGdata(:,7);
delta = EEGdata(:,8);
theta = EEGdata(:,9);
alphaLow = EEGdata(:,10);
alphaHigh = EEGdata(:,11);
betaLow = EEGdata(:,12);
betaHigh = EEGdata(:,13);
gammaLow = EEGdata(:,14);
gammaMid = EEGdata(:,15);
%tagEvent = EEGdata(:,16);
%location = [lat,long] = EEGdata(:,17);
%% Define colors
red = [1,0,0];
orange = [1,.5,0];
yellow = [1,1,0];
green = [.5,1,0];
cyan = [0,1,1];
blue = [0,0,1];
purple = [.5,0,1];
pink = [1,0,1];
%% Plot data
x = timestampMs - 1411778000000;
%% Plot EEG raw value
plot(eegRawValue);
xlimits = xlim([1, 1000]);
title('EEG Raw Value');
xlabel('Time');
figure;
%% Plot Attention and Meditation
plot(attention, "g", meditation, "b");
title('Focus');
xlabel('Time');
legend('Attention', 'Meditation', "show");
figure();
%% Plot all brainwaves
semilogy(x, gammaMid, 'color', [1,0,0], "linewidth", 1,
x, gammaLow, 'color', [1,.5,0], "linewidth", 1,
x, betaHigh, 'color', [1,1,0], "linewidth", 1,
x, betaLow, 'color', [.5,1,0], "linewidth", 1,
x, alphaHigh, 'color', [0,1,1],"linewidth", 1,
x, alphaLow, 'color', [0,0,1], "linewidth", 1,
x, theta, 'color', [.5 0 1], "linewidth", 1,
x, delta, 'color', [1,0,1], "linewidth", 1);
set(gca, 'color', [.85,.85,.85]);
set(gcf, 'color', [.95,.95,.95]);
legend('gammaMid', 'gammaLow', 'betaHigh', 'betaLow', 'alphaHigh', 'alphaLow', 'theta', 'delta');
legend location eastoutside;
title('Brainwaves');
xlabel('Time');
ylabel('Activity');