Beispiel #1
0
from neuron import h, gui
from e import e

s = h.Section()
s.insert('hh')

iname = s.hoc_internal_name()
print(iname)
exec('s2 = h.' + iname)
print('s is s2', s is s2)
print('s is h.cas()', s is h.cas())
print('s == h.cas()', s == h.cas())

h('create soma')
s4 = h.soma
print(s4.hoc_internal_name())
exec('s5 = h.' + s4.hoc_internal_name())
print('s5 is s4', s5 is s4)
print('s5 == s4', s5 == s4)
print(s5.name())
s6 = h.Section(name="s6")
s6.name()
h.topology()

h('''__nrnsec_0x { print secname() }''')
e('s7 = h.__nrnsec_0x')
h('''__nrnsec_0xaaaa { print secname() }''')
e('s7 = h.__nrnsec_0xaaaa')

del(s)
print(s2)
Beispiel #2
0
 def create_sections(self):
     """Create the sections of the cell."""
     self.soma = h.Section(name='soma', cell=self)
     self.dend = h.Section(name='dend', cell=self)
Beispiel #3
0
from neuron import h, gui

soma = h.Section()
soma.insert('hh')


def pname(msname):
    s = h.ref('')
    for i in range(-1, 4):
        ms = h.MechanismStandard(msname, i)
        print('\n', msname, '  vartype=%d' % i)  # vartype = 1 -> PARAMETER
        for j in range(int(ms.count())):
            k = ms.name(s, j)
            print('%-5d %-20s size=%d' % (j, s[0], k))


def ptype():
    msname = h.ref('')
    propList = {}
    for i, mechtype in enumerate(['mechs', 'pointps']):
        mt = h.MechanismType(
            i)  # either distributed mechs (0) or point process (1)
        propList[mechtype] = {}
        for j in range(int(mt.count())):
            mt.select(j)
            mt.selected(msname)
            print('\n\n', msname[0], ' mechanismtype=%d' % j)
            pname(msname[0])
            ms = h.MechanismStandard(msname[0], 1)  # PARAMETER (modifiable)
            propList[mechtype][msname[0]] = []
            propName = h.ref('')
Beispiel #4
0
# This example comes with NeuronVisio.

# Importing the NeuronVisio
from neuronvisio.controls import Controls

controls = Controls()
# Importing hoc interpreter
from neuron import h

# simple model

soma = h.Section(name='soma')
dend1 = h.Section(name='dend1')
dend2 = h.Section(name='dend2')

soma.diam = 10
dend1.diam = 3
dend2.diam = 3
soma.L = 50
dend1.L = 100
dend2.L = 100

dend1.connect(soma)
dend2.connect(soma)

# biophysics

for sec in h.allsec():
    sec.Ra = 100
    sec.cm = 1
Beispiel #5
0
    def __init__(self):
        neuron_utils.createProject(name='Simple Cell')

        self.soma = h.Section(name='soma')
        self.dend = h.Section(name='dend')
        self.dend.connect(self.soma(1))

        # Surface area of cylinder is 2*pi*r*h (sealed ends are implicit).
        # Makes a soma of 500 microns squared.
        self.soma.L = self.soma.diam = 12.6157
        self.dend.L = 200  # microns
        self.dend.diam = 1  # microns

        for sec in h.allsec():
            sec.Ra = 100  # Axial resistance in Ohm * cm
            sec.cm = 1  # Membrane capacitance in micro Farads / cm^2

        # Insert active Hodgkin-Huxley current in the soma
        self.soma.insert('hh')
        self.soma.gnabar_hh = 0.12  # Sodium conductance in S/cm2
        self.soma.gkbar_hh = 0.036  # Potassium conductance in S/cm2
        self.soma.gl_hh = 0.0003  # Leak conductance in S/cm2
        self.soma.el_hh = -54.3  # Reversal potential in mV

        # Insert passive current in the dendrite
        self.dend.insert('pas')
        self.dend.g_pas = 0.001  # Passive conductance in S/cm2
        self.dend.e_pas = -65  # Leak reversal potential mV
        self.dend.nseg = 10

        # add synapse (custom channel)
        self.syn = h.AlphaSynapse(self.dend(1.0))
        self.syn.e = 0  # equilibrium potential in mV
        self.syn.onset = 20  # turn on after this time in ms
        self.syn.gmax = 0.05  # set conductance in uS
        self.syn.tau = 0.1  # set time constant

        # self.stim = h.IClamp(self.dend(1.0))
        # self.stim.amp = 0.3  # input current in nA
        # self.stim.delay = 1  # turn on after this time in ms
        # self.stim.dur = 1  # duration of 1 ms

        # record soma voltage and time
        self.t_vec = h.Vector()
        self.t_vec.record(h._ref_t)
        neuron_utils.createStateVariable(id='time',
                                         name='time',
                                         units='ms',
                                         python_variable={
                                             "record_variable": self.t_vec,
                                             "segment": None
                                         })

        self.v_vec_soma = h.Vector()
        self.v_vec_soma.record(self.soma(1.0)._ref_v)  # change recoding pos

        # TODO How do we extract the units?
        neuron_utils.createStateVariable(id='v_vec_soma',
                                         name='v_vec_soma',
                                         units='mV',
                                         python_variable={
                                             "record_variable":
                                             self.v_vec_soma,
                                             "segment": self.soma(1.0)
                                         })

        self.v_vec_dend = h.Vector()
        self.v_vec_dend.record(self.dend(1.0)._ref_v)
        # TODO How do we extract the units?
        neuron_utils.createStateVariable(id='v_vec_dend',
                                         name='v_vec_dend',
                                         units='mV',
                                         python_variable={
                                             "record_variable":
                                             self.v_vec_dend,
                                             "segment": self.dend(1.0)
                                         })

        # run simulation
        h.tstop = 60  # ms
        # h.run()

        neuron_geometries_utils.extractGeometries()
Beispiel #6
0
    def testpsection(self):
        """Test neuron.psection(Section)"""

        s = h.Section(name='soma')
        neuron.psection(s)
from neuron import h, gui
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cmx
import matplotlib.animation as animation
from matplotlib.animation import FuncAnimation

dtype = np.float64

# one-compartment cell (soma)
soma = h.Section(name='soma')
soma.diam = 50  # micron
soma.L = 63.66198  # micron, so that area = 10000 micron2
soma.nseg = 1  # adimensional
soma.cm = 1  # uF/cm2
soma.Ra = 70  # ohm-cm

soma.nseg = 1
soma.insert('na15')  # insert mechanism
soma.ena = 65
h.celsius = 24  # temperature in celsius
v_init = -120  # holding potential
h.dt = 0.01  # ms - value of the fundamental integration time step, dt, used by fadvance().

# clamping parameters
dur = 500  # clamp duration, ms
step = 3  # voltage clamp increment
st_cl = -120  # clamp start, mV
end_cl = 1  # clamp end, mV
v_cl = -120  # actual voltage clamp, mV
Beispiel #8
0
    def psection(cls):
        """Test neuron.psection(Section)"""

        s = h.Section(name='soma')
        neuron.psection(s)
Beispiel #9
0
    """
		This definition will construct a vector to record all the data taken in the simulation.  The potential across each soma will be recorded for each time step.
	"""
    vec = {}
    #Record appropriate number of potentials.
    for var in range(0, numNeurons):
        vec[str(var + 1)] = h.Vector()
        vec[str(var + 1)].record(Soma[var](0.5)._ref_v)
    #Record time.
    vec['t '] = h.Vector()
    vec['t '].record(h._ref_t)
    return vec


# Construct initial sections of neurons 1-4.
Soma1 = h.Section()
Soma2 = h.Section()
Soma3 = h.Section()
Soma4 = h.Section()
AD1 = h.Section()
AD2 = h.Section()
AD3 = h.Section()
AD4 = h.Section()
BD1 = h.Section()
BD2 = h.Section()
BD3 = h.Section()
BD4 = h.Section()
Axon1 = h.Section()
Axon2 = h.Section()
Axon3 = h.Section()
Axon4 = h.Section()
from neuron import h
from pylab import *
import timeit

start = timeit.default_timer()

cell = h.Section()
cell.insert('hha2')

stimulus = h.IClamp(0.5)
stimulus.delay = 100
stimulus.dur = 800
stimulus.amp = 7

trec = h.Vector()
vrec = h.Vector()

trec.record(h._ref_t)
vrec.record(cell(0.5)._ref_v)

stimuli_rec = h.Vector()
stimuli_rec.record(stimulus._ref_i)

h.load_file("stdrun.hoc")
h.init()
h.v_init = -65
h.tstop = 1000

before_run = timeit.default_timer()
print('initial time:%f' % (before_run - start))
Beispiel #11
0
 def testSectionArgOrder(self):
     """ First optional arg for Section is name (but name="name" is recommended)"""
     soma = h.Section('soma')
     assert soma.name() == 'soma'
Beispiel #12
0
Equation for synaptic inputs taken from
  Izhikevich EM, Edelman GM (2008). "Large-scale model of mammalian thalamocortical systems." PNAS 105(9) 3593-3598.

Cell types available are based on Izhikevich, 2007 book:
    1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007 book)
    2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007 book)
    3. CH - Cat primary visual cortex chattering cell (fig8.23 from 2007 book)
    4. LTS - Rat barrel cortex Low-threshold  spiking interneuron (fig8.25 from 2007 book)
    5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig8.27 from 2007 book)
    6. TC - Cat dorsal LGN thalamocortical (TC) cell (fig8.31 from 2007 book)
    7. RTN - Rat reticular thalamic nucleus (RTN) cell  (fig8.32 from 2007 book)
"""

import collections
from neuron import h
dummy = h.Section()
type2007 = collections.OrderedDict([
  #              C    k     vr  vt vpeak   a      b   c    d  celltype
  ('RS',        (1.0, 0.7,  -60, -40, 35, 0.03,   -2, -50,  100,  1)),
  ('IB',        (1.5, 1.2,  -75, -45, 50, 0.01,   5, -56,  130,   2)),
  ('CH',        (0.5,  1.5,  -60, -40, 25, 0.03,   1, -40,  150,   3)),
  ('LTS',       (1.0, 1.0,  -56, -42, 40, 0.03,   8, -53,   20,   4)),
  ('FS',        (0.2,  1.0,  -55, -40, 25, 0.2,   -2, -45,  -55,   5)),
  ('TC',        (2.0, 1.6,  -60, -50, 35, 0.01,  15, -60,   10,   6)),
  ('TC_burst',  (2.0, 1.6,  -60, -50, 35, 0.01,  15, -60,   10,   6)),
  ('RTN',       (0.4,  0.25, -65, -45,  0, 0.015, 10, -55,   50,   7)),
  ('RTN_burst', (0.4,  0.25, -65, -45,  0, 0.015, 10, -55,   50,   7))])

# class of basic Izhikevich neuron based on parameters in type2007
class IzhiCell (): 
  '''Create an izhikevich cell based on 2007 parameterization using either izhi2007.mod (no hosting section) or izhi2007b.mod (v in created section)
Beispiel #13
0
def run_cell(diam,cm,el,gl,gna,gh,gk,tstop,dur,amp,mhalf,hhalf,mk,hk,nhalf,kn,multiply,multiply1,multiply2,seg1,seg2,seg3):
    #Load the mechanisms in the current directory
    neuron.load_mechanisms(os.path.dirname(os.path.abspath(__file__)))

    Passive = [1,-1,-65]
    soma = h.Section(name='soma')
    soma.L = 100 # um
    soma.insert('hh')
    
    v0_vec = h.Vector()
    t_vec = h.Vector()
    
    v0_vec.record(soma(0.5)._ref_v)
    t_vec.record(h._ref_t)
    
    soma.insert('na1')
    soma.insert('k1')
    soma.insert('hd')

    m_na = h.Vector()
    h_hd = h.Vector()
    n_k = h.Vector()
    tau_m = h.Vector()
    tau_h = h.Vector()
    tau_n = h.Vector()
    
    m_na.record(soma(0.5)._ref_minf_na1)
    h_hd.record(soma(0.5)._ref_linf_hd)
    n_k.record(soma(0.5)._ref_ninf_k1)
    tau_m.record(soma(0.5)._ref_mtau_na1)
    tau_h.record(soma(0.5)._ref_taul_hd)
    tau_n.record(soma(0.5)._ref_taun_k1)

    soma.diam = diam
    soma.cm = cm*1.4884e-4/6.2832e-4
    soma.gbar_na1 = gna*1e-3
    soma.gbar_k1 = gk*1e-3
    soma.gl_hh = gl*1e-6
    soma.ghdbar_hd = gh*1e-4
    soma.el_hh = el
    soma.mhalf_na1 = mhalf
    soma.vhalfl_hd = hhalf
    soma.mk_na1 = mk
    soma.kl_hd = hk
    soma.vhalfn_k1 = nhalf
    soma.kn_k1 = kn
    soma.multiply1_na1 = multiply1
    soma.multiply2_na1 = multiply2
    soma.multiply_k1 = multiply
    soma.seg_value1_k1 = seg1
    soma.seg_value2_na1 = seg2
    soma.seg_value3_hd = seg3
        
    Source = h.IClamp(soma(0.5))
    Source.delay = dur[0]
    Source.dur = dur[1]-dur[0]
    Source.amp = amp
    
    h.tstop = tstop
    h.v_init = el
    
    nc = h.NetCon(soma(0.5)._ref_v,None,sec=soma)
    nc.threshold = 0
    spvec = h.Vector()
    nc.record(spvec)
    if Source.amp < 0:
        h.run()
        print('number of spikes:',len(spvec))
        
        R_in_1 = 1/(soma.gl_hh*1000)
        tau_1 = soma.cm*R_in_1
        V_rest_1 = v0_vec[int(tstop)-20]
        
        R_in_2 = Passive[1]
        tau_2 = Passive[0]
        V_rest_2 = Passive[2]
    
        df1 = pd.DataFrame([[tau_1],[V_rest_1],[R_in_1],[tau_2],[V_rest_2],[R_in_2]],
        columns=['value  '],
        index = ['tau_seg  ', 'Vrest_seg  ', 'Rin_seg  ','tau_ori  ', 'Vrest_ori  ', 'Rin_ori  '])
        print (df1)
        plt.figure(figsize=(10,6))
        plt.plot(t_vec, v0_vec,'b')
        plt.xlim(0, tstop)
        plt.ylabel('mV')
    
    frequency =["all"]
    amplitude =["all"]  
    # FIR Curve

    freq1 = []
    I1 = []
    freq2 = []
    I2 = []
    if (Source.amp > 0):
        for Source.amp in np.arange(amp,amp+1,0.1):
            h.run()
            freq1.append(len(spvec)*1000/Source.dur)
            I1.append(Source.amp)
        plt.figure(figsize=(16,14))
        plt.subplot(4,1,1)
        plt.plot(t_vec, v0_vec,'b')
        plt.xlim(0, tstop)
        plt.ylabel('mV')
        plt.subplot(4,1,2)
        plt.plot(amplitude,frequency,'bo')
        plt.plot(I1,freq1,'yo')
        #plt.legend([soma.flag_k1,1-soma.flag_k1])
        plt.xlabel('Injected current (nA)')
        plt.ylabel('frequency') 
        plt.subplot(4,1,3)
        plt.plot(v0_vec, m_na,'r.')
        plt.plot(v0_vec, h_hd,'b.')
        plt.plot(v0_vec, n_k, 'g.')
        #plt.xlim(0, tstop)
        plt.xlabel('voltage (mV)')
        plt.ylabel('Probability')
        plt.legend(['minf','hinf','ninf'])
        plt.subplot(4,1,4)
        plt.plot(v0_vec, tau_m,'r.')
        plt.plot(v0_vec, tau_h,'b.')
        plt.plot(v0_vec, tau_n, 'g.')
        plt.xlabel('voltage (mV)')
        plt.ylabel('tau')
        plt.legend(['minf','hinf','ninf'])
    image = BytesIO()
    #plt.show()
    plt.savefig(image, format='png')
    ret = base64.b64encode(image.getvalue())
    return str(ret)
    def graph(self):
        #Function:  graph
        #Input:     self
        #Process:   create dendrite branch network
        #Output:    neuron

        self.dendsegs = numpy.array([self.coordinates[:,0], self.coordinates[:,2], self.coordinates[:,3],self.coordinates[:,4],self.coordinates[:,5],self.coordinates[:,6]])

        self.seglist = numpy.array(self.coordinates[:,0]-1,dtype=int)
        self.segmap = numpy.array(self.coordinates[:,6]-1,dtype=int)

        if self.seglist[0] == 1:
            self.seglist = numpy.array(self.seglist-1,dtype=int)
            self.segmap = numpy.array(self.segmap-1,dtype=int)

        #-----------------------------------------------------------------------------------------------------------------------------------------------

        self.compartmentdict = {}
        segvals = []
        Gcompartment = []

        #-----------------------------------------------------------------------------------------------------------------------------------------------

        for c in range(len(self.seglist)):

            #-----------------------------------------------------------------------------------------------------------------------------------------------

            if self.segmap[c] < self.seglist[c] - 1:

                if len(segvals) == 0:
                    continue

                i = c

                self.compartmentdict[i] = [Gcompartment,h.Section(name='compartment',cell=self),segvals]

                Gcompartment = []
                segvals = []

            #-----------------------------------------------------------------------------------------------------------------------------------------------

            if c == len(self.seglist) - 1:

                if len(segvals) == 0:
                    break

                i = c

                self.compartmentdict[i] = [Gcompartment,h.Section(name='compartment',cell=self),segvals]

                Gcompartment = []
                segvals = []

            #-----------------------------------------------------------------------------------------------------------------------------------------------

            else:

                segvals.append([self.dendsegs[1,c]*1/125.0,self.dendsegs[2,c]*1/125.0,self.dendsegs[3,c]*1/125.0,self.dendsegs[4,c]*1/125.0])
                Gcompartment.append(self.seglist[c])

        #-----------------------------------------------------------------------------------------------------------------------------------------------

        for key in self.compartmentdict.keys():

            if len(self.compartmentdict[key][2]) > 0:

                s = self.compartmentdict[key][2][0]
                e = self.compartmentdict[key][2][-1]

                if distance.euclidean(s[0:2],e[0:2]) == 0:

                    h.pt3dadd(s[0],s[1],s[2],s[3],sec=self.compartmentdict[key][1])
                    h.pt3dadd(e[0] + 1e-5,e[1] + 1e-5,e[2] + 1e-5,e[3],sec=self.compartmentdict[key][1])

                else:

                    h.pt3dadd(s[0],s[1],s[2],s[3],sec=self.compartmentdict[key][1])
                    h.pt3dadd(e[0],e[1],e[2],e[3],sec=self.compartmentdict[key][1])

        #-----------------------------------------------------------------------------------------------------------------------------------------------

        for key in self.compartmentdict.keys():

            for part in self.compartmentdict.keys():

                if key in self.compartmentdict[part][0]:

                    self.compartmentdict[key][1].connect(self.compartmentdict[part][1])

        #-----------------------------------------------------------------------------------------------------------------------------------------------

        for dendID in self.compartmentdict.keys():

            n3dID = int(h.n3d(sec=self.compartmentdict[dendID][1]))

            for n in range(n3dID):

                self.dendgraph[dendID]  = numpy.array([float(h.x3d(n,sec=self.compartmentdict[dendID][1])),float(h.y3d(n,sec=self.compartmentdict[dendID][1])),float(h.z3d(n,sec=self.compartmentdict[dendID][1]))])
Beispiel #15
0
 def create_sections(self):
     '''
     Creates sections (compartments)
     '''
     self.branch = h.Section(name='branch', cell=self)
     self.stimsec = [h.Section(name='stimsec[%d]' % i) for i in range(self.num)]
Beispiel #16
0
            elif method in (8, 9):
                args = (_pc_dt(tid), _pc_t(tid), pd1_array, pd2_array)
            for c in call:
                if c[method] is not None:
                    c[method](*args)
    except:
        traceback.print_exc()
        rval = -1
    return rval


_callback = nonvint_block_prototype(nonvint_block)
set_nonvint_block(_callback)

if __name__ == '__main__':
    exec(test)  # see above string

    s = h.Section()
    print("fixed step finitialize")
    h.finitialize(0)
    print("fixed step fadvance")
    h.fadvance()

    h.load_file('stdgui.hoc')
    print("cvode active")
    h.cvode_active(1)
    print("cvode step finitialize")
    h.finitialize(0)
    print("cvode fadvance")
    h.fadvance()
Beispiel #17
0
mtau = 1.0 / (q10 * (alpha + beta))
minf = alpha / (alpha + beta)

# sodium inactivation 'h'
alpha = 0.07 * exp(-(v + 65.0) / 20.0)
beta = 1.0 / (exp(-(v + 35.0) / 10.0) + 1.0)
htau = 1.0 / (q10 * (alpha + beta))
hinf = alpha / (alpha + beta)

# potassium activation 'n'
alpha = 0.01 * vtrap(-(v + 55.0), 10.0)
beta = 0.125 * exp(-(v + 65.0) / 80.0)
ntau = 1.0 / (q10 * (alpha + beta))
ninf = alpha / (alpha + beta)

somaA = h.Section('somaA')
somaA.pt3dclear()
somaA.pt3dadd(-90, 0, 0, 30)
somaA.pt3dadd(-60, 0, 0, 30)
somaA.nseg = 1

somaB = h.Section('somaB')
somaB.pt3dclear()
somaB.pt3dadd(60, 0, 0, 30)
somaB.pt3dadd(90, 0, 0, 30)
somaB.nseg = 1

# mod version
somaB.insert('hh')

# rxd version
from neuron import h, gui
import numpy

# a - red
# b - blue
# c - green
# d - yellow
# e - black

# b(0)->a(1): blue->red
# c(1)->b(1): green->blue
# d(0)->b(1): yellow->blue
# e(0)->a(0): black->red

a, b, c, d, e = [h.Section(name=n) for n in ['a', 'b', 'c', 'd', 'e']]
b.connect(a)
c.connect(b(1), 1)  # connect the 1 end of c to the 1 end of b
d.connect(b)
e.connect(a(0))  # connect the 0 end of e to the 0 end of a
for sec in h.allsec():
    sec.nseg = 20
    sec.L = 100
    for seg in sec:
        seg.diam = numpy.interp(seg.x, [0, 1], [10, 40])

s = h.Shape()
s.show(False)

s.color(2, sec=a)  # a - red
s.color(3, sec=b)  # b - blue
s.color(4, sec=c)  # c - green
Beispiel #19
0
from neuron import h, gui

h.load_file("nrngui.hoc")
#h.nao0_na_ion = 110
#h.cao0_ca_ion = 1.8

soma = h.Section(name="soma")
soma.Ra = 200
soma.L = 40
soma.diam = 50
soma.nseg = 2
soma.insert("pcell")
soma.insert("na")
soma.insert("napump")
soma.insert("gkca")
soma.insert("ca")
soma.insert("cach")
soma.insert("capump")

junction = h.Section(name="soma")
junction.Ra = 200
junction.L = 40
junction.diam = 10
junction.nseg = 2
junction.insert("pcell")
junction.insert("na")
junction.insert("napump")
junction.insert("gkca")
junction.insert("ca")
junction.insert("cach")
junction.insert("capump")
Beispiel #20
0
mtau = 1.0 / (q10 * (alpha + beta))
minf = alpha / (alpha + beta)

# sodium inactivation 'h'
alpha = 0.07 * exp(-(v + 65.0) / 20.0)
beta = 1.0 / (exp(-(v + 35.0) / 10.0) + 1.0)
htau = 1.0 / (q10 * (alpha + beta))
hinf = alpha / (alpha + beta)

# potassium activation 'n'
alpha = 0.01 * vtrap(-(v + 55.0), 10.0)
beta = 0.125 * exp(-(v + 65.0) / 80.0)
ntau = 1.0 / (q10 * (alpha + beta))
ninf = alpha / (alpha + beta)

somaA = h.Section("somaA")
somaA.pt3dclear()
somaA.pt3dadd(-90, 0, 0, 30)
somaA.pt3dadd(-60, 0, 0, 30)
somaA.nseg = 1

somaB = h.Section("somaB")
somaB.pt3dclear()
somaB.pt3dadd(60, 0, 0, 30)
somaB.pt3dadd(90, 0, 0, 30)
somaB.nseg = 1

# mod version
somaB.insert("hh")

# rxd version
Beispiel #21
0
def test_is_point_process():
    section = h.Section()
    clamp = h.SEClamp(section(0.5))
    assert simulator.is_point_process(clamp)
    section.insert('hh')
    assert not simulator.is_point_process(section(0.5).hh)
def load(filename,
         fileformat=None,
         cell=None,
         use_axon=True,
         xshift=0,
         yshift=0,
         zshift=0):
    """
    Load an SWC from filename and instantiate inside cell. Code kindly provided
    by @ramcdougal.

    Args:
        filename = .swc file containing morphology
        cell = Cell() object. (Default: None, creates new object)
        filename = the filename of the SWC file
        use_axon = include the axon? Default: True (yes)
        xshift, yshift, zshift = use to position the cell

    Returns:
        Cell() object with populated soma, axon, dend, & apic fields

    Minimal example:
        # pull the morphology for the demo from NeuroMorpho.Org
        from PyNeuronToolbox import neuromorphoorg, load
        with open('c91662.swc', 'w') as f:
            f.write(neuromorphoorg.morphology('c91662'))
        cell = load(filename)

    """

    if cell is None:
        cell = Cell(name=string.join(filename.split('.')[:-1]))

    if fileformat is None:
        fileformat = filename.split('.')[-1]

    name_form = {1: 'soma[%d]', 2: 'axon[%d]', 3: 'dend[%d]', 4: 'apic[%d]'}

    # load the data. Use Import3d_SWC_read for swc, Import3d_Neurolucida3 for
    # Neurolucida V3, Import3d_MorphML for MorphML (level 1 of NeuroML), or
    # Import3d_Eutectic_read for Eutectic.
    if fileformat == 'swc':
        morph = h.Import3d_SWC_read()
    elif fileformat == 'asc':
        morph = h.Import3d_Neurolucida3()
    else:
        raise Exception('file format `%s` not recognized' % (fileformat))
    morph.input(filename)

    # easiest to instantiate by passing the loaded morphology to the Import3d_GUI
    # tool; with a second argument of 0, it won't display the GUI, but it will allow
    # use of the GUI's features
    i3d = h.Import3d_GUI(morph, 0)

    # get a list of the swc section objects
    swc_secs = i3d.swc.sections
    swc_secs = [swc_secs.object(i) for i in xrange(int(swc_secs.count()))]

    # initialize the lists of sections
    sec_list = {1: cell.soma, 2: cell.axon, 3: cell.dend, 4: cell.apic}

    # name and create the sections
    real_secs = {}
    for swc_sec in swc_secs:
        cell_part = int(swc_sec.type)

        # skip everything else if it's an axon and we're not supposed to
        # use it... or if is_subsidiary
        if (not (use_axon) and cell_part == 2) or swc_sec.is_subsidiary:
            continue

        # figure out the name of the new section
        if cell_part not in name_form:
            raise Exception('unsupported point type')
        name = name_form[cell_part] % len(sec_list[cell_part])

        # create the section
        sec = h.Section(name=name)

        # connect to parent, if any
        if swc_sec.parentsec is not None:
            sec.connect(real_secs[swc_sec.parentsec.hname()](swc_sec.parentx))

        # define shape
        if swc_sec.first == 1:
            h.pt3dstyle(1,
                        swc_sec.raw.getval(0, 0),
                        swc_sec.raw.getval(1, 0),
                        swc_sec.raw.getval(2, 0),
                        sec=sec)

        j = swc_sec.first
        xx, yy, zz = [swc_sec.raw.getrow(i).c(j) for i in xrange(3)]
        dd = swc_sec.d.c(j)
        if swc_sec.iscontour_:
            # never happens in SWC files, but can happen in other formats supported
            # by NEURON's Import3D GUI
            raise Exception('Unsupported section style: contour')

        if dd.size() == 1:
            # single point soma; treat as sphere
            x, y, z, d = [dim.x[0] for dim in [xx, yy, zz, dd]]
            for xprime in [x - d / 2., x, x + d / 2.]:
                h.pt3dadd(xprime + xshift, y + yshift, z + zshift, d, sec=sec)
        else:
            for x, y, z, d in zip(xx, yy, zz, dd):
                h.pt3dadd(x + xshift, y + yshift, z + zshift, d, sec=sec)

        # store the section in the appropriate list in the cell and lookup table
        sec_list[cell_part].append(sec)
        real_secs[swc_sec.hname()] = sec

    cell.all = cell.soma + cell.apic + cell.dend + cell.axon
    return cell
Beispiel #23
0
import sys
import time
import itertools

npar = len(sys.argv)
#if(npar<2):
#    print "usage: python wave1d.py <nseg> <nsubseg>"
#    sys.exit(0)

#rxd.options.nsubseg =int(sys.argv[2])
rxd.options.subseg_interpolation = 0
rxd.options.subseg_averaging = 0



sec = h.Section()
L  = 100
#sec.diam = 1
sec.nseg = 125
#h.pt3dadd(0, 0, 0, 1)
#h.pt3dadd(L, 0, 0, 10)
sec.Ra = 150
Rm =  25370
dend= sec
for myseg in dend: myseg.v = -64  
for myseg in dend: myseg.cm = 1.41
dend.insert('pas')
for myseg in dend: myseg.pas.g = 1.0/Rm
for myseg in dend: myseg.pas.e = -64
dend.insert('cal') # insert L-type Ca channel
for myseg in dend: myseg.cal.gcalbar = 1.e-6
Beispiel #24
0
    def create_synapses(self, syn_set):

        set_name = syn_set['name']
        syn_entries = syn_set['entries']

        synapses = self.synapse_sets[set_name] = []

        for entry in syn_entries:

            rank_source_section = self.rank_section_name(
                entry['source_section'])
            rank_dest_section = self.rank_section_name(entry['dest_section'])

            source_on_rank = rank_source_section is not None
            dest_on_rank = rank_dest_section is not None

            if dest_on_rank:
                dest_sec = self.section_index[rank_dest_section]
                dest_x = self.clamp_section_x(entry['dest_x'])
            else:
                dest_sec = None
                dest_x = 0

            if source_on_rank:
                source_sec = self.section_index[rank_source_section]
                source_x = self.clamp_section_x(entry['source_x'])
            else:
                source_sec = None
                source_x = 0

            # At first, assume no spines
            neck = None
            head = None

            # Unless indicated otherwise
            if source_on_rank and entry['create_spine']:
                prefix = set_name + "_" + entry['prefix'] + "[" + str(
                    len(synapses)) + "]"

                # Create the spine head
                head = h.Section(name=prefix + ".head")

                # basic passive params
                head.insert('pas')

                # Add the 3D coords
                self.add_spine_pt3d(head, entry['head_start'],
                                    entry['head_diameter'])
                self.add_spine_pt3d(head, entry['head_end'],
                                    entry['head_diameter'])

                # Create the head (if there is enough room)
                if entry['neck_start'] is not None:
                    neck = h.Section(name=prefix + ".neck")
                    neck.insert('pas')

                    self.add_spine_pt3d(neck, entry['neck_start'],
                                        entry['neck_diameter'])
                    self.add_spine_pt3d(neck, entry['neck_end'],
                                        entry['neck_diameter'])

                    # Connect the spine together to the source section
                    neck.connect(source_sec(source_x), 0)
                    head.connect(neck)

                else:
                    # If there is no neck, connect the head to section directly
                    head.connect(source_sec(source_x), 0)

                # Point process should now be placed on the spine head
                source_sec = head
                source_x = 0.5

            source_gid = self.segment_gid(entry['source_section'],
                                          entry['source_seg_i'],
                                          entry['create_spine'])

            netcon, syn = self.create_netcon_syn(
                entry['dest_syn'], dest_sec, dest_x, entry['dest_syn_params'],
                source_sec, source_x, entry['threshold'], entry['delay'],
                entry['weight'], source_on_rank, dest_on_rank, source_gid)

            # If reciprocal, create a NetCon+Syn going in the opposite direction
            if entry['is_reciprocal']:

                dest_gid = self.segment_gid(entry['dest_section'],
                                            entry['dest_seg_i'], False)

                netcon_recip, syn_recip = self.create_netcon_syn(
                    entry['source_syn'], source_sec, source_x,
                    entry['source_syn_params'], dest_sec, dest_x,
                    entry['threshold'], entry['delay'], entry['weight'],
                    dest_on_rank, source_on_rank, dest_gid)
            else:
                netcon_recip, syn_recip = None, None

            # Keep references to the synapse parts
            synapses.append((netcon, syn, neck, head, netcon_recip, syn_recip))
Beispiel #25
0
'''
PyNeuron tutorial. 
Create basic conductance-based model
Set up recording of parameters to save and plot the data
'''
import pickle  # for saving/reading data

import neuron
from neuron import h  # hoc interpreter

import numpy as np
from pylab import *  # for drawing

#h.celsius = 37 # set the temperature

cell = h.Section()  # create a section (cable)
cell.insert('hh')  # insert a Hodgkin-Huxley channel

vrec = h.Vector()  # setup recording Vectors
trec = h.Vector()
vrec.record(
    cell(0.5)._ref_v)  # record voltage from middle (0.5) of the Section
trec.record(h._ref_t)  # record time variable

h.finitialize(-60)  # voltage at initialization, in mV
h.dt = 0.025  # 0.025 millisecond timestep
neuron.run(1000)  # run simulation for 1000 milliseconds

plot(np.array(trec), np.array(vrec))  # plot the output using matplotlib
xlim((0, h.tstop))
xlabel('Time (ms)')
Beispiel #26
0
from neuron import *
from nrn import *
from itertools import chain
from neuron import h
Section = h.Section
from numpy import *
from pylab import *

#Let's first try making two neurons...

soma = h.Section()
h.pt3dadd(0, 0, 0, 3, sec=soma)
h.pt3dadd(0, 0, 1, 3, sec=soma)
dend1 = h.Section()
h.pt3dadd(0, 0, 5, 3, sec=dend1)
h.pt3dadd(5, 0, 5, 2, sec=dend1)
h.pt3dadd(15, 15, 15, 10, sec=dend1)
dend2 = h.Section()
h.pt3dadd(0, 0, -5, 3, sec=dend2)
h.pt3dadd(-5, 0, -5, 4, sec=dend2)
h.pt3dadd(-15, -15, -15, 50, sec=dend2)
dend1.connect(soma, 0, 0)
dend2.connect(soma, 1, 0)

soma1 = h.Section()
h.pt3dadd(10, 10, 10, 3, sec=soma1)
h.pt3dadd(10, 10, 11, 3, sec=soma1)
dend3 = h.Section()
h.pt3dadd(10, 10, 15, 3, sec=dend3)
h.pt3dadd(15, 10, 15, 2, sec=dend3)
h.pt3dadd(5, 5, 5, 1, sec=dend3)
Beispiel #27
0
from neuron import h, crxd as rxd
import numpy
import __main__

name = __main__.__file__
if name[-3:] == ".py":
    name = name[:-3]
h.load_file("stdrun.hoc")

dend1 = h.Section()
dend1.diam = 2
dend1.nseg = 101
dend1.L = 50

dend2 = h.Section()
dend2.diam = 2
dend2.nseg = 101
dend2.L = 50
dend2.connect(dend1)

diff_constant = 1
h.cvode_active(True)
r = rxd.Region(h.allsec(), dx=0.25)

rxd.set_solve_type([dend1], dimension=3)

ca = rxd.Species(
    r,
    d=diff_constant,
    atolscale=0.1,
    initial=lambda node: 1 if (0.8 < node.x and node.segment in dend1) or
Beispiel #28
0
    def create_cell(self):
        """
        3D morphology of CA229simp cell.
        The diam and L of each compartment is determined by 3D structure.
        Same as hoc 3D morphology: CA229.hoc
        """
        self.soma = [h.Section(name='soma[%d]' % i) for i in xrange(4)]
        self.apical = [h.Section(name='apical[0]')]
        self.basal = [h.Section(name='basal[%d]' % i) for i in xrange(10)]
        self.axon = [h.Section(name='axon[0]')]

        self.axon[0].L = 200.0
        self.axon[0].diam = 1.03
        self.axon[0].nseg = 1
        self.axon[0].connect(self.soma[2])

        self.apical[0].L = 454.5
        self.apical[0].diam = 6.00
        self.apical[0].nseg = 1
        self.apical[0].connect(self.soma[3])

        self.basal[9].L = 157.2
        self.basal[9].diam = 6.00
        self.basal[9].nseg = 1
        self.basal[9].connect(self.soma[1])

        self.basal[8].nseg = 3

        # Set up the 3d morphology and connection of soma
        h.pt3dclear(sec=self.soma[0])
        h.pt3dstyle(1, -53.42, 3.52, -5.95, 13.43, sec=self.soma[0])
        h.pt3dadd(-53.42, 3.52, -5.96, 13.43, sec=self.soma[0])

        self.soma[1].connect(self.soma[0])
        h.pt3dclear(sec=self.soma[1])
        h.pt3dadd(-53.42, 3.52, -5.96, 13.43, sec=self.soma[1])
        h.pt3dadd(-53.74, 0.93, -5.96, 15.35, sec=self.soma[1])
        h.pt3dadd(-54.06, -1.66, -5.96, 11.51, sec=self.soma[1])

        self.soma[3].connect(self.soma[0])
        h.pt3dclear(sec=self.soma[3])
        h.pt3dadd(-53.42, 3.52, -5.96, 13.43, sec=self.soma[3])
        h.pt3dadd(-53.1, 6.12, -5.96, 11.19, sec=self.soma[3])
        h.pt3dadd(-52.78, 8.71, -5.96, 9.59, sec=self.soma[3])
        h.pt3dadd(-52.78, 11.62, -5.96, 7.36, sec=self.soma[3])
        h.pt3dadd(-53.1, 14.22, -5.96, 5.76, sec=self.soma[3])

        self.soma[2].connect(self.soma[1])
        h.pt3dclear(sec=self.soma[2])
        h.pt3dadd(-54.06, -1.66, -5.96, 11.51, sec=self.soma[2])
        h.pt3dadd(-54.06, -4.25, -5.96, 7.99, sec=self.soma[2])

        # Set up the 3d morphology and connection of basal dendrites

        self.basal[0].connect(self.soma[0])
        h.pt3dclear(sec=self.basal[0])
        h.pt3dadd(-53.42, 3.52, -5.96, 2.5, sec=self.basal[0])
        h.pt3dadd(-60.3, 3.99, 0.28, 1.28, sec=self.basal[0])
        h.pt3dadd(-64.028, 3.787, 1.455, 1.28, sec=self.basal[0])
        h.pt3dadd(-68.616, 2.577, 1.405, 1.28, sec=self.basal[0])
        h.pt3dadd(-72.55, 1.133, 1.864, 1.28, sec=self.basal[0])
        h.pt3dadd(-77.03, 0.483, 3.784, 1.28, sec=self.basal[0])

        self.basal[1].connect(self.basal[0])
        h.pt3dclear(sec=self.basal[1])
        h.pt3dadd(-77.03, 0.483, 3.784, 1.28, sec=self.basal[1])
        h.pt3dadd(-80.68, 2.633, 0.564, 0.96, sec=self.basal[1])
        h.pt3dadd(-84.2, 3.613, -0.576, 0.96, sec=self.basal[1])
        h.pt3dadd(-88.771, 4.452, -1.634, 0.96, sec=self.basal[1])
        h.pt3dadd(-93.902, 6.048, -2.616, 0.96, sec=self.basal[1])
        h.pt3dadd(-96.462, 6.688, -4.516, 0.96, sec=self.basal[1])
        h.pt3dadd(-100.622, 5.718, -5.996, 0.96, sec=self.basal[1])
        h.pt3dadd(-102.852, 5.718, -7.876, 0.96, sec=self.basal[1])

        self.basal[2].connect(self.basal[1])
        h.pt3dclear(sec=self.basal[2])
        h.pt3dadd(-102.852, 5.718, -7.876, 0.96, sec=self.basal[2])
        h.pt3dadd(-102.852, 3.128, -17.756, 0.64, sec=self.basal[2])
        h.pt3dadd(-101.262, 2.478, -21.296, 0.64, sec=self.basal[2])
        h.pt3dadd(-100.622, -1.082, -24.456, 0.64, sec=self.basal[2])
        h.pt3dadd(-101.892, -1.732, -27.696, 0.64, sec=self.basal[2])
        h.pt3dadd(-103.172, -2.702, -35.536, 0.64, sec=self.basal[2])
        h.pt3dadd(-105.092, -3.032, -41.596, 0.64, sec=self.basal[2])
        h.pt3dadd(-105.412, -2.052, -46.196, 0.64, sec=self.basal[2])
        h.pt3dadd(-107.012, -1.412, -47.816, 0.64, sec=self.basal[2])
        h.pt3dadd(-108.932, -1.412, -50.276, 0.64, sec=self.basal[2])
        h.pt3dadd(-110.212, 0.538, -52.336, 0.496, sec=self.basal[2])
        h.pt3dadd(-110.212, 1.508, -56.156, 0.476, sec=self.basal[2])

        self.basal[3].connect(self.basal[1])
        h.pt3dclear(sec=self.basal[3])
        h.pt3dadd(-102.852, 5.718, -7.876, 0.96, sec=self.basal[3])
        h.pt3dadd(-104.452, 5.398, -7.876, 0.96, sec=self.basal[3])
        h.pt3dadd(-108.932, 5.718, -9.356, 0.804, sec=self.basal[3])

        self.basal[4].connect(self.basal[3])
        h.pt3dclear(sec=self.basal[4])
        h.pt3dadd(-108.932, 5.718, -9.356, 0.804, sec=self.basal[4])
        h.pt3dadd(-113.092, 4.428, -12.676, 0.64, sec=self.basal[4])
        h.pt3dadd(-115.332, 3.128, -12.676, 0.782, sec=self.basal[4])
        h.pt3dadd(-118.842, 3.128, -14.996, 0.738, sec=self.basal[4])
        h.pt3dadd(-121.402, 2.158, -17.416, 0.73, sec=self.basal[4])
        h.pt3dadd(-124.282, 1.188, -17.416, 0.64, sec=self.basal[4])

        self.basal[5].connect(self.basal[4])
        h.pt3dclear(sec=self.basal[5])
        h.pt3dadd(-124.282, 1.188, -17.416, 0.64, sec=self.basal[5])
        h.pt3dadd(-127.162, 0.858, -20.256, 0.64, sec=self.basal[5])
        h.pt3dadd(-129.082, 0.858, -20.256, 0.64, sec=self.basal[5])
        h.pt3dadd(-131.632, -1.732, -22.016, 0.64, sec=self.basal[5])
        h.pt3dadd(-134.192, -3.352, -24.736, 0.64, sec=self.basal[5])
        h.pt3dadd(-138.352, -4.322, -29.736, 0.64, sec=self.basal[5])
        h.pt3dadd(-140.592, -5.622, -32.256, 0.64, sec=self.basal[5])
        h.pt3dadd(-143.472, -6.912, -32.256, 0.64, sec=self.basal[5])
        h.pt3dadd(-146.342, -6.912, -35.356, 0.64, sec=self.basal[5])
        h.pt3dadd(-149.222, -7.562, -37.116, 0.64, sec=self.basal[5])
        h.pt3dadd(-152.102, -7.562, -37.936, 0.64, sec=self.basal[5])
        h.pt3dadd(-154.022, -7.562, -37.916, 0.64, sec=self.basal[5])
        h.pt3dadd(-157.222, -8.212, -39.196, 0.64, sec=self.basal[5])
        h.pt3dadd(-159.782, -10.152, -39.636, 0.64, sec=self.basal[5])
        h.pt3dadd(-162.332, -11.452, -43.116, 0.64, sec=self.basal[5])
        h.pt3dadd(-165.852, -13.392, -44.816, 0.516, sec=self.basal[5])
        h.pt3dadd(-168.092, -14.042, -47.096, 0.486, sec=self.basal[5])

        self.basal[6].connect(self.basal[4])
        h.pt3dclear(sec=self.basal[6])
        h.pt3dadd(-124.282, 1.188, -17.416, 0.64, sec=self.basal[6])
        h.pt3dadd(-126.522, -2.052, -19.176, 0.58, sec=self.basal[6])
        h.pt3dadd(-130.042, -4.972, -19.176, 0.588, sec=self.basal[6])
        h.pt3dadd(-133.872, -5.942, -17.176, 0.622, sec=self.basal[6])
        h.pt3dadd(-137.072, -8.212, -17.176, 0.664, sec=self.basal[6])
        h.pt3dadd(-139.312, -9.832, -17.176, 0.656, sec=self.basal[6])
        h.pt3dadd(-142.512, -12.422, -17.596, 0.618, sec=self.basal[6])
        h.pt3dadd(-146.342, -12.752, -16.076, 0.648, sec=self.basal[6])
        h.pt3dadd(-149.862, -13.072, -17.236, 0.514, sec=self.basal[6])
        h.pt3dadd(-153.062, -12.752, -18.816, 0.612, sec=self.basal[6])
        h.pt3dadd(-155.942, -12.422, -20.536, 0.498, sec=self.basal[6])
        h.pt3dadd(-159.142, -11.772, -23.916, 0.404, sec=self.basal[6])

        self.basal[7].connect(self.basal[3])
        h.pt3dclear(sec=self.basal[7])
        h.pt3dadd(-108.932, 5.718, -9.356, 0.804, sec=self.basal[7])
        h.pt3dadd(-114.692, 7.338, -3.716, 0.72, sec=self.basal[7])
        h.pt3dadd(-119.482, 8.638, 1.824, 0.758, sec=self.basal[7])
        h.pt3dadd(-122.362, 9.288, 5.544, 0.658, sec=self.basal[7])
        h.pt3dadd(-125.882, 10.578, 7.024, 0.676, sec=self.basal[7])
        h.pt3dadd(-131.002, 10.908, 9.624, 0.598, sec=self.basal[7])
        h.pt3dadd(-133.552, 13.498, 10.304, 0.652, sec=self.basal[7])
        h.pt3dadd(-136.752, 14.788, 11.724, 0.546, sec=self.basal[7])
        h.pt3dadd(-138.992, 16.088, 13.144, 0.614, sec=self.basal[7])
        h.pt3dadd(-144.112, 18.358, 14.244, 0.476, sec=self.basal[7])

        self.basal[8].connect(self.basal[0])
        h.pt3dclear(sec=self.basal[8])
        h.pt3dadd(-77.03, 0.483, 3.784, 1.28, sec=self.basal[8])
        h.pt3dadd(-80.23, -0.487, 1.264, 0.788, sec=self.basal[8])
        h.pt3dadd(-82.47, -0.487, 1.084, 0.852, sec=self.basal[8])
        h.pt3dadd(-85.35, -2.107, 0.664, 0.75, sec=self.basal[8])
        h.pt3dadd(-88.084, -4.512, 0.566, 0.848, sec=self.basal[8])
        h.pt3dadd(-90.408, -7.229, 0.826, 0.952, sec=self.basal[8])
        h.pt3dadd(-93.59, -9.125, 0.336, 0.918, sec=self.basal[8])
        h.pt3dadd(-96.47, -9.445, -0.304, 0.732, sec=self.basal[8])
        h.pt3dadd(-98.07, -11.395, -1.384, 0.852, sec=self.basal[8])
        h.pt3dadd(-99.35, -13.985, -1.924, 0.806, sec=self.basal[8])
        h.pt3dadd(-101.59, -16.895, -2.324, 0.834, sec=self.basal[8])
        h.pt3dadd(-104.47, -20.135, -3.244, 0.872, sec=self.basal[8])
        h.pt3dadd(-106.502, -23.151, -3.947, 0.784, sec=self.basal[8])
        h.pt3dadd(-108.055, -26.209, -4.515, 0.798, sec=self.basal[8])
        h.pt3dadd(-110.728, -29.518, -5.631, 0.798, sec=self.basal[8])
        h.pt3dadd(-113.278, -32.758, -9.111, 0.756, sec=self.basal[8])
        h.pt3dadd(-116.798, -35.348, -10.931, 0.776, sec=self.basal[8])
        h.pt3dadd(-119.038, -37.288, -14.551, 0.786, sec=self.basal[8])
        h.pt3dadd(-121.278, -39.558, -17.851, 0.732, sec=self.basal[8])
        h.pt3dadd(-124.798, -42.148, -20.151, 0.788, sec=self.basal[8])
        h.pt3dadd(-127.15, -46.524, -19.989, 0.748, sec=self.basal[8])
        h.pt3dadd(-130.234, -50.645, -19.025, 0.712, sec=self.basal[8])
        h.pt3dadd(-132.082, -54.729, -18.852, 0.64, sec=self.basal[8])
        h.pt3dadd(-134.952, -57.639, -18.852, 0.64, sec=self.basal[8])
        h.pt3dadd(-137.192, -60.229, -22.812, 0.64, sec=self.basal[8])
        h.pt3dadd(-140.072, -62.499, -24.332, 0.64, sec=self.basal[8])
        h.pt3dadd(-143.272, -64.449, -23.972, 0.64, sec=self.basal[8])
        h.pt3dadd(-145.192, -66.709, -23.972, 0.64, sec=self.basal[8])
        h.pt3dadd(-147.752, -69.309, -26.752, 0.64, sec=self.basal[8])
        h.pt3dadd(-149.982, -72.219, -25.852, 0.64, sec=self.basal[8])
        h.pt3dadd(-150.302, -77.079, -26.312, 0.64, sec=self.basal[8])
        h.pt3dadd(-152.222, -79.999, -27.112, 0.64, sec=self.basal[8])
        h.pt3dadd(-153.182, -83.889, -27.772, 0.64, sec=self.basal[8])
        h.pt3dadd(-156.062, -87.119, -28.132, 0.64, sec=self.basal[8])
        h.pt3dadd(-157.342, -91.009, -28.052, 0.64, sec=self.basal[8])
        h.pt3dadd(-158.822, -95.029, -26.292, 0.64, sec=self.basal[8])
        h.pt3dadd(-160.732, -99.569, -26.272, 0.64, sec=self.basal[8])
        h.pt3dadd(-162.012, -102.479, -25.372, 0.64, sec=self.basal[8])
        h.pt3dadd(-164.572, -106.049, -24.672, 0.32, sec=self.basal[8])
        h.pt3dadd(-167.132, -110.579, -24.672, 0.32, sec=self.basal[8])
        h.pt3dadd(-168.732, -116.409, -26.352, 0.32, sec=self.basal[8])
Beispiel #29
0
March 2013 - June 2014
"""

from neuron import h, rxd

from matplotlib import pyplot
import numpy
import __main__

name = __main__.__file__
if name[-3:] == '.py':
    name = name[:-3]

h.load_file('stdrun.hoc')

dend = h.Section()
dend.diam = 2
dend.nseg = 101
dend.L = 100

diff_constant = 1

r = rxd.Region(h.allsec())
ca = rxd.Species(r,
                 d=diff_constant,
                 initial=lambda node: 1 if 0.4 < node.x < 0.6 else 0)

h.finitialize()

for t in [25, 50, 75, 100, 125]:
    h.continuerun(t)
        fd = sys.stdout.fileno()
        keep = os.dup(fd)
        sys.stdout.flush()
        os.dup2(null.fileno(), fd)
        h(arg)
        sys.stdout.flush()
        os.dup2(keep, fd)

def hoc_setup():
    hoc_execute_quiet('load_file("stdrun.hoc")')

# Make model

hoc_setup()

cable = h.Section(name='cable')
cable.diam = diam
cable.L= length
cable.cm = 100*cm       # [µF/cm² = 0.01 F/m²]
cable.Ra = 100*ra       # [Ω cm = 0.01 Ω m]
cable.nseg = int(n)

cable.insert('pas')
cable.g_pas = 0.0001/rm  # [S/cm² = 10000 S/m²]
cable.e_pas = Erev

stim = h.IClamp(cable(0))
stim.delay = 0
stim.dur = tend
stim.amp = iinj