-
Notifications
You must be signed in to change notification settings - Fork 0
/
conn_cal.m
75 lines (71 loc) · 4.95 KB
/
conn_cal.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
close all; clc; clear all;
addpath('D:\software\fieldtrip-20190325');
addpath('D:\software\eeglab14_1_2b');
%% calculating powe-based and phase-based NS over time and/or frequency
trialNameSet ={'compet1_1','compet1_2','compet2_1','compet2_2','compet3_1','compet3_2',...
'compet4_1','compet4_2','compet5_1','compet5_2','compet6_1','compet6_2',...
'compet7_1','compet7_2','compet8_1','compet8_2','compet9_1','compet9_2',...
'compet10_1','compet10_2','compet11_1','compet11_2','compet12_1','compet12_2','compet13_1','compet13_2',...
'compet14_1','compet14_2','compet15_1','compet15_2','compet16_1','compet16_2',...
'compet17_1','compet17_2','compet18_1','compet18_2','compet19_1','compet19_2',...
'compet20_1','compet20_2','compet21_1','compet21_2','compet22_1','compet22_2',...
'cooperation1_1','cooperation1_2','cooperation2_1','cooperation2_2','cooperation3_1','cooperation3_2',...
'cooperation4_1', 'cooperation4_2','cooperation5_1', 'cooperation5_2',...
'cooperation6_1', 'cooperation6_2','cooperation7_1', 'cooperation7_2',...
'cooperation8_1', 'cooperation8_2','cooperation9_1', 'cooperation9_2',...
'cooperation10_1', 'cooperation10_2','cooperation11_1', 'cooperation11_2',...
'cooperation12_1', 'cooperation12_2','cooperation13_1', 'cooperation13_2',...
'cooperation14_1', 'cooperation14_2','cooperation15_1', 'cooperation15_2',...
'cooperation16_1', 'cooperation16_2','cooperation17_1', 'cooperation17_2',...
'cooperation18_1', 'cooperation18_2','cooperation19_1', 'cooperation19_2'...
'cooperation20_1', 'cooperation20_2','cooperation21_1', 'cooperation21_2',...
'cooperation22_1', 'cooperation22_2','cooperation23_1', 'cooperation23_2',...
'cooperation24_1', 'cooperation24_2','cooperation25_1', 'cooperation25_2'};
saveSetName= {'compet1','compet2','compet3','compet4','compet5','compet6'...
'compet7','compet8','compet9','compet10','compet11','compet12','compet13',...
'compet14','compet15','compet16','compet17','compet18','compet19',...
'compet20','compet21','compet22',...
'cooperation1','cooperation2','cooperation3','cooperation4','cooperation5',...
'cooperation6','cooperation7','cooperation8','cooperation9',...
'cooperation10','cooperation11','cooperation12','cooperation13', 'cooperation14','cooperation15',...
'cooperation16','cooperation17','cooperation18','cooperation19','cooperation20','cooperation21',...
'cooperation22','cooperation23','cooperation24','cooperation25'};
for trialNameII = 1:2:length(trialNameSet) %calculate inter-brain FC
if trialNameII > 7
[~] = conn_powerBased(strcat('data/useful/',trialNameSet{trialNameII},'_allersp.mat'),...
strcat('data/useful/',trialNameSet{trialNameII+1},'_allersp.mat'),...
strcat('data/useful/conn/conn_power_',saveSetName{(trialNameII+1)/2},'_overTime.mat'),trialNameII,0); % over frequeny and time
[~] = conn_powerBased(strcat('data/useful/',trialNameSet{trialNameII},'_allersp.mat'),...
strcat('data/useful/',trialNameSet{trialNameII+1},'_allersp.mat'),...
strcat('data/useful/conn/conn_power_',saveSetName{(trialNameII+1)/2},'_overTime.mat'),trialNameII,1); % over time
[~] = conn_powerBased(strcat('data/useful/',trialNameSet{trialNameII},'_allersp.mat'),...
strcat('data/useful/',trialNameSet{trialNameII+1},'_allersp.mat'),...
strcat('data/useful/conn/conn_power_',saveSetName{(trialNameII+1)/2},'_overFreq.mat'),trialNameII,2); % over frequency
end
end
%%
for trialNameII = 1:2:length(trialNameSet) % calculate inter-brain FC
% [~] = conn_phaseBased(strcat('data/useful/',trialNameSet{trialNameII},'_allitc.mat'),...
% strcat('data/useful/',trialNameSet{trialNameII+1},'_allitc.mat'),...
% strcat('data/useful/conn/conn_phase_',saveSetName{(trialNameII+1)/2},'_overTime.mat'),trialNameII,0); % over frequency and time
conn_phaseBased(strcat('data/useful/',trialNameSet{trialNameII},'_allitc.mat'),...
strcat('data/useful/',trialNameSet{trialNameII+1},'_allitc.mat'),...
strcat('data/useful/conn/conn_phase_',saveSetName{(trialNameII+1)/2},'_overTime.mat'),trialNameII,1); % over time
conn_phaseBased(strcat('data/useful/',trialNameSet{trialNameII},'_allitc.mat'),...
strcat('data/useful/',trialNameSet{trialNameII+1},'_allitc.mat'),...
strcat('data/useful/conn/conn_phase_',saveSetName{(trialNameII+1)/2},'_overFreq.mat'),trialNameII,2); % over frequency
end
%% calculate MI over frequency and time
for trialI = 1:2:size(trialNameSet,2)
dicI = (trialI+1)/2;
MI = MI_cal(trialNameSet{trialI}, trialNameSet{trialI+1}, 'data/useful/',trialI);
save(strcat('data/useful/conn/conn_MI_',saveSetName{dicI},'.mat'),'MI'); % save mutual information for each trial
MI(:,9) = []; MI(9,:) = []; MI(:,14)=[]; MI(14,:)=[];
MI(:,9+21) = []; MI(9+21,:) = []; MI(:,14+20)=[]; MI(14+20,:)=[];
if (dicI < 23)
MI_all.compet(:,dicI) = MI(:);
else % cooperation set
MI_all.cop(:,dicI-22) = MI(:);
end
end
save('data/useful/conn/MI_all','MI_all');