def do_sim(simulation, sim_control=None): """setup a simulation""" global na, cell # hide the simulation control panel, if there was one if sim_control: sim_control.unmap() cell = FleidervishNeuron() # add sodium diffusion everywhere allsec = rxd.Region(h.allsec(), nrn_region='i') na = rxd.Species(allsec, d=0.6, name='na', charge=1) # create a current clamp and add it to the cell cell.ic = h.IClamp(cell.soma(0.5)) cell.ic.dur = 3 # ms cell.ic.amp = 1.5 # nA # setup graphs needed by both simulations concentration_graph = h.Graph(False) concentration_graph.size(0, 3000, 4, 4.4) voltage_graph = h.Graph(False) voltage_graph.size(0, 3000, -90, 60) h.graphList[0].append(voltage_graph) h.graphList[1].append(concentration_graph) # pop up the run control h.nrncontrolmenu() # call the funciton which actually sets up the specific simulation simulation(cell, voltage_graph, concentration_graph)
def __init__(self, cell): def show_val(): print("Spacer Ra of the model: {}".format(cell.spacer.Ra)) print( 'The starting point is {}, end point is {} with increasing steps of {}' .format(min_current_var[0], max_current_var[0], step_current_var[0])) #Contorl Panel sim_control = h.HBox() sim_control.intercept(1) h.nrncontrolmenu() attach_current_clamp(cell) h.xpanel('TEST') h.xlabel('Choose a simulation to run') h.xbutton('Spike Protocol', (spike_fig, cell)) h.xbutton('Rheobase Protocol', (fig_rheobase_check, cell)) h.xbutton('Multiple Rheobase Protocol', (multiple_rheobase_plots_new, cell)) h.xbutton('Increasing Ra Protocol', (fig_ra_rheobase_spacerL, cell)) h.xbutton('Increasing spacer_gpas Protocol', (fig_g_rheobase_spacerL, cell)) h.xbutton('Increasing cell c_m Protcol', (fig_cm_rheobase_spacerL, cell)) h.xbutton('Combined Protocol Run', (Combined_Protocol, cell)) h.xpvalue('Rheobase protocol start', min_current_var, 1) h.xpvalue('Rheobase protocol end', max_current_var, 1) h.xpvalue('Rheobase step size', step_current_var, 1) h.xbutton('show value', show_val) # h.xvalue('enter value', (this_module, 'val')) h.xpanel() #Output panel g = h.Graph() g.addvar('soma(0.5).v', cell.soma(0.5)._ref_v) g.addvar('AIS(0.5).v', cell.AIS(0.5)._ref_v) g.size(0, 1000, -90, 90) h.graphList[0].append(g) h.MenuExplore() sim_control.intercept(0) sim_control.map() input()
import matplotlib as mpl mpl.use('tkagg') from neuron import h, gui from Cereb_GrC_regular import Grc_regular import multiprocessing import numpy as np import matplotlib.pyplot as plt cell = Grc_regular(1) h.nrncontrolmenu() time_step = h.CVode() time_step.active(0) #0 fixed step, 1 variable time step cpu = multiprocessing.cpu_count() h.load_file("parcom.hoc") p = h.ParallelComputeTool() if cpu > 8: p.change_nthread(8, 1) print('Maximum 8 threads') else: p.change_nthread(cpu, 1) print('N° of treads', cpu) p.multisplit(1) h('load_file("vm.ses")') stimdata = dict() stimdata['timeglobal'] = 2500
def show_menu(): global is_menu if is_menu == 0: h.nrnmainmenu() # create main menu h.nrncontrolmenu() # crate control menu is_menu = 1
# File to save: of0 # Column: RS_pop[0]/v h(' objectvar v_v_of0 ') h(' { v_v_of0 = new Vector() } ') h(' v_v_of0.record(&v(0.5)) ') h.v_v_of0.resize((h.tstop * h.steps_per_ms) + 1) # Column: RS_pop[0]/u h(' objectvar v_u_of0 ') h(' { v_u_of0 = new Vector() } ') h(' v_u_of0.record(&Izhi2007b[0].u) ') h.v_u_of0.resize((h.tstop * h.steps_per_ms) + 1) if plot: h.nrncontrolmenu() h.run() if plot: display_d1.exec_menu("View = plot") display_d2.exec_menu("View = plot") py_v_time = [ t/1000 for t in h.v_time.to_python() ] # Convert to Python list for speed... # File to save: of0 py_v_v_of0 = [ float(x / 1000.0) for x in h.v_v_of0.to_python() ] # Convert to Python list for speed, variable has dim: voltage py_v_u_of0 = [ float(x / 1.0E9) for x in h.v_u_of0.to_python() ] # Convert to Python list for speed, variable has dim: current