Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 06e42fc

Browse files
Merge pull request #496 from Hjorthmedh/master
replace_axon now allows the axon length and numbr of sections to be set
2 parents d46979b + e05291c commit 06e42fc

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

bluepyopt/ephys/morphologies.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def __init__(
5757
do_set_nseg=True,
5858
comment='',
5959
replace_axon_hoc=None,
60+
axon_stub_length=60,
61+
axon_nseg_frequency=40,
6062
nseg_frequency=40,
6163
morph_modifiers=None,
6264
morph_modifiers_hoc=None,
@@ -74,6 +76,8 @@ def __init__(
7476
python, replace_axon is used instead. Must include
7577
'proc replace_axon(){ ... }
7678
If None,the default replace_axon is used
79+
axon_stub_length (float): Length of replacement axon
80+
axon_nseg_frequency (int): frequency of nseg, for axon
7781
nseg_frequency (float): frequency of nseg
7882
do_set_nseg (bool): if True, it will use nseg_frequency
7983
morph_modifiers (list): list of functions to modify the icell
@@ -90,6 +94,8 @@ def __init__(
9094
morphology_path = str(morphology_path)
9195
self.morphology_path = morphology_path
9296
self.do_replace_axon = do_replace_axon
97+
self.axon_stub_length = axon_stub_length
98+
self.axon_nseg_frequency = axon_nseg_frequency
9399
self.do_set_nseg = do_set_nseg
94100
self.nseg_frequency = nseg_frequency
95101
self.morph_modifiers = morph_modifiers
@@ -155,7 +161,9 @@ def instantiate(self, sim=None, icell=None):
155161
self.set_nseg(icell)
156162

157163
if self.do_replace_axon:
158-
self.replace_axon(sim=sim, icell=icell)
164+
self.replace_axon(sim=sim, icell=icell,
165+
axon_stub_length=self.axon_stub_length,
166+
axon_nseg_frequency=self.axon_nseg_frequency)
159167

160168
if self.morph_modifiers is not None:
161169
for morph_modifier in self.morph_modifiers:
@@ -172,7 +180,8 @@ def set_nseg(self, icell):
172180
section.nseg = 1 + 2 * int(section.L / self.nseg_frequency)
173181

174182
@staticmethod
175-
def replace_axon(sim=None, icell=None):
183+
def replace_axon(sim=None, icell=None,
184+
axon_stub_length=60, axon_nseg_frequency=40):
176185
"""Replace axon"""
177186

178187
nsec = len([sec for sec in icell.axonal])
@@ -187,8 +196,10 @@ def replace_axon(sim=None, icell=None):
187196
sim.neuron.h.distance(0, 0.5, sec=icell.soma[0])
188197

189198
for section in icell.axonal:
190-
# If distance to soma is larger than 60, store diameter
191-
if sim.neuron.h.distance(1, 0.5, sec=section) > 60:
199+
# If distance to soma is larger than
200+
# axon_stub_length, store diameter
201+
if sim.neuron.h.distance(1, 0.5, sec=section) \
202+
> axon_stub_length:
192203
ais_diams[1] = section.diam
193204
break
194205

@@ -199,16 +210,16 @@ def replace_axon(sim=None, icell=None):
199210
sim.neuron.h.execute('create axon[2]', icell)
200211

201212
for index, section in enumerate(icell.axon):
202-
section.nseg = 1
203-
section.L = 30
213+
section.L = axon_stub_length / 2
214+
section.nseg = 1 + 2 * int(section.L / axon_nseg_frequency)
204215
section.diam = ais_diams[index]
205216
icell.axonal.append(sec=section)
206217
icell.all.append(sec=section)
207218

208219
icell.axon[0].connect(icell.soma[0], 1.0, 0.0)
209220
icell.axon[1].connect(icell.axon[0], 1.0, 0.0)
210221

211-
logger.debug('Replace axon with AIS')
222+
logger.debug(f"Replace axon with AIS, {axon_stub_length=}")
212223

213224
default_replace_axon_hoc = \
214225
'''

0 commit comments

Comments
 (0)