-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcalcmi.m
52 lines (41 loc) · 1.75 KB
/
calcmi.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
function calcmi(listname,varargin)
loadpaths
measure = 'modules';
param = finputcheck(varargin, {
'randratio', 'string', {'on','off'}, 'off'; ...
});
load(sprintf('%s/groupdata_%s.mat',filepath,listname),'graph','tvals','subjlist');
% ctrlgraph = load(sprintf('%s/groupdata_ctrllist.mat',filepath),'graph','tvals');
weiorbin = 2;
if any(strcmp('mutual information',graph(:,1)))
midx = find(strcmp('mutual information',graph(:,1)));
else
graph{end+1,1} = 'mutual information';
midx = size(graph,1);
end
modinfo = graph{strcmp(measure,graph(:,1)),weiorbin};
% allctrl = ctrlgraph.graph{strcmp(measure,graph(:,1)),weiorbin};
% meanctrl = squeeze(mean(ctrlgraph.graph{strcmp(measure,graph(:,1)),weiorbin}(crsdiag == 5,:,:,:),1));
mutinfo = nan(size(modinfo,1),size(modinfo,1),size(modinfo,2),size(modinfo,3));
for bandidx = 1:size(modinfo,2)
fprintf('band %d, threshold', bandidx);
for t = 1:size(modinfo,3)
fprintf(' %d',t);
for s1 = 1:size(modinfo,1)
for s2 = 1:size(modinfo,1)
if s1 < s2
% mutinfo(s1,s2,bandidx,t) = ...
% corr(squeeze(modinfo(s1,bandidx,t,:)),squeeze(allctrl(s2,bandidx,t,:)));
[~, mutinfo(s1,s2,bandidx,t)] = ...
partition_distance(squeeze(modinfo(s1,bandidx,t,:)),squeeze(modinfo(s2,bandidx,t,:)));
elseif s1 > s2
mutinfo(s1,s2,bandidx,t) = mutinfo(s2,s1,bandidx,t);
end
end
end
end
fprintf('\n');
end
graph{midx,weiorbin} = mutinfo;
fprintf('Appending mutual information to %s/groupdata_%s.mat.\n',filepath,listname);
save(sprintf('%s/groupdata_%s.mat',filepath,listname), 'graph','-append');