-
Notifications
You must be signed in to change notification settings - Fork 2
/
GC_initModel.m
205 lines (187 loc) · 8.47 KB
/
GC_initModel.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
function [tree,neuron,treeFilename] = GC_initModel(ostruct)
if ~isfield( ostruct,'reducecells')
ostruct.reducecells = 0;
end
if ~isfield( ostruct,'newborn')
ostruct.newborn = 0;
end
if ~isfield( ostruct,'forcecalcload')
ostruct.forcecalcload = 0;
end
neuron.params.celsius = 24; % temperature
neuron.params.prerun = 400; % large-dt prerun to let the system equilibrate
neuron.params.v_init = -90; % initial membrane voltage
neuron.params.dt = 1; % standard time step (is automatically changed to a smaller dt in most simulations below)
neuron.params.nseg = 'dlambda'; % number of segments, can be constant or 'dlambda' to adjust it according to the d-lambda rule
neuron.params.v_init = -80;
AHflag = false;
if ostruct.vmodel == 0 % only channels active at subthreshold
mechoptions = '-p';
elseif ostruct.vmodel > 0
mechoptions = '-a-p-n'; % active model as published in Beining et al 2017
else
mechoptions = '-o-a-p'; % old AH99 model
AHflag = true;
end
if ostruct.newborn
mechoptions = strcat(mechoptions,'-y');
end
if ostruct.ratadjust
mechoptions = strcat(mechoptions,'-ra');
end
if ostruct.ratadjust
str = '_ratadjust';
else
str = '';
end
if ~isnan(ostruct.usemorph)
switch ostruct.usemorph
case 1 % SH07 cells
if ostruct.adjustloads && ~ostruct.forcecalcload && exist(fullfile(pwd,'morphos','SH_07_all_repairedandsomaAIS_MLyzed_loadadjusted.mtr'),'file')
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','SH_07_all_repairedandsomaAIS_MLyzed_loadadjusted.mtr'));
else
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','SH_07_all_repairedandsomaAIS_MLyzed.mtr'));
end
tname = 'SH07all2';
case 2 % synth adult mouse cells
if ostruct.adjustloads && ~ostruct.forcecalcload && exist(fullfile(pwd,'morphos','mouse_AAVart_old_pruned_axon_loadadjusted.mtr'),'file')
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','mouse_AAVart_old_pruned_axon_loadadjusted.mtr'));
else
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','mouse_AAVart_old_pruned_axon.mtr'));
end
tname = 'mouse_matGC_art';
neuron.params.exchfolder = 't2nexchange_aGCmorphsim';
case 3 % synth young mouse cells
if ostruct.adjustloads && ~ostruct.forcecalcload && exist(fullfile(pwd,'morphos','mouse_RVart_pruned_axon_loadadjusted.mtr'),'file')
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','mouse_RVart_pruned_axon_loadadjusted.mtr'));
else
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','mouse_RVart_pruned_axon.mtr'));
end
tname = 'mouse_abGC_art';
neuron.params.exchfolder = 't2nexchange_aGCmorphsim2';
case 4 % adult rat cells
if ostruct.adjustloads && ~ostruct.forcecalcload && exist(fullfile(pwd,'morphos',sprintf('Beining_AAV_contra_MLyzed_axon_loadadjusted%s.mtr',str)),'file')
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos',sprintf('Beining_AAV_contra_MLyzed_axon_loadadjusted%s.mtr',str)));
else
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','Beining_AAV_contra_MLyzed_axon.mtr'));
end
tname = 'rat_mGC_Beining';
neuron.params.exchfolder = 't2nexchange_aGCmorphsim6';
case 5 % synth adult rat cells
if ostruct.adjustloads && ~ostruct.forcecalcload && exist(fullfile(pwd,'morphos',sprintf('rat_AAVart_old_pruned_axon_loadadjusted%s.mtr',str)),'file')
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos',sprintf('rat_AAVart_old_pruned_axon_loadadjusted%s.mtr',str)));
else
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','rat_AAVart_old_pruned_axon.mtr'));
end
tname = 'rat_matGC_art';
neuron.params.exchfolder = 't2nexchange_aGCmorphsim3';
case 6 % synth young rat cells
if ostruct.adjustloads && ~ostruct.forcecalcload && exist(fullfile(pwd,'morphos',sprintf('rat_RVart_pruned_axon_loadadjusted%s.mtr',str)),'file')
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos',sprintf('rat_RVart_pruned_axon_loadadjusted%s.mtr',str)));
else
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','rat_RVart_pruned_axon.mtr'));
end
tname = 'rat_abGC_art';
neuron.params.exchfolder = 't2nexchange_aGCmorphsim4';
case 7 % Claiborne rat cells
if ostruct.adjustloads && ~ostruct.forcecalcload && exist(fullfile(pwd,'morphos',sprintf('Claiborne_male_MLyzed_axon_loadadjusted%s.mtr',str)),'file')
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos',sprintf('Claiborne_male_MLyzed_axon_loadadjusted%s.mtr',str)));
else
[tree,treeFilename,treepath]=load_tree(fullfile(pwd,'morphos','Claiborne_male_MLyzed_axon.mtr'));
end
tname = 'rat_mGC_Claiborne';
neuron.params.exchfolder = 't2nexchange_aGCmorphsim5';
end
neuron.experiment = tname;
if AHflag
neuron.experiment = strcat(neuron.experiment,'_AH99');
end
ntree = min(numel(tree),15);
tree=tree(1:ntree);
if ostruct.usecol
if any(ostruct.usemorph == [1,4]) % reconstructed morphologies
colors = colorme(ntree,'-grb');
else
colors = colorme(ntree,'-grg');
end
else
colors = colorme(ntree);
end
for t = 1:numel(tree)
tree{t}.col = colors(t);
end
else
[tree,treeFilename,treepath]=load_tree;
if isempty(tree)
return
end
colors = colorme(numel(tree));
for t = 1:numel(tree)
tree{t}.col = colors(t);
end
tname = treeFilename(1:end-4);
end
if ~all(cellfun(@(x) isfield(x,'NID'),tree)) || ~all(cellfun(@(x) exist(fullfile(pwd,'morphos','hocs',[x.NID,'.hoc']),'file'),tree))
answer = questdlg('Caution! Not all of your trees have been transformed for NEURON yet! Transforming now..','Transform trees','OK','Cancel','OK');
if strcmp(answer,'OK')
tree = t2n_writeTrees(tree,tname,fullfile(treepath,treeFilename));
end
end
if isempty(tree)
return
end
if isstruct(tree)
tree={tree};
elseif iscell(tree{1})
tree=tree{1};
end
cd(pwd)
for t = 1:numel(tree)
tree{t} = sort_tree(tree{t},'-LO');
neuron.mech{t} = [];
if ~AHflag && ostruct.scalespines % spine scaling ignored in AH99 as already taken into account in the biophys
neuron.mech{t} = t2n_catStruct(GC_biophys(mechoptions),GC_spinedensity(ostruct.scalespines*0.9));
else
neuron.mech{t} = t2n_catStruct(GC_biophys(mechoptions));
end
if ~AHflag || ostruct.changeAHion
neuron = t2n_setionconcentration(neuron,'Mongiat');
end
if ~isfield(tree{t},'col')
tree{t}.col{1} = rand(1,3);
end
if ostruct.noise ~= 0
neuron.pp{t}.InGauss = struct('node',1,'mean',0.01,'stdev',0.01,'del',0,'dur',1e9);
end
end
if ostruct.scalespines
neuron = t2n_implicitSpines(neuron);
end
%%% This is the Hay 2013 implementation of adjusting soma and AIS
%%% conductance according to dendritic morphology
if ostruct.adjustloads
if any(cellfun(@(x) ~isfield(x,'Rho_soma') | ~isfield(x,'Rho_AIS'),tree)) || ostruct.forcecalcload
tree = calculate_loads(neuron,tree);
save_tree(tree,fullfile(treepath,[treeFilename(1:end-4),sprintf('_loadadjusted%s.mtr',str)]));
end
if ostruct.usemorph >= 4 %rat
neuron = adjust_loads(neuron,tree,'r',ostruct);
else %mouse
neuron = adjust_loads(neuron,tree,'m');
end
end
if ostruct.reducecells
if ostruct.usemorph ~= 1
tree=tree((1:3)+2);
neuron.mech = neuron.mech((1:3)+2);
else
tree=tree(3);
neuron.mech = neuron.mech(3);
end
neuron.experiment = strcat(neuron.experiment,'_reduceNs');
end
if ostruct.ratadjust
neuron.experiment = strcat(neuron.experiment,'_ratadjust');
end
treeFilename = fullfile(treepath,treeFilename);
fprintf('Model initialized...%s\n',neuron.experiment)