@@ -161,9 +161,8 @@ def inst_distribution(self):
161
161
# Use this special formatting to bypass missing keys
162
162
return string .Formatter ().vformat (self .distribution , (), dist_dict )
163
163
164
- def eval_dist (self , values , distance ):
165
- """Create the final dist string"""
166
-
164
+ def scale_dict (self , values , distance ):
165
+ """Create scale dictionary"""
167
166
scale_dict = {}
168
167
if isinstance (values , dict ):
169
168
for k , v in values .items ():
@@ -172,6 +171,12 @@ def eval_dist(self, values, distance):
172
171
scale_dict ["value" ] = format_float (values )
173
172
scale_dict ["distance" ] = format_float (distance )
174
173
174
+ return scale_dict
175
+
176
+ def eval_dist (self , values , distance ):
177
+ """Create the final dist string"""
178
+ scale_dict = self .scale_dict (values , distance )
179
+
175
180
return self .inst_distribution .format (** scale_dict )
176
181
177
182
def scale (self , values , segment , sim = None ):
@@ -261,3 +266,51 @@ def acc_scale_iexpr(self, value, constant_formatter=format_float):
261
266
ArbFileMorphology .region_labels ['somatic' ].ref
262
267
)
263
268
return generate_acc_scale_iexpr (iexpr , variables , constant_formatter )
269
+
270
+
271
+ class NrnSegmentSomaDistanceStepScaler (NrnSegmentSomaDistanceScaler ,
272
+ ParameterScaler , DictMixin ):
273
+
274
+ """Scaler based on distance from soma with a step function"""
275
+ SERIALIZED_FIELDS = ('name' , 'comment' , 'distribution' , )
276
+
277
+ def __init__ (
278
+ self ,
279
+ name = None ,
280
+ distribution = None ,
281
+ comment = '' ,
282
+ dist_param_names = None ,
283
+ soma_ref_location = 0.5 ,
284
+ step_begin = None ,
285
+ step_end = None ):
286
+ """Constructor
287
+ Args:
288
+ name (str): name of this object
289
+ distribution (str): distribution of parameter dependent on distance
290
+ from soma. string can contain `distance` and/or `value` as
291
+ placeholders for the distance to the soma and parameter value
292
+ respectively. It can also contain step_begin and step_end.
293
+ dist_param_names (list): list of names of parameters that
294
+ parametrise the distribution. These names will become
295
+ attributes of this object.
296
+ The distribution string should contain these names, and they
297
+ will be replaced by values of the corresponding attributes
298
+ soma_ref_location (float): location along the soma used as origin
299
+ from which to compute the distances. Expressed as a fraction
300
+ (between 0.0 and 1.0).
301
+ step_begin (float): distance at which the step begins
302
+ step_end (float): distance at which the step ends
303
+ """
304
+
305
+ super (NrnSegmentSomaDistanceStepScaler , self ).__init__ (
306
+ name , distribution , comment , dist_param_names ,
307
+ soma_ref_location = soma_ref_location )
308
+ self .step_begin = step_begin
309
+ self .step_end = step_end
310
+
311
+ def scale_dict (self , values , distance ):
312
+ scale_dict = super ().scale_dict (values , distance )
313
+ scale_dict ["step_begin" ] = self .step_begin
314
+ scale_dict ["step_end" ] = self .step_end
315
+
316
+ return scale_dict
0 commit comments