Skip to content

Commit

Permalink
Checks if conductanceSource point process is available before trying …
Browse files Browse the repository at this point in the history
…to insert it
  • Loading branch information
joseph-tharayil committed Feb 27, 2024
1 parent 73d945d commit b794902
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
19 changes: 18 additions & 1 deletion neurodamus/core/stimuli.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,24 @@ class _DynamicClamp:
def __init__(self, cell_section, position=0.5, clamp_container=None,
stim_vec_mode=True, time_vec=None, stim_vec=None,
reversal=0.0, **clamp_params):
self.clamp = Neuron.h.conductanceSource(position, sec=cell_section)


# Check sif new conductanceSource mechanism is available
mt = h.MechanismType(1)
mname = h.ref('')
mList = []
for i in range(mt.count()):
mt.select(i)
mt.selected(mname)
mList.append(mname[0])

if 'conductanceSource' in mList

self.clamp = Neuron.h.conductanceSource(position, sec=cell_section)

else:
self.clamp = Neuron.h.SEClamp(position, sec=cell_section)

if stim_vec_mode:
assert time_vec is not None and stim_vec is not None
self.clamp.dur1 = time_vec[-1]
Expand Down
17 changes: 16 additions & 1 deletion neurodamus/stimulus_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,22 @@ def __init__(self, target, stim_info: dict, cell_manager):
continue

# create single electrode voltage clamp at location
seclamp = Nd.h.conductanceSource(tpoint_list.x[sec_id], sec=sc.sec)

# Checks if new conductanceSource mechanism is available
mt = h.MechanismType(1)
mname = h.ref('')
mList = []
for i in range(mt.count()):
mt.select(i)
mt.selected(mname)
mList.append(mname[0])

# If conductanceSource not available, insert standard SEClamp
if 'conductanceSource' in mList:
seclamp = Nd.h.conductanceSource(tpoint_list.x[sec_id], sec=sc.sec)
else:
seclamp = Nd.h.SEClamp(tpoint_list.x[sec_id], sec=sc.sec)

seclamp.rs = self.rs
seclamp.dur1 = self.duration
seclamp.amp1 = self.vhold
Expand Down

0 comments on commit b794902

Please sign in to comment.