How to use NEURON - 10 common examples

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(keep=False):

                from neuron import h
                h.load_file(test_hoc_file)
                tc = h.TestCell()

                ic = h.IClamp(0.5, sec=tc.soma)
                ic.delay = 1
                ic.dur = 3
                ic.amp = 0.5

                bn.prepare_for_collection()
                h.run()
                bn.to_blender()

                bn.run_command("bpy.data.scenes['Scene'].frame_current = 1;")
                self.assertTrue(bn.run_command("return_value = bpy.data.materials['TestCell[0].dendrites[9][0]'].emit") == 0.0)

                bn.run_command("bpy.data.scenes['Scene'].frame_current = 7;")
                self.assertTrue(bn.run_command("return_value = bpy.data.materials['TestCell[0].dendrites[9][0]'].emit") == 2.0)
github JustasB / BlenderNEURON / tests / test_client.py View on Github external
def test():
            from blenderneuron.quick import bn

            with Blender():
                from neuron import h
                h.load_file(test_hoc_file)
                tc1 = h.TestCell()
                tc2 = h.TestCell()

                ic = h.IClamp(0.5, sec=tc1.soma)
                ic.delay = 1
                ic.dur = 3
                ic.amp = 0.5

                bn.prepare_for_collection()
                bn.groups["all"]["3d_data"]["interaction_level"] = "Group"
                bn.groups["all"]["3d_data"]["color_level"] = "Group"

                h.run()

                bn.to_blender()
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 JustasB / BlenderNEURON / tests / test_client.py View on Github external
def test():
            from blenderneuron.quick import bn

            with Blender(keep=False):

                from neuron import h
                h.load_file(test_hoc_file)
                tc1 = h.TestCell()
                tc2 = h.TestCell()

                ic = h.IClamp(0.5, sec=tc1.soma)
                ic.delay = 1
                ic.dur = 3
                ic.amp = 0.5

                bn.prepare_for_collection()
                bn.groups["all"]["3d_data"]["interaction_level"] = "Cell"
                bn.groups["all"]["3d_data"]["color_level"] = "Segment"

                h.run()

                bn.to_blender()

                self.assertTrue(bn.run_command("return_value = 'TestCell[0]' in bpy.data.objects"))
                self.assertTrue(bn.run_command("return_value = 'TestCell[1]' in bpy.data.objects"))

                self.assertTrue(bn.run_command("return_value = 'TestCell[0].soma[0]' in bpy.data.materials"))
github JustasB / BlenderNEURON / tests / test_client.py View on Github external
def test():
            from blenderneuron.quick import bn

            with Blender(keep=False):

                from neuron import h
                h.load_file(test_hoc_file)
                tc1 = h.TestCell()
                tc2 = h.TestCell()

                ic = h.IClamp(0.5, sec=tc1.soma)
                ic.delay = 1
                ic.dur = 3
                ic.amp = 0.5

                bn.prepare_for_collection()
                bn.groups["all"]["3d_data"]["interaction_level"] = "Cell"
                bn.groups["all"]["3d_data"]["color_level"] = "Section"

                h.run()

                bn.to_blender()

                self.assertTrue(bn.run_command("return_value = 'TestCell[0]' in bpy.data.objects"))
                self.assertTrue(bn.run_command("return_value = 'TestCell[1]' in bpy.data.objects"))

                self.assertTrue(bn.run_command("return_value = 'TestCell[0].soma' in bpy.data.materials"))
github NeuralEnsemble / PyNN / test / unsorted / neuron / test_neuron.py View on Github external
def record(self, active):
        if active:
            rec = h.NetCon(self.source, None, sec=self)
            rec.record(self.spike_times)
github neuronsimulator / nrn / test / pynrn / test_basic.py View on Github external
h('''create soma''')
    h.load_file("stdrun.hoc")
    h.soma.L = 5.6419
    h.soma.diam = 5.6419
    h.soma.insert("hh")
    ic = h.IClamp(h.soma(0.5))
    ic.delay = 0.5
    ic.dur = 0.1
    ic.amp = 0.3

    v = h.Vector()
    v.record(h.soma(0.5)._ref_v, sec=h.soma)
    tv = h.Vector()
    tv.record(h._ref_t, sec=h.soma)
    nc = h.NetCon(h.soma(0.5)._ref_v, None, sec=h.soma)
    spikestime = h.Vector()
    nc.record(spikestime)
    h.run()

    simulation_spikes = spikestime.to_python()

    assert np.allclose(simulation_spikes, ref_spikes)
github nrnhines / ringtest / ringuniform.py View on Github external
nring=64
ncell=8 # number of cells per ring

nsomachild = 16
nbranch = 32

print "nring=%d\ncell per ring=%d"%(nring, ncell)

tstop=100
randomize_parameters = False

from neuron import h
h.load_file('nrngui.hoc')
pc = h.ParallelContext()
rank = int(pc.id())
nhost = int(pc.nhost())
#from cell import BallStick
h.load_file("celluniform.hoc")

class Ring(object):

  def __init__(self, ncell, nbranch, gidstart):
    #print "construct ", self
    self.gids = []
    self.delay = 1
    self.ncell = int(ncell)
    self.gidstart = gidstart
    self.mkring(self.ncell, nbranch, nsomachild)
    self.mkstim()
github BlueBrain / CoreNeuron / tests / jenkins / neuron_direct.py View on Github external
from neuron import h, gui
import sys

h('''create soma''')
h.soma.L=5.6419
h.soma.diam=5.6419
h.soma.insert("hh")
ic = h.IClamp(h.soma(.5))
ic.delay = .5
ic.dur = 0.1
ic.amp = 0.3

h.cvode.use_fast_imem(1)
h.cvode.cache_efficient(1)

v = h.Vector()
v.record(h.soma(.5)._ref_v, sec = h.soma)
i_mem = h.Vector()
i_mem.record(h.soma(.5)._ref_i_membrane_, sec = h.soma)
tv = h.Vector()
tv.record(h._ref_t, sec=h.soma)
h.run()
vstd = v.cl()
tvstd = tv.cl()
github openworm / pygeppetto / jupyter-frontend / simple_network.py View on Github external
def plot_raster(self, color='blue'):
        """ Plot raster with spikes of all cells """
        pyplot.figure()
        pyplot.scatter(self.spkt, self.spkid, marker= "|", s=100, c=color)
        pyplot.xlabel('time (ms)')
        pyplot.ylabel('cell id')
        pyplot.title('Network raster')
        pyplot.show()

# Main code
net = Net(numcells=10)  # create network 
net.connect_cells_ring(syn_weight=0.1, syn_delay=1)  # connect cells in a ring 
net.plot_net()  # plot network cells positions
net.cells[0].add_current_stim(delay=1)  # add stimulation to a cell

h.tstop = 60 # set simulation duration
#h.init()  # initialize sim
#h.run()  # run simulation

def analysis():
    from matplotlib import pyplot

    net.cells[0].plot_voltage()  # plot voltage
    net.cells[4].plot_voltage()  # plot voltage

    # plot raster
    net.plot_raster()