-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTOY_MODEL.m
145 lines (101 loc) · 3.16 KB
/
TOY_MODEL.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
%% TOY MODEL
%% Define the network
%The network will consist on 10 nodes and the first node will be the only node
%connected with the rest of the nodes (one hub).
nNodes=10;
C=zeros(nNodes,nNodes);
for n=1:3
C(n,1:3)=0.12;
end
C(4,:)=0.2;
C(:,4)=0.2;
for n=5:10
C(n,5:10)=0.12;
end
%plot te structural connectivity
figure
imagesc(C)
xlabel('Node')
ylabel('Node')
title('SC')
hold on
colormap('summer')
%% BUild the model
tic
% simulation parameters
dt = 0.01; % time step (in seconds)
Tmax=1000;
TRsec=2;
nSubs=1;
tvect=1:dt:Tmax*TRsec*nSubs; % vector of time stamps (in seconds)
Nt=length(tvect); % number of time points
xs=zeros(Tmax*nSubs,nNodes); % prepare variable for BOLD
% G value
G=0.3;
% omega
f=0.05*ones(nNodes,1); % frequency, i.e., number of cycles per unit time
omega = 2*pi*f; % angular velocity
% bifurcation parameter a
a_val=0;
a = a_val*ones(nNodes,1); % same for all nodes
% gC and strength
gC = G*C;
sumgC = sum(gC,2);
% noise
sig = 0.04;
dsig = sqrt(dt)*sig; % to avoid sqrt(dt) at each time step
% Bifurcation parameters to study
a_hub_vals=0:-0.5:-3;
N_a_hub=length(a_hub_vals);
% external stimulation parameters
f_ext=0.05;
omega_ext=2*pi*f_ext;
A_ext=0.2;
z_ext=A_ext*exp(i*omega_ext*tvect); % apply function for all values of t
C_ext=0.2;
M_max=9;
% Prepare variables to store
FC=zeros(N_a_hub, M_max, nNodes, nNodes);
%% Run the simulation
for aidx=1:N_a_hub
%value of the hub
a_hub=a_hub_vals(aidx);
a(4)=a_hub;
% Initialize z and let it evolve under the effect of the network
z_ini=0.1*complex(ones(nNodes,1),ones(nNodes,1)); % initialize z
z=z_ini;
for t=1:dt:3000 % Leaving 3000 seconds for the model to stabilize
input = gC*z - sumgC.*z; % input from other nodes
z = z + dt * ( a.*z - (abs(z).^2).*z + 1i*omega.*z + input) + dsig*complex(randn(nNodes,1),randn(nNodes,1));
end
z_ini=z; % Take the final z as the initial value for the next step
for M=1:M_max
z=z_ini;
tp=1; % time steps for simulation
tpbold=1; % time steps for BOLD
for t=1:dt:Tmax*TRsec*nSubs
input = gC*z - sumgC.*z;
input(4) = input(4) + (M-1)*C_ext*(z_ext(tp)-z(4)); % add external input
z = z + dt * ( a.*z - (abs(z).^2).*z + 1i*omega.*z + input) + dsig*complex(randn(nNodes,1),randn(nNodes,1));
tp=tp+1;
if abs(mod(t,TRsec))<dt/2
xs(tpbold,:)=real(z)'; % save BOLD
tpbold=tpbold+1; % Get index ready for next time step
end
end
FC(aidx,M,:, :) = corrcoef(xs(1:end,:));
end
end
toc
%% FIGURES
%subplots of the diff between FC matrix of perturbed - not perturbed network for each value of bifurcation parameter
figure()
for iii=1:N_a_hub
subplot(3,3,iii)
clim=[0 1]
imagesc(squeeze(FC(iii,9,:,:))-squeeze(FC(iii,1,:,:)),clim)
colorbar()
end
%plot global FC for each value of bifurcation parameter (rows) at increasing levels of perturbation intensity (columns)
figure()
imagesc(mean(mean(FC,4),3))