How to use the neuron.h.Section function in NEURON

To help you get started, we’ve selected a few NEURON examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JustasB / BlenderNEURON / tests / test_client.py View on Github external
def test():
            from blenderneuron.quick import bn

            with Blender():
                from neuron import h
                soma = h.Section(name="Soma")
                soma.L = soma.diam = 10

                bn.to_blender()

                self.assertTrue(bn.run_command("return_value = 'Soma' in bpy.data.objects"))
                self.assertTrue(bn.run_command("return_value = bpy.data.objects['Soma'].dimensions == mathutils.Vector((10.020000457763672, 10.0, 10.0))"))
github arbor-sim / arbor / nrn / simple_synapse.py View on Github external
parser.add_argument('--synapse', metavar='SYN', dest='synapse',
                    choices=['exp', 'exp2'],
                    default='exp',
                    help='use synapse type SYN (exp or exp2)')

# hack to make things work with nrniv ... -python:
# throw away args before -python foo.py if -python present.

if '-python' in sys.argv:
    argv = sys.argv[sys.argv.index('-python')+2:]
else:
    argv = sys.argv

args = parser.parse_args(argv)

soma = h.Section(name='soma')
dend = h.Section(name='dend')

dend.connect(soma(1))

# Surface area of cylinder is 2*pi*r*h (sealed ends are implicit).
# Here we make a square cylinder in that the diameter
# is equal to the height, so diam = h. ==> Area = 4*pi*r^2
# We want a soma of 500 microns squared:
# r^2 = 500/(4*pi) ==> r = 6.2078, diam = 12.6157
soma.L = soma.diam = 12.6157 # Makes a soma of 500 microns squared.
dend.L = 200 # microns
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
github Neurosim-lab / netpyne / examples / M1detailed / cells / ITcell.py View on Github external
def add_axon (self):
    # NB: paste-on axon if using SPI morphology (eg for comparing morph effect on dynamics)
    from PTAxonMorph import axonPts
    self.axon.append(h.Section(name="axon[0]"))
    self.all.append(self.axon[0])
    self.axon[0].connect(self.soma[0], 0.0, 0.0)
    # clears 3d points
    h.pt3dclear()
    # define a logical connection point relative to the first 3-d point
    h.pt3dstyle(axonPts[0][0], axonPts[0][1], axonPts[0][2], axonPts[0][3], sec=self.axon[0])
    # add axon points after first logical connection point
    for x, y, z, d in axonPts[1:]: h.pt3dadd(x, y, z, d, sec=self.axon[0])
github JustasB / BlenderNEURON / blenderneuron / nrn / neuronnode.py View on Github external
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'])
github BlueBrain / eFEL / examples / deap / deap_efel_eval1.py View on Github external
def evaluate(individual, target_voltage1=-80, target_voltage2=-60):
    """
    Evaluate a neuron model with parameters e_pas and g_pas, extracts
    features from resulting traces and returns a tuple with
    abs(voltage_base-target_voltage1) and 
    abs(steady_state_voltage-target_voltage2)
    """

    neuron.h.v_init = target_voltage1

    soma = neuron.h.Section()

    soma.insert('pas')

    soma.g_pas = individual[0]
    soma.e_pas = individual[1]

    clamp = neuron.h.IClamp(0.5, sec=soma)

    stim_start = 500
    stim_end = 1000

    clamp.amp = 1.0
    clamp.delay = stim_start
    clamp.dur = 100000

    voltage = neuron.h.Vector()
github Neurosim-lab / netpyne / sim / shared_yfrac.py View on Github external
def make (self):
        # Instantiate cell model (eg. Izhi2007 point process, HH MC, ...)
        if self.cellModel == l.Izhi2007: # Izhikevich 2007 neuron model
            self.dummy = h.Section()
            if self.topClass in range(0,3): # if excitatory cell use RS
                self.m = izhi.RS(self.dummy, cellid=self.gid)
            elif self.topClass == l.Pva: # if Pva use FS
                self.m = izhi.FS(self.dummy, cellid=self.gid)
            elif self.topClass == l.Sst: # if Sst us LTS
                self.m = izhi.LTS(self.dummy, cellid=self.gid)
        else:
            print('Selected cell model %d not yet implemented' % (self.cellModel))
github research-team / robot-dream / Nociception / python_model / model_part.py View on Github external
def create_sections(self):
        self.soma = h.Section(name='soma', cell=self)
        self.dend = h.Section(name='dend', cell=self)
    def build_topology(self):
github pozzorin / GIFFittingToolbox / src / HBP / NEURON / GIF_NEURON.py View on Github external
def _build(self, passive_axon=False):
        self.soma = soma = h.Section(name='soma')
        if passive_axon: # simulate a passive axon for network implementation

            h.execute('create axon[2]')
            self.axon = axon = h.axon

            for index, section in enumerate(axon):
                section.nseg = 1
                section.L = 1e-9
                section.diam = 1e-9
                section.Ra = 1e-9
                #section.insert('pas')
                #section(0.5).pas.g = 1e-9

            axon[0].connect(soma, 1.0, 0.0)
            axon[1].connect(axon[0], 1.0, 0.0)
github ahwillia / PyNeuron-Toolbox / PyNeuronToolbox / morphology.py View on Github external
def load_json(morphfile):

    with open(morphfile, 'r') as f:
        secdata = json.load(morphfile)

    seclist = []
    for sd in secdata:
        # make section
        sec = h.Section(name=sd['name'])
        seclist.append(sec)


        # make 3d morphology
        for x,y,z,d in zip(sd['x'], sd['y'], sd['z'], sd('diam')): 
            h.pt3dadd(x, y, z, d, sec=sec)

    # connect children to parent compartments
    for sec,sd in zip(seclist,secdata):
        if sd['parent_loc'] >= 0:
            parent_sec = sec_list[sd['parent']]
            sec.connect(parent_sec(sd['parent_loc']), sd['section_orientation'])

    return seclist
github research-team / robot-dream / Nociception / cfiber.py View on Github external
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)]
    def build_topology(self):