コード例 #1
0
    def __init__(self):
        h.xopen("purkinje_reduced_PPR model.hoc")

        # There are thirtyeight compartments and the following are chosen as
        # attributes to this python class for potential recording
        self.soma = h.Soma
        #
        dend_root = h.MainDendrite  # len(h.MainDendrite) -> 1
        dend_sm_distalshort = h.SmoothDistalDendriteshort  # len() -> 3
        dend_sm_distallong = h.SmoothDistalDendritelong  # len() -> 3
        dend_sp_distal = h.SpinyDistalDendrite  # len() -> 3
        dend_adj = h.AdjacentDendrite  # len() -> 15
        spine_neck = h.SpineNeck  # len() -> 1
        spine = h.Spine  # len() -> 1
        #
        self.dend_root = dend_root[0]
        self.dend_sm = [
            dend_sm_distalshort[randint(0,
                                        len(dend_sm_distalshort) - 1)],
            dend_sm_distallong[randint(0,
                                       len(dend_sm_distallong) - 1)]
        ][randint(0, 1)]
        self.dend_sp = [
            dend_sp_distal[randint(0,
                                   len(dend_sp_distal) - 1)],
            dend_adj[randint(0,
                             len(dend_adj) - 1)]
        ][randint(0, 1)]
        self.spine_head = spine[0]
        self.spine_neck = spine_neck[0]
コード例 #2
0
def main(template_path, forest_path, synapses_path, config_path):

    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()

    env = Env(comm=comm, config_file=config_path, template_paths=template_path)

    h('objref nil, pc, tlog, Vlog, spikelog')
    h.load_file("nrngui.hoc")
    h.xopen("./tests/rn.hoc")
    h.xopen(template_path + '/BasketCell.hoc')

    pop_name = "BC"
    gid = 1039000
    (trees_dict, _) = read_tree_selection(forest_path,
                                          pop_name, [gid],
                                          comm=env.comm)
    synapses_dict = read_cell_attribute_selection(synapses_path,
                                                  pop_name, [gid],
                                                  "Synapse Attributes",
                                                  comm=env.comm)

    (_, tree) = next(trees_dict)
    (_, synapses) = next(synapses_dict)

    v_init = -60

    template_class = getattr(h, "BasketCell")

    ap_test(template_class, tree, v_init)
    passive_test(template_class, tree, v_init)
    ap_rate_test(template_class, tree, v_init)
    fi_test(template_class, tree, v_init)
    gap_junction_test(env, template_class, tree, v_init)
    synapse_test(template_class, gid, tree, synapses, v_init, env)
コード例 #3
0
ファイル: HICAPCellTest.py プロジェクト: soltesz-lab/dentate
def main(template_path, forest_path, synapses_path, connections_path, config_path):
    
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()

    env = Env(comm=comm, config_file=config_path, template_paths=template_path)

    h('objref nil, pc, tlog, Vlog, spikelog')
    h.load_file("nrngui.hoc")
    h.xopen ("./tests/rn.hoc")
    h.xopen(template_path+'/HICAPCell.hoc')
    
    pop_name = "HCC"
    gid = 1043250
    (trees_dict,_) = read_tree_selection (forest_path, pop_name, [gid], comm=env.comm)

    (_, tree) = next(trees_dict)
    v_init = -67
    
    template_class = getattr(h, "HICAPCell")

    passive_test(template_class, tree, v_init)
    ap_test(template_class, tree, v_init)
    ap_rate_test(template_class, tree, v_init)
    fi_test(template_class, tree, v_init)

    if synapses_path and connections_path:
        synapses_iter = read_cell_attribute_selection (synapses_path, pop_name, [gid],
                                                       "Synapse Attributes", comm=env.comm)
        (_, synapses_dict) = next(synapses_iter)
        connections = read_graph_selection(file_name=connections_path, selection=[gid],
                                            namespaces=['Synapses', 'Connections'], comm=env.comm)

        synapse_test(template_class, gid, tree, synapses_dict, connections, v_init, env)
コード例 #4
0
ファイル: Golgi.py プロジェクト: cerebunit/cerebmodels
    def __init__(self):
        ############################# MORPHOLOGY ##############################
        h.xopen("Golgi_template.hoc") # Within it is the function Goc() which
        # creates a soma (1 section, 1 segment = 1 compartment) and
        # three dendrites (3 section, each with 10 compartments = 10 segments)
        # notice the absence of axon
        h("objref GoC")      # this will make available: h.GoC.soma
        h("GoC = new Goc(0,0,0)") # h.GoC.axon and h.GoC.dend
        # Notice three arguments vs GoC2007Solinas, this is because here the
        # the template by Souza & Schutter are meant for the network.
        # The arguments are basically the x,y,z-coordinates.

        # below are the regions set as attribute to this python class
        self.soma = h.GoC.soma
        self.dend = h.GoC.dend # len(h.GoC.dend) -> 3

        ############################# PARAMETERS ##############################
        # using the parameters given in network.hoc (under Golgi cell layer)
        #self.soma.el_Golgi_lkg = -55. # already by default
        self.soma.ko = 5
        #self.soma.ki = 140 # already by default
        self.soma.nao = 145
        #self.soma.nai = 5 # already by default
        #
        # Based on the paper http://dx.doi.org/10.1186/2042-1001-1-7
        # under Methods section, Model GoC's sub-section
        # "We adopted a resting membrane potential of -60 mV and a
        # passive leakage current with reversal porential at -44.5 mV."
        h("v_init = -60.")
        self.soma.el_Golgi_lkg = -44.5
        [ setattr(d, "el_Golgi_lkg", -44.5) for d in self.dend ]
コード例 #5
0
ファイル: Granule.py プロジェクト: cerebunit/cerebmodels
    def __init__(self):
        h.xopen("granule2.proto")  # Within it parameters are defined and
        # its geometry is set by loading granuel.nrn

        # There are thirteen compartments and the following are chosen as
        # attributes to this python class for potential recording
        self.soma = h.soma
        self.dend = h.dendrite  # len(h.dendrite) -> 4
        self.bulb = h.bulb  # len(h.bulb) -> 4
コード例 #6
0
    def __init__(self):
        h.xopen("resurgesim.hoc")

        # Since it has only one compartment the attribute for this
        # python class for recording is just soma
        self.soma = h.soma

        # based on the readme.txt
        h.dt = 0.025
        h.steps_per_ms = 1 / h.dt
コード例 #7
0
    def __init__(self):
        ############################# MORPHOLOGY ##############################
        h("GJ = 1") # 0 for no gap-junctions between GoCs
        # 0 or 1, GJ must be set prior to loading network.hoc
        h.xopen("network.hoc") # Within it is the function Goc() which

        # below are the components set as attribute to this python class
        self.GrC = h.GrC # len(h.GrC) -> 8100
        self.GoC = h.GoC # len(h.GoC) -> 225
        self.MF = h.fiber # len(h.fiber) -> 900
コード例 #8
0
    def __init__(self):
        h.xopen("purkinje.hoc")

        # There are thirteen compartments and the following are chosen as
        # attributes to this python class for potential recording
        self.soma = h.soma
        #
        dend_sm = h.SmoothDendrite  # len(h.SmoothDendrite) -> 85
        dend_sp = h.SpinyDendrite  # len(h.SpinyDendrite) -> 1002
        #
        self.dend_sm = dend_sm[randint(0, len(dend_sm) - 1)]
        self.dend_sp = dend_sp[randint(0, len(dend_sp) - 1)]
コード例 #9
0
    def __init__(self):
        h("load_file(\"nrngui.hoc\")")  #h("proc set_ra() {}")
        # this step is needed otherwise there is RuntimeError
        # for the undefined function when loading 2_compartment.hoc where this
        # function is called at line 34. The above step defines the function set_ra()
        h.xopen("2_compartment.hoc")

        # The 1087 out of 1088 compartments are the compartment of dendites,
        # smooth and spiny. These 1087 are reduced to a compartment. Thus,
        # attributes to this python class for potential recording are
        self.soma = h.soma
        self.dend = h.Couple  # h.Couple.nseg -> 1
コード例 #10
0
    def __init__(self):
        h("objref cvode")  # initialize multiple order variable time step
        h("cvode = new CVode()"
          )  # integration method as it is called in hoc file
        h.xopen("start.hoc")

        # nsyn1 = 4 at line 11
        # ncells = 1 at line 79
        # nmossy = 4 at line 80
        # Notice that one should try to have nmossy = nsyn1 =/= NumSyn (synapse/MF)
        self.cell = h.GrCell[0]  # len(h.GrCell) -> 1
        self.mossy = h.Mossy  # len(h.Mossy) -> 4
コード例 #11
0
    def __init__(self):
        ############################# MORPHOLOGY ##############################
        h.xopen(
            "granule_template.hoc")  # Within it is the function grc() which
        # creates a soma (1 section, 1 segment = 1 compartment)
        h("objref GrC")  # this will make available: h.GrC.soma
        h("GrC = new grc(0,0,0)")
        # Notice three arguments, this is because here the
        # the template by Souza & Schutter are meant for the network.
        # The arguments are basically the x,y,z-coordinates.

        # below are the regions set as attribute to this python class
        self.soma = h.GrC.soma
コード例 #12
0
    def __init__(self):
        h.xopen(
            "DCN_simulation.hoc")  # Within it, after defining the parameters
        # it loads: DCN_morph.hoc, DCN_mechs.hoc and DCN_run.hoc
        # (inside DCN_run.hoc, DCN_recording.hoc is loaded)
        # NOTE: for our application none of the functions within DCN_run.hoc and
        # DCN_recording.hoc will be invoked and hence are of direct interest.

        # since there are 517 compartments with the following reference groups:
        # h.soma, h.axHillock, h.axIniSeg, h.axNode,
        # h.proxDend, h.distDend, h.excSynapseComps, h.inhSynapseComps
        # only those used in DCN_recording.hoc have its attribute to this python class
        self.soma = h.soma
        self.gaba = h.gaba  # len(h.gaba) -> 450
コード例 #13
0
    def __init__(self):
        h.xopen("model2.hoc")

        # The following compartments of the Deep Cerebellar Neuron if available
        # as attributes
        self.soma = h.soma  # 1 compartment
        # there is also only 1 compartment for axon hillock but it is a SectionList
        self.axon_hillock = [sec for sec in h.axHillock][0]
        # there are 10 compartments of axon initial segment
        self.axon_initial = [sec for sec in h.axIniSeg]
        # there are 20 compartments for axon node
        self.axon_node = [sec for sec in h.axNode]
        # there are 83 compartments for the proximal dendrite
        self.dend_proximal = [sec for sec in h.proxDend]
        # there are 402 compartments for the distal dendrite
        self.dend_distal = [sec for sec in h.distDend]
コード例 #14
0
    def __init__(self):
        ############################# MORPHOLOGY ##############################
        h.xopen("Golgi_template.hoc")  # Within it is the function Goc() which
        # creates a soma (1 section, 1 segment = 1 compartment),
        # an axon (1 section, 100 segment = 100 compartments) and
        # three dendrites (3 section, each with 10 compartments = 10 segments)
        h("objref Golgi[1]")  # this will make available: h.Golgi[0].soma
        h("Golgi[0] = new Goc()")  # h.Golgi[0].axon and h.Golgi[0].dend

        ############################# PARAMETERS ##############################
        h.xopen("Synapses.hoc")  # synapse parameters are set on h.Golgi[0]

        # below are the regions set as attribute to this python class
        self.soma = h.Golgi[0].soma
        self.axon = h.Golgi[0].axon
        self.dend = h.Golgi[0].dend  # len(h.Golgi[0].dend -> 3
コード例 #15
0
    def __init__(self):
        h.xopen("full_CP.hoc")

        # There are 1088 compartments and the following are chosen as
        # attributes to this python class for potential recording
        self.soma = h.soma
        #
        dend_sm = h.sm  # len(h.sm) -> 85
        #self.dend_sp1 = h.spn1 # len() -> 1
        #but there are 86 such spiny dendrites and unlike h.sm they are separate
        dend_sp = []
        for i in range(1, 86 + 1):
            dend_sp.append(getattr(h, "spn" + str(i))[0])  # since nseg = 1
        #
        self.dend_sm = dend_sm[randint(0, len(dend_sm) - 1)]
        self.dend_sp = dend_sp[randint(0, len(dend_sp) - 1)]
コード例 #16
0
    def __init__(self, hoc_model, path_mods, setting):
        """
        Parameters
        ----------
        hoc_model : str
            the path to model in .hoc
        path_mods : str
            the path to the directory containing the .mod files
        setting : dict
            the dictionary containing setting
        """
        self.setting = setting
        h.nrn_load_dll(path_mods + 'nrnmech.dll')
        h.xopen(hoc_model)

        self.CA1 = h.CA1_PC_Tomko()
        self.soma = self.CA1.soma[0]
        self.all = list(self.CA1.all)
        self.apical = list(self.CA1.apical)
        self.basal = list(self.CA1.basal)

        self.v_vec = h.Vector().record(self.soma(0.5)._ref_v)
        self.t_vec = h.Vector().record(h._ref_t)
        self.t_rs_vec = h.Vector().record(
            h._ref_t, self.setting['simulation']['RECORDING_STEP'])
        self.cai_vecs = {}
        self.cal2_ica_vecs = {}
        self.dend_vecs = {}
        self.ina_vecs = {}
        self.nmda_ica_vecs = {}

        self.apc = None
        self.apc_vec = h.Vector()

        self.bcm = None
        self.alpha_scout_vec = h.Vector()
        self.d_vec = h.Vector()
        self.p_vec = h.Vector()

        self.syn_AMPA_count = 0
        self.syn_NMDA_count = 0
        self.synapses = {}
        self.net_cons = []
        self.net_stims = []

        self.vBoxShape = None
        self.shplot = None
コード例 #17
0
def create_cell(name,
                mechparams=None,
                Ra=None,
                calc_nseg=False,
                filename=None):
    """Make a copy of the GGN and insert mechanisms based on mechparams.

    mechparams: dict of dicts containing parameters for
    mechanisms. Each entry should be
    
    name: { param: value, param: value, ...}
    
    Other than name, the param keys depend on the mechanism
    definition. For example, the predefined passive mechanism has name
    `pas` and it defines g and e as parameters. The corresponding dict entry
    will be `'pas': {'g': 2.5e-4, 'e'=-65.0}` for inserting
    passive conductance with density 2.5e-4 S/cm2 on each compartment
    and the reversal potential -65 mV.

    """
    if not hasattr(h, name):
        if filename is None:
            raise Exception('Cell not preloaded. Specify template filename')
        h.xopen(filename)
    cell = eval('h.{}()'.format(name))
    if mechparams is None:
        mechparams = {}
    print(mechparams)
    mech_dict = ephys.create_mechs(mechparams)
    insert_mechanisms(cell, mech_dict.values())
    if (Ra is not None) or calc_nseg:
        cell.soma.push()
        ordered_tree = h.SectionList()
        ordered_tree.wholetree()
        h.pop_section()
        if not isinstance(Ra, float):  # Assume pint.UnitRegistry().Quantity
            Ra = ephys.Q_(Ra).to('ohm*cm').m
        for sec in ordered_tree:
            sec.push()
            if Ra is not None:
                sec.Ra = Ra
            # lambda_f = np.sqrt(sec.diam/(4 * sec.Ra * sec.g_pas))
            # nseg = int(10 * sec.L / lambda_dc + 0.5)
            nseg = int((sec.L / (0.1 * h.lambda_f(100)) + 0.999) / 2) * 2 + 1
            sec.nseg = nseg
            h.pop_section()
    return cell
コード例 #18
0
    def __init__(self):
        h.xopen("purkinje.hoc")

        # There are 1088 compartments and the following are chosen as
        # attributes to this python class for potential recording
        self.soma = h.somaA
        self.ais = h.AIS
        # Based on last 50 or so lines of Purkinje19b972-1.nrn
        self.dend_root = h.dendA1_0  # see Fig.2A of paper
        # Reverse eng. from Purkinje19b972-1.nrn and dendv_arnd21.ses
        self.dend_sm = [sec for sec in h.maindend]  # len(dend_sm) -> 30
        self.dend_sp = [sec for sec in h.spinydend]  # len(dend_sp) -> 1105
        # note that for either self.dend_sm or self.dend_sp
        # the first element of its list is a dendrite section closest to soma
        # and last element is the dendrite section farthest away.
        # also potentially
        self.cf = [sec for sec in h.cf]  # for climbing fibre
        self.pf = [sec for sec in h.pf]  # for parallel fibre
        self.bs_cf = [sec
                      for sec in h.bs]  # for branch-specific climbing fibre
コード例 #19
0
ファイル: nrntools.py プロジェクト: shamdor/Optimal-Neuron
def load_3dcell(filename, max_compartment_size=20):

    dendritic = h.SectionList()

    for sec in h.allsec():
        del sec #is this correct?
      
    h.xopen(filename)
    h('access soma')
    
    #make sure no compartments exceed 50 uM length
    for sec in h.allsec():
        diam_save = sec.diam #sec.diam makes no sense does it since diam is a segment property
        n = sec.L / max_compartment_size 
        n_truncated = int(n)#use a truncating division to avoid error
        sec.nseg = n_truncated + 1 
        if h.n3d() == 0:
            sec.diam = diam_save
        dendritic.append()
        
    return dendritic
コード例 #20
0
def main(template_path,forest_path):
    
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()

    h('objref nil, pc, tlog, Vlog, spikelog')
    h.load_file("nrngui.hoc")
    h.xopen("./lib.hoc")
    h.xopen ("./tests/rn.hoc")
    h.xopen(template_path+'/MOPPCell.hoc')
    h.pc = h.ParallelContext()
    
    popName = "MOPP"
    (trees,_) = read_tree_selection (comm, forest_path, popName, [1052650])
    
    tree = next(iter(viewvalues(trees)))
    
    passive_test(tree,-60)
    ap_rate_test(tree,-60)
コード例 #21
0
# Email:[email protected]


# Model published as [Diwakar et al., 2011, PLoS ONE]
#Shyam Diwakar, Paola Lombardo, Sergio Solinas, Giovanni Naldi, Egidio D'Angelo. "Local field potential modeling predicts dense activation in cerebellar granule cells clusters under LTP and LTD control", PLoS ONE, 2011.


from neuron import h
import os
import subprocess
from tkinter import *


h.load_file("nrngui.hoc")
h.load_file("Start.hoc")
h.xopen("Record_vext.hoc")

print("For run the Invitro LFP simulation click on the Invitro button in the panel\n")
print("For run the Invivo LFP simulation click on the Invivo button in the panel\n")

def invitroplot():
    h.Invitro()
    print('\n\n\n')
    print('Plotting invitro......')
    print('Please wait few minutes......... :)')
    os.chdir("data/Invitro/")
    return_value = subprocess.check_output('python3 testconv.py', shell=True)
    print(return_value.decode('utf-8'))
    print("Quit and restart before running for in vivo traces... ")

コード例 #22
0
# "Encoding and retrieval in a model of the hippocampal CA1 microcircuit",
# Hippocampus, in press, DOI 10.1002/hipo.20661, 2009.

from neuron import h, gui
import numpy as np
import random
import math
import sys

h("strdef simname")
h("batchflag = 0")
h("plotflag = 0")
h("scaleDown = 1")
h("scaleEScon = 1")  # Scaling argument for calcium channel conductances

h.simname = "test"
if len(sys.argv) > 1:
    h.simname = sys.argv[1]
    if len(sys.argv) > 2:
        h.batchflag = int(sys.argv[2])
        if len(sys.argv) > 3:
            h.plotflag = int(sys.argv[3])
            if len(sys.argv) > 4:
                h.scaleDown = float(sys.argv[4])
                if len(sys.argv) > 5:
                    h.scaleEScon = float(sys.argv[5])

print("h.simname = ", h.simname)

h.xopen("HAM_StoRec_ser_new.hoc")
コード例 #23
0
# CA1 heteroassociative memory network: Storage and recall
# CA1 PCs, BCs, AACs, BSCs and OLMs (using moderate cell models)
# EC, CA3 (excitatory) and Septal (inhibitory) inputs
# Cycle is: Recall-Storage-Recall etc
# Serial code adapted from Hines' ran3ser.hoc
# VCU & BPG 8-1-09

# Results reported in V. Cutsuridis, S. Cobb and B.P. Graham,
# "Encoding and retrieval in a model of the hippocampal CA1 microcircuit",
# Hippocampus, in press, DOI 10.1002/hipo.20661, 2009.

from neuron import h, gui
import numpy as np
import random
import math

h.xopen("HAM_StoRec_ser.hoc")


コード例 #24
0
def init_cell(cell_path, spines=True):

    """
    cell: path to cell definiton
    """

    h("forall delete_section()")

    # ---- conditions ----

    h.celsius = temp

    # ---- soma & dendrite ----

    h.xopen(cell_path)

    soma = h.soma

    dendritic = []

    # segment lengths should be not longer than 50um
    # contains soma!
    for sec in h.allsec():
        diam = sec.diam
        n = sec.L / 50.0 + 1
        sec.nseg = int(n)  # needed in Python, automatic in hoc
        if h.n3d() == 0:
            sec.diam = diam
        dendritic.append(sec)

    dendritic_only = []
    for sec in dendritic:
        if sec != h.soma:
            dendritic_only.append(sec)

    assert len(dendritic) - 1 == len(dendritic_only)

    # ---- spines ---

    if spines:

        for sec in dendritic_only:
            a = 0.0
            for seg in sec.allseg():
                a += seg.area()
            F = (sec.L * spine_area * spine_dens + a) / a
            sec.L = sec.L * F ** (2 / 3.0)
            for seg in sec.allseg():
                seg.diam = seg.diam * F ** (1 / 3.0)

    # ---- axon ----

    # initial segment between hillock + myelin
    iseg = h.Section(name="iseg")
    iseg.L = iseg_L
    iseg.nseg = iseg_nseg
    soma_compl_area = 0
    for seg in soma:
        soma_compl_area += seg.area()
    print soma_compl_area
    iseg.diam = (soma_compl_area / (4.0 * np.pi)) ** (0.5) / 10.0

    # axon hillock
    hill = h.Section(name="hill")
    hill.L = hill_L
    hill.nseg = hill_nseg
    taper_diam(hill, 4 * iseg.diam, iseg.diam)

    myelin = [h.Section(name="myelin %d" % i) for i in range(n_axon_seg)]
    for myelin_sec in myelin:
        myelin_sec.nseg = myelin_nseg  # each of the 5 sections has 5 segments
        myelin_sec.L = myelin_L
        myelin_sec.diam = iseg.diam

    node = [h.Section(name="node %d" % i) for i in range(n_axon_seg)]
    for node_sec in node:
        node_sec.nseg = node_nseg
        node_sec.L = node_L
        node_sec.diam = iseg.diam * 0.75

    # syntax: childsec.connect(parentsec, parentx, childx)
    hill.connect(soma, 0.5, 0)
    iseg.connect(hill, 1, 0)
    myelin[0].connect(iseg, 1, 0)
    node[0].connect(myelin[0], 1, 0)

    for i in range(n_axon_seg - 1):
        myelin[i + 1].connect(node[i], 1, 0)
        node[i + 1].connect(myelin[i + 1], 1, 0)

    # ---- mechanisms ----

    for sec in h.allsec():
        sec.insert("pas")
        sec.Ra = ra
        sec.cm = c_m
        sec.g_pas = 1.0 / rm
        sec.e_pas = v_init

        sec.insert("na")

    # dendrite
    for sec in dendritic_only:
        sec.gbar_na = gna_dend
        sec.insert("km")
        sec.gbar_km = gkm
        sec.insert("kca")
        sec.gbar_kca = gkca
        sec.insert("ca")
        sec.gbar_ca = gca
        sec.insert("cad")

    # na+ channels
    soma.gbar_na = gna_soma

    soma.insert("kv")
    soma.gbar_kv = gkv_soma

    soma.insert("km")
    soma.gbar_km = gkm_soma
    soma.insert("kca")
    soma.gbar_kca = gkca_soma
    soma.insert("ca")
    soma.gbar_ca = gca_soma
    soma.insert("cad")

    for myelin_sec in myelin:
        myelin_sec.cm = cm_myelin
        myelin_sec.gbar_na = gna_dend

    hill.gbar_na = gna_node
    iseg.gbar_na = gna_node

    for node_sec in node:
        node_sec.g_pas = g_pas_node
        node_sec.gbar_na = gna_node

    iseg.insert("kv")
    iseg.gbar_kv = gkv_axon

    hill.insert("kv")
    hill.gbar_kv = gkv_axon

    for sec in h.allsec():
        if h.ismembrane("k_ion"):
            sec.ek = Ek
        if h.ismembrane("na_ion"):
            sec.ena = Ena
            h.vshift_na = -5
        if h.ismembrane("ca_ion"):
            sec.eca = 140
            h.ion_style("ca_ion", 0, 1, 0, 0, 0)
            h.vshift_ca = 0

    axon = [iseg, hill, myelin, node]

    return soma, dendritic_only, axon
コード例 #25
0
''' Test file for MC single cell stimulation as in MC_Stim.hoc 
of the Cleland model'''

from neuron import h, gui
import tabchannels
import matplotlib.pyplot as plt
import numpy as np

# import cell
h.xopen('MC_def.hoc')

# Parameters
tstop = 6000
celsius = 35

# Instantiate a cell
mitral = h.Mitral()

# Current injection
T1 = 1500
Dur = 4000
Ic1 = 0.36
'''
stim1 = h.IClamp(mitral.soma(0.5))
stim1.delay = T1
stim1.dur = Dur
stim1.amp = Ic1



コード例 #26
0
ファイル: neuron3d.py プロジェクト: tfoutz99/Neuron3D
 def _display_NEURON_fired(self):
     nrn.xopen("ses.ses")
コード例 #27
0
    def __init__(self):
        h.xopen("purkinje.hoc")

        # Since there is only the denrite compartment with CF being inserted
        self.dend = h.dend
コード例 #28
0
ファイル: d2msn.py プロジェクト: Neurosim-lab/MSN_temp
import sys
from neuron import h, hoc
from math import sqrt, pi, log, exp
Ra = 100
ek = -94
ena = 50
with open('wtd2_params.txt') as f:
    for line in f:
        exec(line)

h.xopen("msn_wolf_all_tau_vecs.hoc")
dgnaf_proxF = G_NAFD / G_NAF
dgnap_proxF = G_NAPD / G_NAP
dgnaf_midF = G_NAFD / G_NAF
dgnap_midF = G_NAPD / G_NAP
dgkas_midF = G_KASD / G_KAS
dgkaf_midF = G_KAFD / G_KAF
dgnaf_distF = G_NAFD / G_NAF
dgnap_distF = G_NAPD / G_NAP
dgkas_distF = G_KASD / G_KAS
dgkaf_distF = G_KAFD / G_KAF


class WTD2:
    def __init__(self):
        self.create_cell()

        self.optimize_nseg()
        self.settopo()
        self.add_all()
        self.geom_nseg()
コード例 #29
0
netfcns.spikerecord(cells)
results = netfcns.vrecord(cells,dictpop, iPPC, iNPPC)



#%%

#################
# RUN SIMULATION AND WRITE RESULTS
#################

h('StepBy=100') # ms

h('walltime = startsw()')
h.xopen("midbalfcn.hoc")
h('objref fihw')
h('fihw = new FInitializeHandler(2, "midbal()")')



#if (batchflag==1):
print("Now running simulation at scale = ", scaleDown, " for time = ", h.SIMDUR, " with scaleEScon = ", scaleEScon)
h.run()
netfcns.spikeout(cells,fstem)
netfcns.vout(cells,results,fstem,dictpop)
print( "** Finished running sim and printing results **")

#%%

#################
コード例 #30
0
ファイル: PySim.py プロジェクト: SantamariaLab/NeuroManager
def pythonsim(simid, rundir, inputdir, modeldir, outputdir, currentstr, vinitstr, delaystr, stimdurationstr, timestepstr, simstopstr, recordintervalstr):
	import neuron
	from neuron import h
	Section = h.Section

	# All the mods are in the simulator directory
	# Apparently this is already done by  the import, if we use the "-dll" 
	# option in the call to nrniv. Since the import behavior seems to be 
	# inconsistent without the "-dll" option, we do it this way.
	#neuron.load_mechanisms(".")  # NOT USING LOAD_MECHANISMS HERE
	# local auto-modified version for no gui and control over certain ion 
	#  channels is in the run dir
	h.xopen(rundir + '/' + simid + '.hoc') 

	timefilepath = outputdir + '/' + 'timedata.txt'
	timefile = h.File()
	timefile.wopen(timefilepath, 'w')
	
	voltagefilepath = outputdir + '/' + 'voltagedata.txt'
	voltagefile = h.File()
	voltagefile.wopen(voltagefilepath, 'w')

	current = float(currentstr)
	vinit = float(vinitstr)
	delay = float(delaystr)
	stimduration = float(stimdurationstr)
	timestep = float(timestepstr)
	simstop = float(simstopstr)
	recordinterval = float(recordintervalstr)
	
	# ----- Current Injection
	stim = h.IClamp(0.5, sec=h.soma)
	stim.amp = current  # nA
	stim.delay = delay  # msec
	stim.dur = stimduration # msec

	# ----- Simulation Control (now mostly done through input arguments)
	h.dt = timestep

	# Preallocate record vectors for speed
	# Requires recordinterval to be an exact multiple of tstep.
	recordlength = simstop/recordinterval + 1
	testt = h.Vector(recordlength)
	testv = h.Vector(recordlength)

    # Recording at the soma
	testt.record(h._ref_t, recordinterval)
	testv.record(h.soma(0.5)._ref_v, recordinterval)

	# Initialize
	h.finitialize(vinit)
	h.fcurrent()

	# Integrate
	while h.t <= simstop:
		v = h.soma.v
		h.fadvance()

	# Shutdown
	testt.printf(timefile, '%f\n')
	testv.printf(voltagefile, '%f\n')
	timefile.close()
	voltagefile.close()
	return(0)
コード例 #31
0
    def __init__(self):
        h.xopen("P20.hoc")

        # The following are chosen as attributes for potential recording
        self.soma = h.soma
        self.dend_root = h.dendA1_0 # see Fig.2A Zang et al. 2018 10.1016/j.celrep.2018.07.011
コード例 #32
0
ファイル: sim.py プロジェクト: ModelDBRepository/183014
#
# Script code (run always)
#

# Load the sys and os packages.
import sys, os

# Load the interpreter object.
from neuron import h

# Load the NEURON GUI.
if use_NEURON_GUI:
    from neuron import gui

# Load default parameters and initialize the network.
h.xopen("main.hoc")

# Load functions for interfacing with hoc data structures.
from hocinterface import *

# Load the neuroplot namespace.
from neuroplot import *

# Load the numpy namespace.
from numpy import *

# Load analysis
from analysis import *

# Set up cellsnq and connsnq for display functions.
h('objref cellsnq')
コード例 #33
0
	stim.amp=amp
	return stim

def recvolt(seg):
	rec_v=neuron.h.Vector()
	rec_v.record(seg._ref_v)
	return rec_v

def rectime(seg):
	rec_t=neuron.h.Vector()
	rec_t.record(seg._ref_t)
	return rec_t

load_mechanisms('/home/ben/Desktop/5ht3a_project/neuron_model/downloaded_neuron_models/Hipp_paper_code/')

h.xopen('/home/ben/Desktop/5ht3a_project/neuron_model/downloaded_neuron_models/Hipp_paper_code/basket_cell17S.hoc')
h.xopen('/home/ben/Desktop/5ht3a_project/neuron_model/downloaded_neuron_models/Hipp_paper_code/pyramidal_cell_14Vb.hoc')
h.xopen('/home/ben/Desktop/5ht3a_project/neuron_model/downloaded_neuron_models/Hipp_paper_code/olm_cell2.hoc')


pyrstren=np.arange(.005,.01,.001)
pvstren=np.arange(0,0.3,.05)


olmexcstren=np.arange(.05,.055,.001)
olmstren=np.arange(.04,.05,.002)
olmcombs=itertools.product(olmexcstren,olmstren)
pvpyrcombs=itertools.product(pyrstren,pvstren)

numiter=100
ppp=1
コード例 #34
0
ファイル: sim_demo.py プロジェクト: ModelDBRepository/183014
#
# Script code (run always)
#

# Load the sys and os packages.
import sys, os

# Load the interpreter object.
from neuron import h

# Load the NEURON GUI.
if use_NEURON_GUI:
   from neuron import gui

# Load default parameters and initialize the network.
h.xopen("main_demo.hoc")

# Load functions for interfacing with hoc data structures.
from hocinterface import *

# Load the neuroplot namespace.
from neuroplot import *

# Load the numpy namespace.
from numpy import *

# Load analysis
from analysis import *


# Set up cellsnq and connsnq for display functions. 
コード例 #35
0
ファイル: measure_trees.py プロジェクト: pramodk/dentate
def main(config, template_path, output_path, forest_path, populations, io_size,
         chunk_size, value_chunk_size, cache_size, verbose):
    """

    :param config:
    :param template_path:
    :param forest_path:
    :param populations:
    :param io_size:
    :param chunk_size:
    :param value_chunk_size:
    :param cache_size:
    """

    utils.config_logging(verbose)
    logger = utils.get_script_logger(script_name)

    comm = MPI.COMM_WORLD
    rank = comm.rank

    env = Env(comm=MPI.COMM_WORLD,
              config_file=config,
              template_paths=template_path)
    h('objref nil, pc, templatePaths')
    h.load_file("nrngui.hoc")
    h.load_file("./templates/Value.hoc")
    h.xopen("./lib.hoc")
    h.pc = h.ParallelContext()

    if io_size == -1:
        io_size = comm.size
    if rank == 0:
        logger.info('%i ranks have been allocated' % comm.size)

    h.templatePaths = h.List()
    for path in env.templatePaths:
        h.templatePaths.append(h.Value(1, path))

    if output_path is None:
        output_path = forest_path

    if rank == 0:
        if not os.path.isfile(output_path):
            input_file = h5py.File(forest_path, 'r')
            output_file = h5py.File(output_path, 'w')
            input_file.copy('/H5Types', output_file)
            input_file.close()
            output_file.close()
    comm.barrier()

    (pop_ranges, _) = read_population_ranges(forest_path, comm=comm)
    start_time = time.time()
    for population in populations:
        logger.info('Rank %i population: %s' % (rank, population))
        count = 0
        (population_start, _) = pop_ranges[population]
        template_name = env.celltypes[population]['template']
        h.find_template(h.pc, h.templatePaths, template_name)
        template_class = eval('h.%s' % template_name)
        measures_dict = {}
        for gid, morph_dict in NeuroH5TreeGen(forest_path,
                                              population,
                                              io_size=io_size,
                                              comm=comm,
                                              topology=True):
            if gid is not None:
                logger.info('Rank %i gid: %i' % (rank, gid))
                cell = cells.make_neurotree_cell(template_class,
                                                 neurotree_dict=morph_dict,
                                                 gid=gid)
                secnodes_dict = morph_dict['section_topology']['nodes']

                apicalidx = set(cell.apicalidx)
                basalidx = set(cell.basalidx)

                dendrite_area_dict = {k + 1: 0.0 for k in range(0, 4)}
                dendrite_length_dict = {k + 1: 0.0 for k in range(0, 4)}
                for (i, sec) in enumerate(cell.sections):
                    if (i in apicalidx) or (i in basalidx):
                        secnodes = secnodes_dict[i]
                        prev_layer = None
                        for seg in sec.allseg():
                            L = seg.sec.L
                            nseg = seg.sec.nseg
                            seg_l = old_div(L, nseg)
                            seg_area = h.area(seg.x)
                            layer = cells.get_node_attribute(
                                'layer', morph_dict, seg.sec, secnodes, seg.x)
                            layer = layer if layer > 0 else (
                                prev_layer if prev_layer is not None else 1)
                            prev_layer = layer
                            dendrite_length_dict[layer] += seg_l
                            dendrite_area_dict[layer] += seg_area

                measures_dict[gid] = { 'dendrite_area': np.asarray([ dendrite_area_dict[k] for k in sorted(dendrite_area_dict.keys()) ], dtype=np.float32), \
                                       'dendrite_length': np.asarray([ dendrite_length_dict[k] for k in sorted(dendrite_length_dict.keys()) ], dtype=np.float32) }

                del cell
                count += 1
            else:
                logger.info('Rank %i gid is None' % rank)
        append_cell_attributes(output_path,
                               population,
                               measures_dict,
                               namespace='Tree Measurements',
                               comm=comm,
                               io_size=io_size,
                               chunk_size=chunk_size,
                               value_chunk_size=value_chunk_size,
                               cache_size=cache_size)
    MPI.Finalize()
コード例 #36
0
ファイル: cable.py プロジェクト: prcastro/LasconVI
#!/usr/bin/env python

# run using command line: 'python -i cable.py'

from neuron import gui, h  # h stands for hoc

# create the cable
cable = h.Section()  # the name here is used for graphics but doesn't produce a hoc pointer
cable.L, cable.diam, cable.nseg = 10000, 1, 1001 # microns, microns, num
cable.insert('hh')  # this is a SECTION level call that puts 'pas' into all of the 1001 SEGMENTs
# cable.g_pas, cable.e_pas = 1/20000.0, -65  # 1/(Ohm cm^2) = Siemens/cm^2, mV;  this access will set all of the segments

cabref = h.SectionRef(sec=cable)  # a workaround to end up with a hoc object that points to the python object
h('objref cable')  # creates the object reference in hoc
h.cable=cabref     # aligns the pointers; if had a hoc file that defined the cell would go other direction

h.xopen("cable.ses")

# here's a more pythonic way to set pas params that accesses segments via dot notation
# def setpas (sec, gpas=1/20000, epas=-65):  # provide defaults
#     for seg in sec:                        # iterate over all of the segments in a section
#         seg.pas.g, seg.pas.e = gpas, epas  # this is the more pythonic segmentwise way to do this
#
# setpas(cable)