Skip to content

Commit f3012b4

Browse files
Merge pull request #1493 from softmatterlab/alpha2_MultiplexPipelines
Alpha2 - multiplex pipelines
2 parents 321a1eb + 72096f3 commit f3012b4

File tree

636 files changed

+9995
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

636 files changed

+9995
-189
lines changed

braph2genesis/measures/_Distance.gen.m

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@
3939

4040
distance = cell(g.layernumber(), 1);
4141
connectivity_type = g.getConnectivityType(g.layernumber());
42-
parfor li = 1:1:g.layernumber()
43-
44-
Aii = A{li, li};
45-
connectivity_layer = connectivity_type(li, li);
42+
connectivity_type = diag(connectivity_type);
43+
for li = 1:g.layernumber()
44+
Aii_tmp{li} = A{li, li}; %#ok<AGROW>
45+
end
46+
parfor li = 1:g.layernumber()
47+
Aii = Aii_tmp{li};
48+
connectivity_layer = connectivity_type(li);
4649

4750
if connectivity_layer == Graph.WEIGHTED % weighted graphs
48-
distance(li) = {m.getWeightedCalculation(Aii)};
51+
distance(li) = {m.getWeightedCalculation(Aii)}; %#ok<PFBNS>
4952
else % binary graphs
5053
distance(li) = {m.getBinaryCalculation(Aii)};
5154
end
@@ -54,7 +57,7 @@
5457
value = distance;
5558

5659
%% ¡methods!
57-
function weighted_distance = getWeightedCalculation(m, A)
60+
function weighted_distance = getWeightedCalculation(~, A)
5861
%GETWEIGHTEDCALCULATION calculates the distance value of a weighted adjacency matrix.
5962
%
6063
% WEIGHTED_DISTANCE = GETWEIGHTEDCALCULATION(M, A) returns the value of the
@@ -77,9 +80,9 @@
7780

7881
for v = V
7982
T = find(L1(v, :)); % neighbours of shortest nodes
80-
[d, wi] = min([D(u, T);D(u, v)+L1(v, T)]);
83+
[d, ~] = min([D(u, T);D(u, v)+L1(v, T)]);
8184
D(u, T) = d; % smallest of old/new path lengths
82-
ind = T(wi==2); % indices of lengthened paths
85+
% ind = T(wi==2); % indices of lengthened paths
8386
end
8487

8588
minD = min(D(u, S));
@@ -92,7 +95,7 @@
9295
end
9396
weighted_distance = D;
9497
end
95-
function binary_distance = getBinaryCalculation(m, A)
98+
function binary_distance = getBinaryCalculation(~, A)
9699
%GETBINARYCALCULATION calculates the distance value of a binary adjacency matrix.
97100
%
98101
% BINARY_DISTANCE = GETBINARYCALCULATION(A) returns the value of the

braph2genesis/measures/_PathLength.gen.m

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
%%% ¡prop!
2929
rule (parameter, OPTION) is the path length algorithm
3030
%%%% ¡settings!
31-
{'subgraphs' 'harmonic' 'pl_default'}
31+
{'subgraphs' 'harmonic' 'mean'}
3232
%%%% ¡default!
33-
'pl_default'
33+
'harmonic'
3434

3535
%% ¡props_update!
3636

@@ -56,23 +56,22 @@
5656
for u = 1:1:N
5757
Du = distance_layer(:, u);
5858
path_length_layer(u) = mean(Du(Du~=Inf & Du~=0));
59-
end
60-
case {'harmonic'}
59+
end
60+
case {'mean'}
6161
for u = 1:1:N
6262
Du = distance_layer(:, u);
63-
path_length_layer(u) = harmmean(Du(Du~=0));
63+
path_length_layer(u) = mean(Du(Du~=0));
6464
end
65-
otherwise % 'default'
65+
otherwise % 'harmonic' 'default'
6666
for u = 1:1:N
6767
Du = distance_layer(:, u);
68-
path_length_layer(u) = mean(Du(Du~=0));
68+
path_length_layer(u) = harmmean(Du(Du~=0));
6969
end
7070
end
7171
path_length(li) = {path_length_layer}; % node Inf corresponds to isolated nodes
7272
end
7373
value = path_length;
7474

75-
7675
%% ¡tests!
7776

7877
%%% ¡test!
@@ -86,7 +85,7 @@
8685
0 0 .1 0
8786
];
8887

89-
known_path_length = {[2 4/3 4/3 2]'};
88+
known_path_length = {[18/11 18/15 18/15 18/11]'};
9089

9190
g = GraphBU('B', B);
9291
path_length = PathLength('G', g).get('M');
@@ -109,8 +108,8 @@
109108
thresholds = [0 1];
110109

111110
known_path_length = { ...
112-
[2 4/3 4/3 2]'
113-
[Inf Inf Inf Inf]'
111+
[18/11 18/15 18/15 18/11]'
112+
[Inf Inf Inf Inf]'
114113
};
115114

116115
g = MultigraphBUT('B', B, 'THRESHOLDS', thresholds);
@@ -141,8 +140,8 @@
141140
B = { A11 A22};
142141

143142
known_path_length = {
144-
[2 4/3 4/3 2]'
145-
[2 4/3 4/3 2]'
143+
[18/11 18/15 18/15 18/11]'
144+
[18/11 18/15 18/15 18/11]'
146145
};
147146

148147
g = MultiplexBU('B', B);

braph2genesis/measures/_PathLengthAv.gen.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@
2727
%% ¡props_update!
2828

2929
%%% ¡prop!
30-
M (result, cell) is the path length.
30+
M (result, cell) is the average path length.
3131
%%%% ¡calculate!
3232
g = m.get('G'); % graph from measure class
3333

34-
path_length = calculateValue@PathLength(m, prop);
34+
path_length = calculateValue@PathLength(m, prop);
3535
path_length_av = cell(g.layernumber(), 1);
36+
path_length_rule = m.get('rule');
3637
parfor li = 1:1:length(path_length_av)
37-
path_length_av(li) = {mean(path_length{li})};
38+
switch lower(path_length_rule)
39+
case {'subgraphs'}
40+
player = path_length{li};
41+
path_length_av(li) = {mean(player(player~=Inf))};
42+
case {'mean'}
43+
path_length_av(li) = {mean(path_length{li})};
44+
otherwise % 'harmonic' 'default'
45+
path_length_av(li) = {harmmean(path_length{li})};
46+
end
3847
end
3948
value = path_length_av;
4049

@@ -51,7 +60,7 @@
5160
0 0 .1 0
5261
];
5362

54-
known_path_length_av = {mean([2 4/3 4/3 2])};
63+
known_path_length_av = {mean([18/11 18/15 18/15 18/11])};
5564

5665
g = GraphBU('B', A);
5766
path_length_av = PathLengthAv('G', g).get('M');
@@ -79,8 +88,8 @@
7988
A = {A11 A22};
8089

8190
known_path_length_av = {
82-
mean([2 4/3 4/3 2])
83-
mean([2 4/3 4/3 2])
91+
mean([18/11 18/15 18/15 18/11])
92+
mean([18/11 18/15 18/15 18/11])
8493
};
8594

8695
g = MultiplexBU('B', A);

braph2genesis/measures/_SmallWorldness.gen.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
end
3838
L = g.layernumber();
3939

40+
path_length_rule = m.get('rule');
4041
clustering_av = ClusteringAv('G', g).get('M');
4142
path_length_av = calculateValue@PathLengthAv(m, prop);
42-
path_length_rule = m.get('rule');
4343

4444
M = 100; % number of random graphs
4545
clustering_av_random = cell(1, M);
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
%% ¡header!
2+
AnalyzeGroup_CON_FUN_MP_GA_BUD < AnalyzeGroup (a, graph analysis with connectivity and functional multiplex data of fixed density) is a graph analysis using connectivity and functional multiplex data of fixed density.
3+
4+
%% ¡description!
5+
This graph analysis uses connectivity and functional multiplex data of
6+
fixed density and analyzes them using binary undirected graphs.
7+
8+
%%% ¡seealso!
9+
AnalyzeGroup_CON_FUN_MP_WU, SubjectCON_FUN_MP, MultiplexBUD.
10+
11+
%% ¡props!
12+
13+
%%% ¡prop!
14+
REPETITION(parameter, scalar) is the number of repetitions for functional data
15+
%%%% ¡default!
16+
1
17+
18+
%%% ¡prop!
19+
FREQUENCYRULEMIN(parameter, scalar)is the minimum frequency value for functional data
20+
%%%% ¡default!
21+
0
22+
23+
%%% ¡prop!
24+
FREQUENCYRULEMAX(parameter, scalar)is the maximum frequency value for functional data
25+
%%%% ¡default!
26+
Inf
27+
28+
%%% ¡prop!
29+
CORRELATION_RULE (parameter, option) is the correlation type for functional data.
30+
%%%% ¡settings!
31+
Correlation.CORRELATION_RULE_LIST(1:3)
32+
%%%% ¡default!
33+
Correlation.CORRELATION_RULE_LIST{1}
34+
35+
%%% ¡prop!
36+
NEGATIVE_WEIGHT_RULE (parameter, option) determines how to deal with negative weights of functional data.
37+
%%%% ¡settings!
38+
Correlation.NEGATIVE_WEIGHT_RULE_LIST
39+
%%%% ¡default!
40+
Correlation.NEGATIVE_WEIGHT_RULE_LIST{1}
41+
42+
%%% ¡prop!
43+
DENSITIES (parameter, rvector) is the vector of densities.
44+
%%%% ¡default!
45+
0
46+
47+
%% ¡props_update!
48+
49+
%%% ¡prop!
50+
TEMPLATE (parameter, item) is the analysis template to set the parameters.
51+
%%%% ¡settings!
52+
'AnalyzeGroup_CON_FUN_MP_GA_BUD'
53+
54+
%%% ¡prop!
55+
GR (data, item) is the subject group, which also defines the subject class SubjectCON_FUN_MP.
56+
%%%% ¡default!
57+
Group('SUB_CLASS', 'SubjectCON_FUN_MP')
58+
59+
%%% ¡prop!
60+
G (result, item) is the average multiplex graph obtained from this analysis.
61+
%%%% ¡settings!
62+
'MultiplexBUD'
63+
%%%% ¡default!
64+
MultiplexBUD()
65+
%%%% ¡calculate!
66+
gr = a.get('GR');
67+
T = a.get('REPETITION');
68+
fmin = a.get('FREQUENCYRULEMIN');
69+
fmax = a.get('FREQUENCYRULEMAX');
70+
densities = a.get('DENSITIES'); % this is a vector
71+
A = cell(1, 2);
72+
data = cell(1, 2);
73+
74+
for i = 1:1:gr.get('SUB_DICT').length()
75+
sub = gr.get('SUB_DICT').getItem(i);
76+
CON_FUN_MP = sub.getr('CON_FUN_MP');
77+
78+
% FUN data
79+
data_fun = CON_FUN_MP{2};
80+
fs = 1 / T;
81+
82+
if fmax > fmin && T > 0
83+
NFFT = 2 * ceil(size(data_fun, 1) / 2);
84+
ft = fft(data_fun, NFFT); % Fourier transform
85+
f = fftshift(fs * abs(-NFFT / 2:NFFT / 2 - 1) / NFFT); % absolute frequency
86+
ft(f < fmin | f > fmax, :) = 0;
87+
data_fun = ifft(ft, NFFT);
88+
end
89+
90+
A_fun = Correlation.getAdjacencyMatrix(data_fun, a.get('CORRELATION_RULE'), a.get('NEGATIVE_WEIGHT_RULE'));
91+
92+
% CON data
93+
if i == 1
94+
data(1) = CON_FUN_MP(1);
95+
data(2) = {A_fun};
96+
else
97+
data(1) = {data{1} + CON_FUN_MP{1}};
98+
data(2) = {data{2} + A_fun};
99+
end
100+
101+
layerlabels = {};
102+
for i = 1:length(densities)
103+
layerlabels = [...
104+
layerlabels, ['C ' num2str(densities(i)) '%'], ...
105+
['F ' num2str(densities(i)) '%']];
106+
end
107+
end
108+
109+
A(1) = {data{1}/gr.get('SUB_DICT').length()};
110+
A(2) = {data{2}/gr.get('SUB_DICT').length()};
111+
112+
ba = BrainAtlas();
113+
if ~isempty(gr) && ~isa(gr, 'NoValue') && gr.get('SUB_DICT').length > 0
114+
ba = gr.get('SUB_DICT').getItem(1).get('BA');
115+
end
116+
117+
g = MultiplexBUD( ...
118+
'ID', ['g ' gr.get('ID')], ...
119+
'B', A, ...
120+
'DENSITIES', densities, ...
121+
'LAYERTICKS', densities, ...
122+
'LAYERLABELS', cell2str(layerlabels), ...
123+
'BAS', ba ...
124+
);
125+
126+
value = g;
127+
128+
%% ¡methods!
129+
function pr = getPPCompareGroup_CPDict(a, varargin)
130+
%GEPPPCOMPAREGROUP_CPDICT returns the comparison plot panel compatible with the analysis.
131+
%
132+
% PR = GEPPPCOMPAREGROUP_CPDICT(A) returns the comparison plot panel
133+
% that is compatible with the analyze group.
134+
%
135+
% See also CompareGroup.
136+
137+
pr = PPCompareGroup_CPDict_CON_FUN_MP_GA_BUD(varargin{:});
138+
end
139+
140+
%% ¡tests!
141+
142+
%%% ¡test!
143+
%%%% ¡name!
144+
Example
145+
%%%% ¡code!
146+
example_CON_FUN_MP_GA_BUD

0 commit comments

Comments
 (0)