forked from trentool/TRENTOOL3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_script_ensemblemethod.m
121 lines (78 loc) · 3.18 KB
/
example_script_ensemblemethod.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
%% set paths
addpath('TRENTOOL3.3.1') % note: this script assumes, you have already compiled the GPU mex-files using 'install.m'
addpath('fieldtrip-20120703');
ft_defaults;
%% define data paths
OutputDataPath = '/results/';
InputDataPath = 'TRENTOOL3_exampledata/Lorenz_2_systems/lorenz_1-2_45ms.mat';
load(InputDataPath);
%% define cfg for TEprepare.m
cfgTEP = [];
% data
cfgTEP.toi = [min(data.time{1,1}),max(data.time{1,1})]; % time of interest
cfgTEP.sgncmb = {'A1' 'A2'}; % channels to be analyzed
% scanning of interaction delays u
cfgTEP.predicttimemin_u = 40; % minimum u to be scanned
cfgTEP.predicttimemax_u = 50; % maximum u to be scanned
cfgTEP.predicttimestepsize = 1; % time steps between u's to be scanned
% estimator
cfgTEP.TEcalctype = 'VW_ds'; % use the new TE estimator (Wibral, 2013)
% use ensemble method
cfgTEP.ensemblemethod = 'yes';
% ACT estimation and constraints on allowed ACT(autocorelation time)
cfgTEP.actthrvalue = 40; % threshold for ACT
cfgTEP.maxlag = 100;
cfgTEP.minnrtrials = 15; % minimum acceptable number of trials
% optimizing embedding
cfgTEP.optimizemethod ='ragwitz'; % criterion used
cfgTEP.ragdim = 2:8; % criterion dimension
cfgTEP.ragtaurange = [0.2 0.4]; % range for tau
cfgTEP.ragtausteps = 15; % steps for ragwitz tau steps
cfgTEP.repPred = 100; % size(data.trial{1,1},2)*(3/4);
% kernel-based TE estimation
cfgTEP.flagNei = 'Mass' ; % neigbour analyse type
cfgTEP.sizeNei = 4; % neigbours to analyse
%% define cfg for TEsurrogatestats_ensemble.m
cfgTESS = [];
% use individual dimensions for embedding
cfgTESS.optdimusage = 'indivdim';
% surrogate testing
cfgTESS.tail = 1;
cfgTESS.surrogatetype = 'trialperm';
cfgTESS.numpermutation = 100;
% GPU specifications
cfgTESS.GPUmemsize = 4200;
cfgTESS.numthreads = 512;
cfgTESS.maxgriddim = 65535;
% volume conduction
cfgTESS.extracond = 'Faes_Method';
cfgTESS.shifttest = 'no';
% don't calculate MI additionally to TE
cfgTESS.MIcalc = 0;
% results file name
cfgTESS.fileidout = strcat(OutputDataPath,'Lorenzdata_1->2_ensemble_');
%% calculation - scan over specified values for u
TGA_results = InteractionDelayReconstruction_calculate(cfgTEP,cfgTESS,data);
save([OutputDataPath 'TGA_results.mat'],'TGA_results');
%% optional: perform a post hoc correction for cascade effects and simple common drive effects
cfgGA = [];
cfgGA.threshold = 3;
cfgGA.cmc = 1;
TGA_results_GA = TEgraphanalysis(cfgGA,TGA_results);
save([OutputDataPath 'Lorenz_1->2_TGA_results_analyzed_GA.mat'],'TGA_results_GA');
%% plotting
load('exampledata/lorenz_layout.mat');
cfgPLOT = [];
cfgPLOT.layout = lay_Lorenz; % see fieldtrip's ft_prepare_layout.m
cfgPLOT.electrodes = 'highlights';
cfgPLOT.statstype = 1; % 1: corrected; 2:uncorrected; 3: 1-pval; 4:rawdistance
cfgPLOT.alpha = 0.05;
cfgPLOT.arrowpos = 1;
cfgPLOT.showlabels = 'yes';
cfgPLOT.electrodes = 'on';
cfgPLOT.hlmarker = 'o';
cfgPLOT.hlcolor = [0 0 0];
cfgPLOT.hlmarkersize = 4;
cfgPLOT.arrowcolorpos = [1 0 0];
figure;
TEplot2D(cfgPLOT,TGA_results_GA)