-
Notifications
You must be signed in to change notification settings - Fork 2
/
erf_osc_analysis_stat_glm_erf.m
executable file
·71 lines (52 loc) · 1.85 KB
/
erf_osc_analysis_stat_glm_erf.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
function erf_osc_analysis_stat_glm_erf(freqRange, zeropoint, erfoi)
if nargin<1 || isempty(freqRange)
freqRange = 'high';
end
if nargin<2 || isempty(zeropoint)
zeropoint = 'reversal';
end
if nargin<3 || isempty(erfoi)
erfoi = 'reversal';
end
% initiate diary
ft_diary('on')
%% load data
erf_osc_datainfo;
for subj=allsubs
tmp{subj} = load(sprintf('/project/3011085.02/analysis/erf/sub-%03d/sub-%03d_glm_tf_%s_%s_erf_%s.mat', subj, subj, freqRange, zeropoint, erfoi));
betas{subj} = tmp{subj}.betas;
betas_bl{subj} = tmp{subj}.betas;
end
clear tmp
%% prepare for statistics
% get grand average
cfg = [];
cfg.appenddim = 'rpt';
betas_GA = ft_appendfreq(cfg, betas{allsubs});
betas_bl_GA = ft_appendfreq(cfg, betas_bl{allsubs});
%% Do statistics
Nsub = length(allsubs);
cfg = [];
cfg.method = 'template';
cfg.feedback = 'no';
neighbours = ft_prepare_neighbours(cfg, betas_GA); % define neighbouring channels
cfg = [];
cfg.channel = 'MEG';
cfg.neighbours = neighbours;
cfg.parameter = 'powspctrm';
cfg.method = 'montecarlo';
cfg.statistic = 'ft_statfun_depsamplesT';
cfg.alpha = 0.05;
cfg.correctm = 'cluster';
cfg.clusteralpha = 0.05;
cfg.correcttail = 'prob';
cfg.numrandomization = 10000;
cfg.design(1,1:2*Nsub) = [ones(1,Nsub) 2*ones(1,Nsub)];
cfg.design(2,1:2*Nsub) = [1:Nsub 1:Nsub];
cfg.ivar = 1; % the 1st row in cfg.design contains the independent variable
cfg.uvar = 2; % the 2nd row in cfg.design contains the subject number
stat = ft_freqstatistics(cfg, betas_GA, betas_bl_GA);
% save
filename = sprintf('/project/3011085.02/analysis/stat_glm_tf_%s_%s_erf_%s.mat', freqRange, zeropoint, erfoi);
save(filename, 'stat', 'betas_GA', 'betas_bl_GA');
ft_diary('off')