def find_units(variable): if variable in recording.UNITS_MAP: return recording.UNITS_MAP[variable] else: # works with NEURON 7.3, not with 7.1, 7.2 not tested nrn_units = h.units(variable.split('.')[-1]) pq_units = nrn_units.replace("2", "**2").replace("3", "**3") return pq_units
def add_button(name, actions=None, value=None, extraData=None): if value is not None: valueUnits = h.units(value) if valueUnits != '': name += " (" + valueUnits + ")" button = GeppettoJupyterGUISync.ButtonSync(widget_id=G.newId(), widget_name=name, extraData=extraData) if actions is not None: button.on_click(actions) return button
def guess_units(variable): # works with NEURON 7.3, not with 7.1, 7.2 not tested nrn_units = h.units(variable.split('.')[-1]) pq_units = nrn_units.replace("2", "**2").replace("3", "**3") return pq_units
ax1 = fig.add_subplot(2,1,1) soma_plot = ax1.plot(t_vec, soma_v_vec, color='black') dend_plot = ax1.plot(t_vec, dend_v_vec, color='red') #rev_plot = ax1.plot([t_vec[0], t_vec[-1]], [syn_.e, syn_.e], # color='blue', linestyle=':') ax1.legend(soma_plot + dend_plot, ['soma', 'dend(0.5)', 'syn reversal']) ax1.set_ylabel('mV') ax1.set_xlim([25,125]) #ax1.set_xticks([]) # Use ax2's tick labels ax2 = fig.add_subplot(2,1,2, sharex = ax1) syn_plot = ax2.plot(t_vec, syn_i_vec, color='blue') ax2.legend(syn_plot,\ ['injected current']) ax2.set_ylabel(h.units('ExpSyn.i')) ax2.set_xlabel('time (ms)') ax2.set_xlim([25,125]) pyplot.show() # Draw fig2 = pyplot.figure(figsize=(8,4)) ax1 = fig2.add_subplot(3,1,1) soma_plot = ax1.plot(t_vec, soma_v_vec, color='black') ax1.legend(soma_plot,'soma') ax1.set_ylabel('mV') ax1.set_xlim([25,125]) ax1.set_ylim([-75,-65])
# Insert active Hodgkin-Huxley current in the soma soma.insert('hh') for seg in soma: seg.hh.gnabar = 0.12 # Sodium conductance in S/cm2 seg.hh.gkbar = 0.036 # Potassium conductance in S/cm2 seg.hh.gl = 0.0003 # Leak conductance in S/cm2 seg.hh.el = -54.3 # Reversal potential in mV # Insert passive current in the dendrite dend.insert('pas') for seg in dend: seg.pas.g = 0.001 # Passive conductance in S/cm2 seg.pas.e = -65 # Leak reversal potential mV print(h.units('gnabar_hh')) for sec in h.allsec(): h.psection(sec=sec) #stimulation stim = h.IClamp(dend(1)) print("segment = {}".format(stim.get_segment())) dir(stim) stim.delay = 5 stim.dur = 1 stim.amp = 0.1
fig = pyplot.figure(figsize=(8, 4)) ax1 = fig.add_subplot(2, 1, 1) soma_plot = ax1.plot(t_vec, soma_v_vec, color='black') dend_plot = ax1.plot(t_vec, dend_v_vec, color='red') rev_plot = ax1.plot([t_vec[0], t_vec[-1]], [syn_.e, syn_.e], color='blue', linestyle=':') ax1.legend(soma_plot + dend_plot + rev_plot, ['soma', 'dend[0](0.5)', 'syn reversal']) ax1.set_ylabel('mV') ax1.set_xticks([]) # Use ax2's tick labels ax2 = fig.add_subplot(2, 1, 2) syn_plot = ax2.plot(t_vec, syn_i_vec, color='blue') ax2.legend(syn_plot, ['synaptic current']) ax2.set_ylabel(h.units('ExpSyn.i')) ax2.set_xlabel('time (ms)') pyplot.show() #connect axons from cell n to a synapse nclist = [] syns = [] for i in range(N): src = cells[i] tgt = cells[(i + 1) % N] syn = h.ExpSyn(tgt.dend[0](0.5)) syns.append(syn) nc = h.NetCon(src.soma(0.5)._ref_v, syn, sec=src.soma) nc.weight[0] = 0.05 nc.delay = 5 nclist.append(nc)
def u(n): print(n, h.units(n))
from neuron import h def u(n): print(n, h.units(n)) u('t') u('dt') u('celsius') u('v') u('Ra') u('gnabar_hh') u('ina') u('nao') u('nai') u('ena') u('ExpSyn.g') u('ExpSyn.i') u('ExpSyn.e') h('a=1') h.units('a', 'inch') u('a')
from neuron import h h('foo = 2') h.variable_domain('foo', 1, 5) h.units('foo', 'cm') h.xpanel("test") h.xvalue("foo", "foo", 1) h.xpvalue("foo", h._ref_foo, 1) h.xpanel()