function b = generative_model(A,D,m,modeltype,modelvar,params,epsilon)
% GENERATIVE_MODEL Run generative model code
%
% B = GENERATIVE_MODEL(A,D,m,modeltype,modelvar,params)
%
% Generates synthetic networks using the models described in the study by
% Betzel et al (2016) in Neuroimage.
%
% Inputs:
% A, binary network of seed connections
% D, Euclidean distance/fiber length matrix
% m, number of connections that should be present in
% final synthetic network
% modeltype, specifies the generative rule (see below)
% modelvar, specifies whether the generative rules are based on
% power-law or exponential relationship
% ({'powerlaw'}|{'exponential})
% params, either a vector (in the case of the geometric
% model) or a matrix (for all other models) of
% parameters at which the model should be evaluated.
% epsilon, the baseline probability of forming a particular
% connection (should be a very small number
% {default = 1e-5}).
%
% Output:
% B, m x number of networks matrix of connections
%
%
% Full list of model types:
% (each model type realizes a different generative rule)
%
% 1. 'sptl' spatial model
% 2. 'neighbors' number of common neighbors
% 3. 'matching' matching index
% 4. 'clu-avg' average clustering coeff.
% 5. 'clu-min' minimum clustering coeff.
% 6. 'clu-max' maximum clustering coeff.
% 7. 'clu-diff' difference in clustering coeff.
% 8. 'clu-prod' product of clustering coeff.
% 9. 'deg-avg' average degree
% 10. 'deg-min' minimum degree
% 11. 'deg-max' maximum degree
% 12. 'deg-diff' difference in degree
% 13. 'deg-prod' product of degree
%
%
% Example usage:
%
% load demo_generative_models_data
%
% % get number of bi-directional connections
% m = nnz(A)/2;
%
% % get cardinality of network
% n = length(A);
%
% % set model type
% modeltype = 'neighbors';
%
% % set whether the model is based on powerlaw or exponentials
% modelvar = [{'powerlaw'},{'powerlaw'}];
%
% % choose some model parameters
% params = [-2,0.2; -5,1.2; -1,1.5];
% nparams = size(params,1);
%
% % generate synthetic networks
% B = generative_model(Aseed,D,m,modeltype,modelvar,params);
%
% % store them in adjacency matrix format
% Asynth = zeros(n,n,nparams);
% for i = 1:nparams;
% a = zeros(n); a(B(:,i)) = 1; a = a + a';
% Asynth(:,:,i) = a;
% end
%
% Reference: Betzel et al (2016) Neuroimage 124:1054-64.
%
% Richard Betzel, Indiana University/University of Pennsylvania, 2015
if ~exist('epsilon','var')
epsilon = 1e-5;
end
n = length(D);
nparams = size(params,1);
b = zeros(m,nparams);
switch modeltype
case 'clu-avg'
clu = clustering_coef_bu(A);
Kseed = bsxfun(@plus,clu(:,ones(1,n)),clu')/2;
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_clu_avg(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'clu-diff'
clu = clustering_coef_bu(A);
Kseed = abs(bsxfun(@minus,clu(:,ones(1,n)),clu'));
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_clu_diff(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'clu-max'
clu = clustering_coef_bu(A);
Kseed = bsxfun(@max,clu(:,ones(1,n)),clu');
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_clu_max(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'clu-min'
clu = clustering_coef_bu(A);
Kseed = bsxfun(@min,clu(:,ones(1,n)),clu');
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_clu_min(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'clu-prod'
clu = clustering_coef_bu(A);
Kseed = clu*clu';
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_clu_prod(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'deg-avg'
kseed = sum(A,2);
Kseed = bsxfun(@plus,kseed(:,ones(1,n)),kseed')/2;
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_deg_avg(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'deg-diff'
kseed = sum(A,2);
Kseed = abs(bsxfun(@minus,kseed(:,ones(1,n)),kseed'));
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_deg_diff(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'deg-max'
kseed = sum(A,2);
Kseed = bsxfun(@max,kseed(:,ones(1,n)),kseed');
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_deg_max(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'deg-min'
kseed = sum(A,2);
Kseed = bsxfun(@min,kseed(:,ones(1,n)),kseed');
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_deg_min(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'deg-prod'
kseed = sum(A,2);
Kseed = (kseed*kseed').*~eye(n);
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_deg_prod(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'neighbors'
Kseed = (A*A).*~eye(n);
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_nghbrs(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'matching'
Kseed = matching_ind(A);
Kseed = Kseed + Kseed';
for iparam = 1:nparams
eta = params(iparam,1);
gam = params(iparam,2);
b(:,iparam) = fcn_matching(A,Kseed,D,m,eta,gam,modelvar,epsilon);
end
case 'sptl'
for iparam = 1:nparams
eta = params(iparam,1);
b(:,iparam) = fcn_sptl(A,D,m,eta,modelvar{1});
end
end
function b = fcn_clu_avg(A,K,D,m,eta,gam,modelvar,epsilon)
K = K + epsilon;
n = length(D);
mseed = nnz(A)/2;
A = A > 0;
mv1 = modelvar{1};
mv2 = modelvar{2};
switch mv1
case 'powerlaw'
Fd = D.^eta;
case 'exponential'
Fd = exp(eta*D);
end
switch mv2
case 'powerlaw'
Fk = K.^gam;
case 'exponential'
Fk = exp(gam*K);
end
c = clustering_coef_bu(A);
k = sum(A,2);
Ff = Fd.*Fk.*~A;
[u,v] = find(triu(ones(n),1));
indx = (v - 1)*n + u;
P = Ff(indx);
for i = (mseed + 1):m
C = [0; cumsum(P)];
r = sum(rand*C(end) >= C);
uu = u(r);
vv = v(r);
A(uu,vv) = 1;
A(vv,uu) = 1;
k([uu,vv]) = k([uu,vv]) + 1;
bu = A(uu,:);
su = A(bu,bu);
bv = A(vv,:);
sv = A(bv,bv);
bth = bu & bv;
c(bth) = c(bth) + 2./(k(bth).^2 - k(bth));
c(uu) = nnz(su)/(k(uu)*(k(uu) - 1));
c(vv) = nnz(sv)/(k(vv)*(k(vv) - 1));
c(k <= 1) = 0;
bth([uu,vv]) = true;
K(:,bth) = bsxfun(@plus,c(:,ones(1,sum(bth))),c(bth,:)')/2 + epsilon;
K(bth,:) = bsxfun(@plus,c(:,ones(1,sum(bth))),c(bth,:)')'/2 + epsilon;
switch mv2
case 'powe
没有合适的资源?快使用搜索试试~ 我知道了~
Brain Connectivity Toolbox(BCT)
共143个文件
m:133个
mat:10个
需积分: 36 10 下载量 17 浏览量
2022-10-12
21:51:41
上传
评论
收藏 943KB ZIP 举报
温馨提示
基于MATLAB的复杂网络分析工具
资源详情
资源评论
资源推荐
收起资源包目录
Brain Connectivity Toolbox(BCT) (143个子文件)
generative_model.m 23KB
generate_fc.m 9KB
predict_fc.m 9KB
null_model_dir_sign.m 9KB
rentian_scaling_3d.m 8KB
null_model_und_sign.m 8KB
rentian_scaling_2d.m 8KB
mleme_constraint_model.m 8KB
community_louvain.m 8KB
link_communities.m 6KB
efficiency_wei.m 6KB
clustering_coef_wu_sign.m 6KB
findpaths.m 5KB
motif4funct_wei.m 5KB
modularity_dir.m 5KB
modularity_und.m 5KB
gateway_coef_sign.m 5KB
align_matrices.m 5KB
latmio_und_connected.m 5KB
motif3funct_wei.m 4KB
quasi_idempotence.m 4KB
latmio_dir_connected.m 4KB
motif4struct_wei.m 4KB
search_information.m 4KB
randomizer_bin_und.m 4KB
motif4funct_bin.m 4KB
demo_efficiency_measures.m 4KB
resource_efficiency_bin.m 4KB
reorder_matrix.m 4KB
evaluate_generative_model.m 4KB
randmio_und_connected.m 3KB
distance_wei_floyd.m 3KB
navigation_wu.m 3KB
latmio_und.m 3KB
core_periphery_dir.m 3KB
reorder_mod.m 3KB
motif3struct_wei.m 3KB
randmio_dir_connected.m 3KB
weight_conversion.m 3KB
clique_communities.m 3KB
charpath.m 3KB
motif3funct_bin.m 3KB
edge_betweenness_wei.m 3KB
consensus_und.m 3KB
partition_distance.m 3KB
distance_wei.m 3KB
betweenness_wei.m 3KB
make_motif34lib.m 3KB
latmio_dir.m 3KB
efficiency_bin.m 3KB
randmio_dir_signed.m 3KB
randmio_und_signed.m 3KB
motif4struct_bin.m 3KB
gtom.m 3KB
rout_efficiency.m 3KB
makerandCIJdegreesfixed.m 3KB
randmio_und.m 2KB
edge_betweenness_bin.m 2KB
assortativity_bin.m 2KB
backbone_wu.m 2KB
rich_club_bd.m 2KB
assortativity_wei.m 2KB
matching_ind.m 2KB
motif3struct_bin.m 2KB
randmio_dir.m 2KB
rich_club_wd.m 2KB
reachdist.m 2KB
rich_club_wu.m 2KB
rich_club_bu.m 2KB
pagerank_centrality.m 2KB
path_transitivity.m 2KB
mean_first_passage_time.m 2KB
makeevenCIJ.m 2KB
betweenness_bin.m 2KB
transitivity_wd.m 2KB
reorderMAT.m 2KB
kcore_bd.m 2KB
breadth.m 2KB
transitivity_bd.m 2KB
kcore_bu.m 2KB
edge_nei_overlap_bd.m 2KB
get_components.m 2KB
local_assortativity_wu_sign.m 2KB
threshold_proportional.m 2KB
agreement.m 2KB
edge_nei_overlap_bu.m 2KB
diversity_coef_sign.m 2KB
flow_coef_bd.m 2KB
clustering_coef_wd.m 2KB
randomize_graph_partial_und.m 2KB
grid_communities.m 2KB
cycprob.m 2KB
adjacency_plot_und.m 2KB
participation_coef.m 1KB
participation_coef_sign.m 1KB
find_motif34.m 1KB
clustering_coef_bd.m 1KB
jdegree.m 1KB
erange.m 1KB
makefractalCIJ.m 1KB
共 143 条
- 1
- 2
youngstudent
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0