Skip to content

Commit 30c6301

Browse files
author
StefanHaufe
committed
alphalevel changed
1 parent 3cc24b2 commit 30c6301

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

demos/demo_analysis_ga_ERPs.m

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
files = {'VPibv_10_11_02\calibration_CenterSpellerMVEP_VPibv',
2+
'VPibq_10_09_24\calibration_CenterSpellerMVEP_VPibq',
3+
'VPiac_10_10_13\calibration_CenterSpellerMVEP_VPiac',
4+
'VPibs_10_10_20\calibration_CenterSpellerMVEP_VPibs',
5+
'VPibt_10_10_21\calibration_CenterSpellerMVEP_VPibt'};
6+
7+
nsub = length(files);
8+
for isub = 1:nsub
9+
file = files{isub};
10+
%% Load data
11+
hdr= file_readBVheader(file);
12+
Wps= [42 49]/hdr.fs*2;
13+
[n, Ws]= cheb2ord(Wps(1), Wps(2), 3, 40);
14+
[filt.b, filt.a]= cheby2(n, 50, Ws);
15+
[cnt, mrk_orig]= file_readBV(file, 'Fs',100, 'Filt',filt);
16+
17+
%% Marker struct
18+
stimDef= {[31:46], [11:26];
19+
'target','nontarget'};
20+
mrk= mrk_defineClasses(mrk_orig, stimDef);
21+
22+
%% Re-referencing to linked-mastoids
23+
A= eye(length(cnt.clab));
24+
iA1= util_chanind(cnt.clab,'A1');
25+
if isempty(iA1)
26+
iA1= util_chanind(cnt.clab,'A2');
27+
end
28+
A(iA1,:)= -0.5;
29+
A(:,iA1)= [];
30+
cnt= proc_linearDerivation(cnt, A);
31+
32+
%% Electrode Montage
33+
grd= sprintf(['scale,_,F5,F3,Fz,F4,F6,_,legend\n' ...
34+
'FT7,FC5,FC3,FC1,FCz,FC2,FC4,FC6,FT8\n' ...
35+
'T7,C5,C3,C1,Cz,C2,C4,C6,T8\n' ...
36+
'P7,P5,P3,P1,Pz,P2,P4,P6,P8\n' ...
37+
'PO9,PO7,PO3,O1,Oz,O2,PO4,PO8,PO10']);
38+
mnt= mnt_setElectrodePositions(cnt.clab);
39+
mnt= mnt_setGrid(mnt, grd);
40+
41+
% Define some settings
42+
disp_ival= [-200 1000];
43+
ref_ival= [-200 0];
44+
crit_maxmin= 70;
45+
crit_ival= [100 800];
46+
crit_clab= {'F9,z,10','AF3,4'};
47+
clab= {'Cz','PO7'};
48+
colOrder= [1 0 1; 0.4 0.4 0.4];
49+
50+
% Apply highpass filter to reduce drifts
51+
b= procutil_firlsFilter(0.5, cnt.fs);
52+
cnt= proc_filtfilt(cnt, b);
53+
54+
% Artifact rejection based on variance criterion
55+
%mrk= reject_varEventsAndChannels(cnt, mrk, disp_ival, 'verbose', 1);
56+
57+
% Segmentation
58+
epo= proc_segmentation(cnt, mrk, disp_ival);
59+
60+
% Artifact rejection based on maxmin difference criterion on frontal chans
61+
[epo iArte] = proc_rejectArtifactsMaxMin(epo, crit_maxmin, 'Clab',crit_clab, ...
62+
'Ival',crit_ival, 'Verbose',1);
63+
64+
% Baseline subtraction, and calculation of a measure of discriminability
65+
epo= proc_baseline(epo, ref_ival);
66+
67+
epos_av{isub} = proc_average(epo, 'Stats', 1);
68+
69+
% three different but almost equivalent ways to make statistics about class differences
70+
epos_diff{isub} = proc_classmeanDiff(epo, 'Stats', 1);
71+
epos_r{isub} = proc_rSquareSigned(epo, 'Stats', 1);
72+
% epos_auc{isub} = proc_aucValues(epo, 'Stats', 1);
73+
74+
end
75+
76+
% grand average
77+
epo_av = proc_grandAverage(epos_av, 'Average', 'INVVARweighted', 'Stats', 1, 'Bonferroni', 1, 'Alphalevel', 0.01);
78+
epo_r = proc_grandAverage(epos_r, 'Average', 'INVVARweighted', 'Stats', 1, 'Bonferroni', 1, 'Alphalevel', 0.01);
79+
epo_diff = proc_grandAverage(epos_diff, 'Average', 'INVVARweighted', 'Stats', 1, 'Bonferroni', 1, 'Alphalevel', 0.01);
80+
% epo_auc = proc_grandAverage(epos_auc, 'Average', 'INVVARweighted', 'Stats', 1, 'Bonferroni', 1, 'Alphalevel', 0.01);
81+
82+
mnt = mnt_setElectrodePositions(epo_av.clab);
83+
mnt= mnt_setGrid(mnt, grd);
84+
85+
% Select some discriminative intervals, with constraints to find N2, P2, P3 like components.
86+
constraint= ...
87+
{{-1, [100 300], {'I#','O#','PO7,8','P9,10'}, [50 300]}, ...
88+
{1, [200 350], {'P3-4','CP3-4','C3-4'}, [200 400]}, ...
89+
{1, [400 500], {'P3-4','CP3-4','C3-4'}, [350 600]}};
90+
[ival_scalps, nfo]= ...
91+
select_time_intervals(epo_r, 'Visualize', 0, 'VisuScalps', 1, ...
92+
'Title', util_untex(file), ...
93+
'Clab',{'not','E*'}, ...
94+
'Constraint', constraint);
95+
%printFigure('r_matrix', [18 13]);
96+
ival_scalps= visutil_correctIvalsForDisplay(ival_scalps, 'fs',epo.fs);
97+
98+
% plot classwise grand-average ERPs
99+
fig_set(1);
100+
H= plot_scalpEvolutionPlusChannel(epo_av, mnt, clab, ival_scalps, defopt_scalp_erp, ...
101+
'ColorOrder',colOrder);
102+
grid_addBars(epo_r);
103+
%printFigure(['erp_topo'], [20 4+5*size(epo.y,1)]);
104+
105+
% plot difference of the class means
106+
fig_set(2, 'shrink',[1 2/3]);
107+
plot_scalpEvolutionPlusChannel(epo_diff, mnt, clab, ival_scalps, defopt_scalp_r);
108+
%printFigure(['erp_topo_r'], [20 9]);
109+
110+
% plot signed log10 p-values of the null hypothesis
111+
% that the difference of the class means is zero
112+
% interpretation: abs(sgnlogp) > 1 <--> p < 0.1
113+
% abs(sgnlogp) > 2 <--> p < 0.01
114+
% abs(sgnlogp) > 3 <--> p < 0.001 , and so on
115+
fig_set(3, 'shrink',[1 2/3]);
116+
epo_diff_sgnlogp = epo_diff;
117+
epo_diff_sgnlogp.x = epo_diff_sgnlogp.sgnlogp;
118+
epo_diff_sgnlogp.yUnit = 'sgnlogp';
119+
plot_scalpEvolutionPlusChannel(epo_diff_sgnlogp, mnt, clab, ival_scalps, defopt_scalp_r);
120+
%printFigure(['erp_topo_r'], [20 9]);
121+
122+
% now plot differences again, with all insignificant results set to zero
123+
epo_diff.x = epo_diff.x.*epo_diff.sigmask;
124+
fig_set(4, 'shrink',[1 2/3]);
125+
plot_scalpEvolutionPlusChannel(epo_diff, mnt, clab, ival_scalps, defopt_scalp_r);
126+

0 commit comments

Comments
 (0)