Skip to content

Commit

Permalink
Uses hasattr() to check if conductanceSource mechanism is available
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-tharayil authored and jorblancoa committed Feb 29, 2024
1 parent 62fd6e2 commit d477fed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
14 changes: 3 additions & 11 deletions neurodamus/core/stimuli.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,17 +434,9 @@ 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):

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

if 'conductanceSource' in mList:

# Checks if new conductanceSource mechanism is available
if hasattr(Neuron.h, "conductanceSource"):
self.clamp = Neuron.h.conductanceSource(position, sec=cell_section)
else:
self.clamp = Neuron.h.SEClamp(position, sec=cell_section)
Expand Down
11 changes: 1 addition & 10 deletions neurodamus/stimulus_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,17 +733,8 @@ def __init__(self, target, stim_info: dict, cell_manager):
if not sc.exists():
continue

# Checks if new conductanceSource mechanism is available
mt = Nd.h.MechanismType(1)
mname = Nd.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:
if hasattr(Nd.h, "conductanceSource"):
seclamp = Nd.h.conductanceSource(tpoint_list.x[sec_id], sec=sc.sec)
else:
# create single electrode voltage clamp at location
Expand Down

0 comments on commit d477fed

Please sign in to comment.