-
Notifications
You must be signed in to change notification settings - Fork 1
/
bounds.g
249 lines (166 loc) · 4.66 KB
/
bounds.g
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
//genesis
//
// $Id: bounds.g 1.3.1.2 Thu, 04 Apr 2002 11:55:56 +0200 hugo $
//
//////////////////////////////////////////////////////////////////////////////
//'
//' Purkinje tutorial
//'
//' (C) 1998-2002 BBF-UIA
//'
//' see our site at http://www.bbf.uia.ac.be/ for more information regarding
//' the Purkinje cell and genesis simulation software.
//'
//'
//' functional ideas ... Erik De Schutter, [email protected]
//' genesis coding ..... Hugo Cornelis, [email protected]
//'
//' general feedback ... Reinoud Maex, Erik De Schutter
//'
//////////////////////////////////////////////////////////////////////////////
// bounds.g : boundaries for xcell and xgraph
int include_bounds
if ( {include_bounds} == 0 )
include_bounds = 1
//v last read boundary file
str boundsLastFile = ""
///
/// SH: BoundsInit
///
/// PA: path..: boundary file
///
/// DE: Initialize boundaries for xcell and xgraph
/// boundaries are set as specified in {path}
/// {path} is registered in boundsLastFile if successfull
///
function BoundsInit(path)
str path
//- give diagnostics
echo "Setting up boundaries from file "{path}
//- create neutral container
create neutral /bounds
//- make it the current element
pushe /bounds
//! create the boundary tab file if it does not exist
//sh "touch bounds.tab"
//- open the tab file
openfile {path} r
//- read first line from file
str line = {readfile {path} -line}
//- loop over all lines in the file
//! I do not know when EOF is read (undocumented), but this seems to
//! work
while (line != "")
//- extract element name
str element = {getarg {arglist {line}} -arg 1}
//- if element does not start with comment char
if ({substring {element} 0 0} != "#")
//- create element for absolute boundaries
create neutral {element}_abs
//- addfields for minima and maxima
addfield {element}_abs \
xcellmin -description \
"XCell minimum, absolute mode"
addfield {element}_abs \
xcellmax -description \
"XCell maximum, absolute mode"
addfield {element}_abs \
xgraphmin -description \
"XGraph minimum, absolute mode"
addfield {element}_abs \
xgraphmax -description \
"XGraph maximum, absolute mode"
//- set the fields for maxima and minima as in the file
setfield {element}_abs \
xcellmin {getarg {arglist {line}} -arg 2} \
xcellmax {getarg {arglist {line}} -arg 3} \
xgraphmin {getarg {arglist {line}} -arg 4} \
xgraphmax {getarg {arglist {line}} -arg 5}
//- create element for normalized values
create neutral {element}_norm
//- addfields for minima and maxima
addfield {element}_norm \
xcellmin -description \
"XCell minimum, normalized mode"
addfield {element}_norm \
xcellmax -description \
"XCell maximum, normalized mode"
addfield {element}_norm \
xgraphmin -description \
"XGraph minimum, normalized mode"
addfield {element}_norm \
xgraphmax -description \
"XGraph maximum, normalized mode"
//- set the fields for maxima and minima as in the file
setfield {element}_norm \
xcellmin {getarg {arglist {line}} -arg 6} \
xcellmax {getarg {arglist {line}} -arg 7} \
xgraphmin {getarg {arglist {line}} -arg 8} \
xgraphmax {getarg {arglist {line}} -arg 9}
end
//- read next line from the file
line = {readfile {path} -line}
end
//- register last boundary file
boundsLastFile = {path}
//- close the tab file
closefile {path}
//- pop previous current element
pope
end
///
/// SH: BoundElementName
///
/// PA: source: subelement of compartment
/// value.: field of subelement
/// iMode.: 4 : absolute channel mode
/// 5 : normalized channel mode
///
/// RE: name of boundary element
///
/// DE: Give the name for a boundary element in the given context
///
function BoundElementName(source,value,iMode)
str source
str value
int iMode
//v name of boundary element
str bound
//- if chanmode is 4
if (iMode == 4)
//- construct element name with boundaries for absolute mode
bound = "/bounds/" \
@ {source} \
@ "_" \
@ {value} \
@ "_abs"
//- else if chanmode is 5
elif (iMode == 5)
//- construct element name with boundaries for normalized mode
bound = "/bounds/" \
@ {source} \
@ "_" \
@ {value} \
@ "_norm"
//- else
else
//- give diagnostics
echo "Illegal chanmode for boundary name creation ("{iMode}")"
//- set result : empty
bound = ""
end
//- return result
return {bound}
end
///
/// SH: BoundsReread
///
/// DE: Reread the boundary file registered in {boundsLastFile}
///
function BoundsReread
//- delete root boundary element
delete /bounds
//- read registered boundary file
BoundsInit {boundsLastFile}
end
end