-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOverallAverageBandpower.m
More file actions
115 lines (85 loc) · 2.64 KB
/
OverallAverageBandpower.m
File metadata and controls
115 lines (85 loc) · 2.64 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
%% Band power for Entire Run
%
% This program calculates the bandpower in chunks of n minutes
% (non-overlapping) for the entire run of a subject and reports the average
% of these measurements.
%
% MDT
% 2017-09-01
%% Setup and Constants
%
% Time and Frequency Constants:
Fs = 128; % Samples per Second of the EEG System
oneMinute = 60 * Fs; % Samples in 1 minute (60*128)
n = 2; % Number of minutes to use for FFT window
windowLen = n * oneMinute;
% Other Constants:
numChannels = 14;
channels = 1:numChannels;
%% Three Nested Loops
% Loop over files
% Loop over
%% for one channel:
vp=[];
for k = startpoints(1:end-1)
[s, t, a, b] = EEGBandProportions(d(channel, k:(k+m)), Fs);
vp = [vp; s t a b];
end
%% for all channels
vp=[];
for k = startpoints(1:end-1)
[s, t, a, b] = EEGBandProportions(d(channel, k:(k+m)), Fs);
vp = [vp; s t a b];
end
%%% Draft code below this
%Bandpower Loop
listOfFiles = dir('*.set');
numberOfFiles = length(listOfFiles);
for jj = 1:numberOfFiles
f = listOfFiles(jj).name; %list of names
x = pop_loadset(f); %loads data
len =x.pnts;
d=x.data;
startpoints=1:oneMinute:len;
vp= [];
for k= startpoints(1:end-1)
b=bandpower(d(channel, k:(k+m)),Fs,[8 13])/ bandpower(d(channel, k:(k+m)), Fs, [1 41]);
vp=[vp; b]
end
k= startpoints(1:end-1);
b=bandpower(d(channel, k:(k+m)),Fs,[8 13])/ bandpower(d(channel, k:(k+m)), Fs, [1 41]);
vp=[vp b]
%plot(vp)
avp = mean(vp)
pause
end
% %printing files
% for s= 1:numberOfFiles
% f= listOfFiles(s).name;
% EEG=pop_loadset(f);
% len=EEG.pnts;
% r=(len/128)/60;
% fprintf('%s\t %g \n', f, r);
% end
%% Auxillary Functions
%
% To make the code easier to read, we sometimes define "functions" to
% encapsulate bits of our work.
% % % function [deltaP, thetaP, alphaP, betaP] = bandProportions(wave, Fs)
% % %
% % % % bandProportions.m
% % % %
% % % % Computes the power in each band, then converts these to proportions.
% % %
% % % bandDelta = [ 1 4]; % Due to filtering, everything < 1 Hz ~0
% % % bandTheta = [ 4 8];
% % % bandAlpha = [ 8 14]; % Wikipedia's alpha (Electroencphalography Article)
% % % bandBeta = [14 31];
% % % bandAll = [ 1 31];
% % %
% % % deltaP = bandpower(wave, Fs, bandDelta) ./ bandpower(wave, Fs, bandAll);
% % % thetaP = bandpower(wave, Fs, bandTheta) ./ bandpower(wave, Fs, bandAll);
% % % alphaP = bandpower(wave, Fs, bandAlpha) ./ bandpower(wave, Fs, bandAll);
% % % betaP = bandpower(wave, Fs, bandBeta) ./ bandpower(wave, Fs, bandAll);
% % %
% % % end