@@ -58,7 +58,7 @@ def __init__(
5858 comment = '' ,
5959 replace_axon_hoc = None ,
6060 axon_stump_length = 60 ,
61- axon_stump_nsec = 2 ,
61+ axon_nseg_frequency = 40 ,
6262 nseg_frequency = 40 ,
6363 morph_modifiers = None ,
6464 morph_modifiers_hoc = None ,
@@ -95,7 +95,7 @@ def __init__(
9595 self .morphology_path = morphology_path
9696 self .do_replace_axon = do_replace_axon
9797 self .axon_stump_length = axon_stump_length
98- self .axon_stump_nsec = axon_stump_nsec
98+ self .axon_nseg_frequency = axon_nseg_frequency
9999 self .do_set_nseg = do_set_nseg
100100 self .nseg_frequency = nseg_frequency
101101 self .morph_modifiers = morph_modifiers
@@ -163,7 +163,7 @@ def instantiate(self, sim=None, icell=None):
163163 if self .do_replace_axon :
164164 self .replace_axon (sim = sim , icell = icell ,
165165 axon_stump_length = self .axon_stump_length ,
166- n_sections = self .axon_stump_nsec )
166+ axon_nseg_frequency = self .axon_nseg_frequency )
167167
168168 if self .morph_modifiers is not None :
169169 for morph_modifier in self .morph_modifiers :
@@ -180,60 +180,45 @@ def set_nseg(self, icell):
180180 section .nseg = 1 + 2 * int (section .L / self .nseg_frequency )
181181
182182 @staticmethod
183- def replace_axon (sim = None , icell = None , axon_stump_length = 60 , n_sections = 2 ):
183+ def replace_axon (sim = None , icell = None , axon_stump_length = 60 , axon_nseg_frequency = 40 ):
184184 """Replace axon"""
185185
186186 nsec = len ([sec for sec in icell .axonal ])
187187
188- print (f"In replace_axon { nsec = } " )
189-
190188 if nsec == 0 :
191- ais_diams = [1 ] * n_sections
189+ ais_diams = [1 , 1 ]
192190 elif nsec == 1 :
193- sec_x = [min (1 , x / n_sections * axon_stump_length / icell .axon [0 ].L )
194- for x in range (0 , n_sections )]
195- ais_diams = [icell .axon [0 ](sx ).diam for sx in sec_x ]
191+ ais_diams = [icell .axon [0 ].diam , icell .axon [0 ].diam ]
196192 else :
197- ais_diams = [icell .axon [0 ].diam ] * n_sections
193+ ais_diams = [icell .axon [0 ].diam , icell . axon [ 0 ]. diam ]
198194 # Define origin of distance function
199195 sim .neuron .h .distance (0 , 0.5 , sec = icell .soma [0 ])
200196
201- end_point_dist = np .arange (1 , n_sections + 1 ) \
202- * axon_stump_length / n_sections
203-
204- idx = 1
205-
206197 for section in icell .axonal :
207- if idx >= len (ais_diams ):
198+ # If distance to soma is larger than
199+ # axon_stump_length, store diameter
200+ if sim .neuron .h .distance (1 , 0.5 , sec = section ) \
201+ > axon_stump_length :
202+ ais_diams [1 ] = section .diam
208203 break
209- if sim .neuron .h .distance (1 , 0.5 , sec = section )\
210- < end_point_dist [idx ]:
211- ais_diams [idx :] = section .diam
212- else :
213- idx += 1
214204
215205 for section in icell .axonal :
216206 sim .neuron .h .delete_section (sec = section )
217207
218208 # Create new axon array
219- sim .neuron .h .execute (f" create axon[{ n_sections } ]" , icell )
209+ sim .neuron .h .execute (' create axon[2]' , icell )
220210
221211 for index , section in enumerate (icell .axon ):
222- section .nseg = 1
223- section .L = axon_stump_length / n_sections
212+ section .L = axon_stump_length / 2
213+ section .nseg = 1 + 2 * int ( section . L / axon_nseg_frequency )
224214 section .diam = ais_diams [index ]
225215 icell .axonal .append (sec = section )
226216 icell .all .append (sec = section )
227217
228- for index in range (len (icell .axon )):
229- if index == 0 :
230- icell .axon [0 ].connect (icell .soma [0 ], 1.0 , 0.0 )
231- else :
232- icell .axon [index ].connect (icell .axon [index - 1 ], 1.0 , 0.0 )
233-
234- logger .debug (f"Replace axon with AIS { axon_stump_length = } , "
235- f"{ n_sections = } " )
218+ icell .axon [0 ].connect (icell .soma [0 ], 1.0 , 0.0 )
219+ icell .axon [1 ].connect (icell .axon [0 ], 1.0 , 0.0 )
236220
221+ logger .debug (f"Replace axon with AIS, { axon_stump_length = } " )
237222
238223 default_replace_axon_hoc = \
239224 '''
0 commit comments