Skip to content

Commit 3e3b347

Browse files
Merge pull request #1495 from softmatterlab/develop
Braph 2.0.0.a2
2 parents 3546c2d + fd12dd0 commit 3e3b347

File tree

636 files changed

+10001
-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

+10001
-189
lines changed

braph2genesis/measures/_Distance.gen.m

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@
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+
Aii_tmp = {};
44+
for li = 1:g.layernumber()
45+
Aii_tmp{li} = A{li, li}; %#ok<AGROW>
46+
end
47+
parfor li = 1:g.layernumber()
48+
Aii = Aii_tmp{li};
49+
connectivity_layer = connectivity_type(li);
4650

4751
if connectivity_layer == Graph.WEIGHTED % weighted graphs
48-
distance(li) = {m.getWeightedCalculation(Aii)};
52+
distance(li) = {m.getWeightedCalculation(Aii)}; %#ok<PFBNS>
4953
else % binary graphs
5054
distance(li) = {m.getBinaryCalculation(Aii)};
5155
end
@@ -54,7 +58,7 @@
5458
value = distance;
5559

5660
%% ¡methods!
57-
function weighted_distance = getWeightedCalculation(m, A)
61+
function weighted_distance = getWeightedCalculation(~, A)
5862
%GETWEIGHTEDCALCULATION calculates the distance value of a weighted adjacency matrix.
5963
%
6064
% WEIGHTED_DISTANCE = GETWEIGHTEDCALCULATION(M, A) returns the value of the
@@ -77,9 +81,9 @@
7781

7882
for v = V
7983
T = find(L1(v, :)); % neighbours of shortest nodes
80-
[d, wi] = min([D(u, T);D(u, v)+L1(v, T)]);
84+
[d, ~] = min([D(u, T);D(u, v)+L1(v, T)]);
8185
D(u, T) = d; % smallest of old/new path lengths
82-
ind = T(wi==2); % indices of lengthened paths
86+
% ind = T(wi==2); % indices of lengthened paths
8387
end
8488

8589
minD = min(D(u, S));
@@ -92,7 +96,7 @@
9296
end
9397
weighted_distance = D;
9498
end
95-
function binary_distance = getBinaryCalculation(m, A)
99+
function binary_distance = getBinaryCalculation(~, A)
96100
%GETBINARYCALCULATION calculates the distance value of a binary adjacency matrix.
97101
%
98102
% 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 = {harmmean([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+
harmmean([18/11 18/15 18/15 18/11])
92+
harmmean([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: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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+
[1:1:10]
46+
%%%% ¡gui!
47+
pr = PanelPropRVectorSmart('EL', a, 'PROP', AnalyzeGroup_CON_FUN_MP_GA_BUD.DENSITIES, ...
48+
'MIN', 0, 'MAX', 100, ...
49+
'DEFAULT', AnalyzeGroup_CON_FUN_MP_GA_BUD.getPropDefault('DENSITIES'), ...
50+
varargin{:});
51+
52+
%% ¡props_update!
53+
54+
%%% ¡prop!
55+
TEMPLATE (parameter, item) is the analysis template to set the parameters.
56+
%%%% ¡settings!
57+
'AnalyzeGroup_CON_FUN_MP_GA_BUD'
58+
59+
%%% ¡prop!
60+
GR (data, item) is the subject group, which also defines the subject class SubjectCON_FUN_MP.
61+
%%%% ¡default!
62+
Group('SUB_CLASS', 'SubjectCON_FUN_MP')
63+
64+
%%% ¡prop!
65+
G (result, item) is the average multiplex graph obtained from this analysis.
66+
%%%% ¡settings!
67+
'MultiplexBUD'
68+
%%%% ¡default!
69+
MultiplexBUD()
70+
%%%% ¡calculate!
71+
gr = a.get('GR');
72+
T = a.get('REPETITION');
73+
fmin = a.get('FREQUENCYRULEMIN');
74+
fmax = a.get('FREQUENCYRULEMAX');
75+
densities = a.get('DENSITIES'); % this is a vector
76+
A = cell(1, 2);
77+
data = cell(1, 2);
78+
layerlabels = {};
79+
80+
for i = 1:1:gr.get('SUB_DICT').length()
81+
sub = gr.get('SUB_DICT').getItem(i);
82+
CON_FUN_MP = sub.getr('CON_FUN_MP');
83+
84+
% FUN data
85+
data_fun = CON_FUN_MP{2};
86+
fs = 1 / T;
87+
88+
if fmax > fmin && T > 0
89+
NFFT = 2 * ceil(size(data_fun, 1) / 2);
90+
ft = fft(data_fun, NFFT); % Fourier transform
91+
f = fftshift(fs * abs(-NFFT / 2:NFFT / 2 - 1) / NFFT); % absolute frequency
92+
ft(f < fmin | f > fmax, :) = 0;
93+
data_fun = ifft(ft, NFFT);
94+
end
95+
96+
A_fun = Correlation.getAdjacencyMatrix(data_fun, a.get('CORRELATION_RULE'), a.get('NEGATIVE_WEIGHT_RULE'));
97+
98+
% CON data
99+
if i == 1
100+
data(1) = CON_FUN_MP(1);
101+
data(2) = {A_fun};
102+
else
103+
data(1) = {data{1} + CON_FUN_MP{1}};
104+
data(2) = {data{2} + A_fun};
105+
end
106+
107+
for i = 1:length(densities)
108+
layerlabels = [...
109+
layerlabels, ['C ' num2str(densities(i)) '%'], ...
110+
['F ' num2str(densities(i)) '%']];
111+
end
112+
end
113+
114+
A(1) = {data{1}/gr.get('SUB_DICT').length()};
115+
A(2) = {data{2}/gr.get('SUB_DICT').length()};
116+
117+
ba = BrainAtlas();
118+
if ~isempty(gr) && ~isa(gr, 'NoValue') && gr.get('SUB_DICT').length > 0
119+
ba = gr.get('SUB_DICT').getItem(1).get('BA');
120+
end
121+
122+
g = MultiplexBUD( ...
123+
'ID', ['g ' gr.get('ID')], ...
124+
'B', A, ...
125+
'DENSITIES', densities, ...
126+
'LAYERTICKS', densities, ...
127+
'LAYERLABELS', cell2str(layerlabels), ...
128+
'BAS', ba ...
129+
);
130+
131+
value = g;
132+
133+
%% ¡methods!
134+
function pr = getPPCompareGroup_CPDict(a, varargin)
135+
%GEPPPCOMPAREGROUP_CPDICT returns the comparison plot panel compatible with the analysis.
136+
%
137+
% PR = GEPPPCOMPAREGROUP_CPDICT(A) returns the comparison plot panel
138+
% that is compatible with the analyze group.
139+
%
140+
% See also CompareGroup.
141+
142+
pr = PPCompareGroup_CPDict_CON_FUN_MP_GA_BUD(varargin{:});
143+
end
144+
145+
%% ¡tests!
146+
147+
%%% ¡test!
148+
%%%% ¡name!
149+
Example
150+
%%%% ¡code!
151+
example_CON_FUN_MP_GA_BUD

0 commit comments

Comments
 (0)