def create_plot_shape(rotation, view): h.load_file("../NEURON_color_maps/TColorMap.hoc") h.load_file("movierun.hoc") ps = h.PlotShape() ps.exec_menu("View = plot") ps.variable("v") cm1 = h.TColorMap("../NEURON_color_maps/jet.cm") cm1.set_color_map(ps, -90, -10) h.fast_flush_list.append(ps) ps.exec_menu("Shape Plot") ps.exec_menu("Show Diam") ps.exec_menu("Variable Scale") try: ps.rotate(rotation[0], rotation[1], rotation[2], rotation[3], rotation[4], rotation[5]) ps.view(view[0], view[1], view[2], view[3], view[4], view[5], view[6], view[7]) except: import pdb pdb.set_trace() ps.exec_menu("View Box")
def get_shape_plot(variable, min_val=-70, max_val=40): ps = h.PlotShape(True) ps.variable(variable) ps.scale(min_val, max_val) ps.show(0) h.fast_flush_list.append(ps) ps.exec_menu('Shape Plot') return ps
def make_shape_plot(variable: str = None, min_val=-70, max_val=40): """ Create a shape plot in NEURON GUI :param variable: variable name to show on the neural shape. By default (None) it will show voltage :param min_val: min value of variable specified :param max_val: max valie of the variable specified :return: HOC's plot shape object """ ps = h.PlotShape(True) if variable: ps.variable(variable) ps.scale(min_val, max_val) ps.show(0) h.fast_flush_list.append(ps) ps.exec_menu('Shape Plot') return ps
# -*- coding: utf-8 -*- """ Created on Mon Apr 25 14:12:00 2016 @author: Radu """ from neuron import h, gui from Ia_LFPy import Ia bla = Ia(n_nodes=43) shape_window = h.PlotShape()
def show_geometry(obj): sections = obj.all ps = h.PlotShape(sections) ps.exec_menu('Shape Plot')
def show(self): """ This method allows to view the Ring network. """ graph = h.PlotShape() graph.exec_menu('Show Diam')
def show_cell_geometry(): """Shows the 3D cell morphology""" h.define_shape() shape_window = h.PlotShape() shape_window.exec_menu('Show Diam')
# record v = h.Vector().record(soma(0.5)._ref_v) # Membrane potential vector t = h.Vector().record(h._ref_t) # Time stamp vector # run h.load_file('stdrun.hoc') #h.fcurrent() # Make all assigned variables (currents, conductances, etc) consistent with the values of the states. Useful in combination with finitialize(). h.finitialize(-64.97 * mV) h.continuerun(300 * ms) # plot graph import matplotlib.pyplot as plt plt.figure() plt.plot(t, v) plt.xlabel('t (ms)') plt.ylabel('v (mV)') #plt.show() # plot shape #plt.figure() h.PlotShape(False).plot(plt) #ps = h.PlotShape(True) # show plots #ps.show() plt.show() #input("Press Enter to continue...")
#h('objref cell') #h('cell = new CellSwc("./SWC/070224_SN-23-R.swc")') #h('forall insert hh') #h('forall insert k_ion') #h('forall insert na_ion') cell = h.CellSwc("./SWC/070224_SN-23-R.swc") for sec in h.allsec(): sec.insert('hh') for seg in chain(sec): seg.hh.gnabar = 0.0001 seg.hh.gkbar = 0.01 sh = h.PlotShape(1) sh.scale(0, 0) sh.size(-140, 140, -140, 140) sh.exec_menu("Shape Plot") STIM_POINT = 187 STOPTIME = 8000 TIMESTEP = 0.025 LENGTH = 0.5 AMPLITUDE = 15 FREQUENCY = 300 L_RATIO = 2.0 # ratio of length (pre+post)/pre A_RATIO = 0.3 # ratio of amplitude POLAR_T = 0.0 volt_time = h.Vector()
#topology dend.connect(soma(1)) h.psection(sec=dend) h.topology() #geometry ## soma as a square cylinder such that diam = h ## radius = 500 micron soma.L = soma.diam = 12.6157 dend.L = 200 dend.diam = 1 print("Surface area of soma = {}".format(soma(0.5).area())) #plot shape shape_window = h.PlotShape() #by default, no diam is shown shape_window.exec_menu('Show Diam') #biophysics for sec in h.allsec(): #iterate over all sections sec.Ra = 100 ## axial resistance in Ohm*cm sec.cm = 1 ## membrane capacitance in microFarad/cm2 soma.insert('hh') #insert active Hodgkin-Huxley current in the soma 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 dend.insert('pas')
conf = bionet.Config.from_json(config_file, validate=True) conf.build_env() graph = bionet.BioNetwork.from_config(conf) sim = bionet.BioSimulator.from_config(conf, network=graph) cells = graph.get_local_cells() cell = cells[list(cells.keys())[0]] psoma = cell.morphology.psoma import matplotlib.pyplot as plt ps = h.PlotShape(False) ax = ps.plot(plt) #import pdb; pdb.set_trace() for con in cell._connections: #print(con._connector.postseg()) #print(p.mark) #import pdb; pdb.set_trace() ax.mark(con._connector.postseg()) import pickle f = open('groups.pkl', 'rb') groups = pickle.load(f) f.close() from clustering import *
cell.add_sec(name="neck", diam=0.5, l=0.5, nseg=50) cell.add_sec(name="dend", diam=0.5, l=5, nseg=100) cell.connect(fr='head', to='neck') cell.connect(fr='neck', to='dend', to_loc=0.5) cell.add_rxd() # init h.finitialize(-65 * mV) #TODO how to check if mM concentration diffuse rapidly or there is a "wall" on dendrite head_last = cell.secs['head'].nseg + cell.secs['neck'].nseg + cell.secs[ 'dend'].nseg - 1 cell.ca.nodes[head_last].concentration = 0.5 h.cvode.re_init() # plot shape ps = h.PlotShape(True) ps.variable('cai') ps.scale(0, 0.01) ps.show(0) h.fast_flush_list.append(ps) ps.exec_menu('Shape Plot') #h.PlotShape(False).plot(plt) # run sleep = 3 print("sleep before run for: %s seconds", sleep) time.sleep(sleep) before = time.time() const_delay = DELAY / 1000 # in seconds for i in np.arange(0, RUNTIME, STEPSIZE): h.continuerun(i * ms)
if tar[:4] == 'dend': h.dend[int(tar[5:-1])](.5).v = 35 elif tar[:4] == 'soma': soma_col = 'cyan' elif tar[:4] == 'axon': h.axon[int(tar[5:-1])](.5).v = 35 # visualisation ========== # plots dendrites ''' sections = h.SectionList([sec for sec in h.allsec() if 'dend' in str(sec)]) ps = h.PlotShape(sections,False).plot(plt) ps._do_plot(0,1,h.dend,'v',cmap=vis_cmap) ''' ps = h.PlotShape(h.SectionList(), False).plot(plt) ps._do_plot(0, 1, h.allsec(), 'v', cmap=vis_cmap) # Make sphere to mimic soma u = np.linspace(0, 2 * np.pi, 100) v = np.linspace(0, np.pi, 100) x = 12 * np.outer(np.cos(u), np.sin(v)) y = 12 * np.outer(np.sin(u), np.sin(v)) z = 12 * np.outer(np.ones(np.size(u)), np.cos(v)) ps.plot_surface(x, y + 5, z + 10, color=soma_col) ps.plot_surface(x, y + 5, z + 14, color=soma_col) ps.plot_surface(x, y + 5, z + 17, color=soma_col) # removes plot background ps.xaxis.pane.fill = False ps.yaxis.pane.fill = False
conf = bionet.Config.from_json(config_file, validate=True) conf.build_env() graph = bionet.BioNetwork.from_config(conf) sim = bionet.BioSimulator.from_config(conf, network=graph) dic = {} dic["high"] = {"dist": [], "Ih": [], "LVAst": [], "HVA": [], "diam": []} dic["low"] = {"dist": [], "Ih": [], "LVAst": [], "HVA": [], "diam": []} #segs = list(graph.get_local_cells().values())[0]._morph.seg_prop #import pdb; pdb.set_trace() cell = list(graph.get_local_cells().values())[0] hobj = cell.hobj import matplotlib.pyplot as plt ps = h.PlotShape(False) # False tells h.PlotShape not to use NEURON's gui h.distance(sec=cell.hobj.soma[0]) diams1 = [] diams2 = [] for sec in hobj.all: fullsecname = sec.name() sec_type = fullsecname.split(".")[1][:4] sec_id = int(fullsecname.split("[")[-1].split("]")[0]) #sec.v = np.random.random(1)[0]*1 #print(sec.v) for seg in sec: #import pdb; pdb.set_trace() dist = h.distance(seg) if sec_type == "soma": #light blue seg.v = -20
#%% h.load_file(biophysicalModelFilename) h.load_file(biophysicalModelTemplateFilename) L5PC = h.L5PCtemplate(morphologyFilename) #%% set dendritic VDCC g=0 ##secs = h.allsec #for sec in h.allsec(): # if hasattr(sec, 'gCa_HVAbar_Ca_HVA'): # sec.gCa_HVAbar_Ca_HVA = 0 #%% inspect the created shape shapeWindow = h.PlotShape() shapeWindow.exec_menu('Show Diam') #%% helper functions def Add_NMDA_SingleSynapticEventToSegment(segment, activationTime, synapseWeight, exc_inh): # synapse = h.ProbAMPANMDA2(segment) # synapse = h.ProbAMPANMDA_EMS(segLoc,sec=section) if exc_inh == 0: # inhibitory synapse = h.ProbGABAAB_EMS(segment) #GABAA/B synapse.tau_r_GABAA = 0.2 synapse.tau_d_GABAA = 8 synapse.tau_r_GABAB = 3.5
print("baba") def set_plotshape_colormap(plotshape, cmap='jet'): import matplotlib.cm s = matplotlib.cm.ScalarMappable(cmap=cmap) cmap = s.get_cmap() s.set_clim(0, cmap.N) rs, gs, bs = itertools.islice(zip(*s.to_rgba(list(range(cmap.N)))), 0, 3) plotshape.colormap(cmap.N) for i, r, g, b in zip(list(range(cmap.N)), rs, gs, bs): plotshape.colormap(i, r * 255, g * 255, b * 255) # call s.scale(lo, hi) to replot the legend s = h.PlotShape() s.exec_menu('Shape Plot') set_plotshape_colormap(s) # show the diameters s.show(0) # cytoplasmic, er volume fractions fc, fe = 0.83, 0.17 # parameters caDiff = 0.016 #caDiff =0 ip3Diff = 0.283 #ip3Diff = 0
def show_architecture(self): shape_window = h.PlotShape() shape_window.exec_menu("Show Diam")