-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathglobal_topographic_measures.m
68 lines (58 loc) · 1.99 KB
/
global_topographic_measures.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
function [OUTEEG, com] = global_topographic_measures( INEEG, typeproc, frame_start, frame_end );
% the command output is a hidden output that does not have to
% be described in the header
com = ''; % this initialization ensure that the function will return something
% if the user press the cancel button
OUTEEG = INEEG;
% display help if not enough arguments
% ------------------------------------
if nargin < 2
help global_topographic_measures;
return;
end;
% pop up window
% -------------
if nargin < 3
promptstr = { 'Plot from frame nr:', 'Plot to frame nr:' };
inistr = { '1',num2str(OUTEEG.srate) };
result = inputdlg( promptstr, 'Plot topographic measures', 1, inistr);
if length( result ) == 0 return; end;
frame_start = eval( [ '[' result{1} ']' ] ); % the brackets allow to process matlab arrays
frame_end = eval( [ '[' result{2} ']' ] ); % the brackets allow to process matlab arrays
if frame_end > OUTEEG.pnts
frame_end = OUTEEG.pnts
end
end;
% call function sample either on raw data or ICA data
% ---------------------------------------------------
if typeproc == 1
dat = OUTEEG.data(:,frame_start:frame_end);
OUTEEG.gtm = std(dat,[],1);
%tend = 500;
figure;
x = OUTEEG.times(frame_start:frame_end);
x = x(2:end);
gfp = OUTEEG.gtm(2:end);
gmd = GMD(dat(:,1:end-1),dat(:,2:end),OUTEEG.nbchan);
R = corrcoef(gfp,gmd);
subplot(211)
suptitle(['Global Topographic Measures ', num2str(R(1,2))])
plot(x, gfp)
title('Global Field Power')
subplot(212)
plot(x, gmd);
xlabel('ms');
%ylabel('Standard deviation across channes');
title('Global Map Dissimilarity')
else
if ~isempty( OUTEEG.icadata )
sample( OUTEEG.icadata );
else
error('You must run ICA first');
end;
end;
% return the string command
% -------------------------
com = sprintf('global_topographic_measures( %s, %d, [%s] );', inputname(1), typeproc, int2str(frame_start), int2str(frame_end));
return;
end