def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    C = moose.Pool(compt.path + '/C')
    D = moose.Pool(compt.path + '/D')
    E = moose.Pool(compt.path + '/E')
    F = moose.Pool(compt.path + '/F')
    Z1 = moose.Pool(compt.path + '/Z1')
    Z2 = moose.Pool(compt.path + '/Z2')

    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Cdot = moose.Function(C.path + '/Cdot')
    Ddot = moose.Function(D.path + '/Ddot')
    Edot = moose.Function(E.path + '/Edot')
    Fdot = moose.Function(F.path + '/Fdot')
    #Zdot = moose.Function( Z.path + '/Zdot' )

    #Adot.expr="x6*(1+x7)*(-x0+(5/(1+x1^3))*(2-x0-x3))"
    #Bdot.expr="x6*(1+x7)*(0*x0-x1+(3+2*(x2^3/(1+x1^3)))*(1/(1+x0^3))*(2-x1-x4))"
    #Cdot.expr="x6*(1+x7)*(0*x0+0*x1-0*x2+0.1*((0.2+0.3*(x0^3/(0.85^3+x0^3)))-x2^2*(0.2+1*x1^3/(0.85^3+x1^3))))"

    Adot.expr = "x6*(1+x7)*(-x0+(4.5/(1+x1^3))*(2-x0-x3))"
    Bdot.expr = "x6*(1+x7)*(0*x0-x1+(3+0.5*(x2^3/(1+x2^3)))*(1/(1+x0^3))*(2-x1-x4))"
    Cdot.expr = "x6*(1+x7)*(0*x0+0*x1-0*x2+0.5*((0.2+0.3*(x0^3/(0.85^3+x0^3)))-x2^2*(0.2+1*x1^3/(0.85^3+x1^3))))"

    #Ddot.expr="(1+x6)*x7*(0*x0+0*x1+0*x2-x3+(5/(1+x4^3))*(2-x0-x3))"
    #Edot.expr="(1+x6)*x7*(0*x0+0*x1+0*x2+0*x3-x4+(3+2*(x5^3/(1+x4^3)))*(1/(1+x3^3))*(2-x1-x4))"
    #Fdot.expr="(1+x6)*x7*(0*x0+0*x1+0*x2+0*x3+0*x4-0*x5+0.1*((0.2+0.3*(x3^3/(0.85^3+x3^3)))-x5^2*(0.2+1*x4^3/(0.85^3+x4^3))))"

    Ddot.expr = "(1+x6)*x7*(0*x0+0*x1+0*x2-x3+(4.5/(1+x4^3))*(2-x0-x3))"
    Edot.expr = "(1+x6)*x7*(0*x0+0*x1+0*x2+0*x3-x4+(3+0.5*(x5^3/(1+x5^3)))*(1/(1+x3^3))*(2-x1-x4))"
    Fdot.expr = "(1+x6)*x7*(0*x0+0*x1+0*x2+0*x3+0*x4-0*x5+0.5*((0.2+0.3*(x3^3/(0.85^3+x3^3)))-x5^2*(0.2+1*x4^3/(0.85^3+x4^3))))"

    print moose.showmsg(Adot)
    Adot.x.num = 8  #2
    Bdot.x.num = 8  #2
    Cdot.x.num = 8  #2
    Ddot.x.num = 8  #2
    Edot.x.num = 8  #2
    Fdot.x.num = 8  #2
    #A.nInit=10
    #B.nInit=5
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(C, 'nOut', Adot.x[2], 'input')
    moose.connect(D, 'nOut', Adot.x[3], 'input')
    moose.connect(E, 'nOut', Adot.x[4], 'input')
    moose.connect(F, 'nOut', Adot.x[5], 'input')
    moose.connect(Z1, 'nOut', Adot.x[6], 'input')
    moose.connect(Z2, 'nOut', Adot.x[7], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(C, 'nOut', Bdot.x[2], 'input')
    moose.connect(D, 'nOut', Bdot.x[3], 'input')
    moose.connect(E, 'nOut', Bdot.x[4], 'input')
    moose.connect(F, 'nOut', Bdot.x[5], 'input')
    moose.connect(Z1, 'nOut', Bdot.x[6], 'input')
    moose.connect(Z2, 'nOut', Bdot.x[7], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    moose.connect(A, 'nOut', Cdot.x[0], 'input')
    moose.connect(B, 'nOut', Cdot.x[1], 'input')
    moose.connect(C, 'nOut', Cdot.x[2], 'input')
    moose.connect(D, 'nOut', Cdot.x[3], 'input')
    moose.connect(E, 'nOut', Cdot.x[4], 'input')
    moose.connect(F, 'nOut', Cdot.x[5], 'input')
    moose.connect(Z1, 'nOut', Cdot.x[6], 'input')
    moose.connect(Z2, 'nOut', Cdot.x[7], 'input')
    moose.connect(Cdot, 'valueOut', C, 'increment')

    moose.connect(A, 'nOut', Ddot.x[0], 'input')
    moose.connect(B, 'nOut', Ddot.x[1], 'input')
    moose.connect(C, 'nOut', Ddot.x[2], 'input')
    moose.connect(D, 'nOut', Ddot.x[3], 'input')
    moose.connect(E, 'nOut', Ddot.x[4], 'input')
    moose.connect(F, 'nOut', Ddot.x[5], 'input')
    moose.connect(Z1, 'nOut', Ddot.x[6], 'input')
    moose.connect(Z2, 'nOut', Ddot.x[7], 'input')
    moose.connect(Ddot, 'valueOut', D, 'increment')

    moose.connect(A, 'nOut', Edot.x[0], 'input')
    moose.connect(B, 'nOut', Edot.x[1], 'input')
    moose.connect(C, 'nOut', Edot.x[2], 'input')
    moose.connect(D, 'nOut', Edot.x[3], 'input')
    moose.connect(E, 'nOut', Edot.x[4], 'input')
    moose.connect(F, 'nOut', Edot.x[5], 'input')
    moose.connect(Z1, 'nOut', Edot.x[6], 'input')
    moose.connect(Z2, 'nOut', Edot.x[7], 'input')
    moose.connect(Edot, 'valueOut', E, 'increment')

    moose.connect(A, 'nOut', Fdot.x[0], 'input')
    moose.connect(B, 'nOut', Fdot.x[1], 'input')
    moose.connect(C, 'nOut', Fdot.x[2], 'input')
    moose.connect(D, 'nOut', Fdot.x[3], 'input')
    moose.connect(E, 'nOut', Fdot.x[4], 'input')
    moose.connect(F, 'nOut', Fdot.x[5], 'input')
    moose.connect(Z1, 'nOut', Fdot.x[6], 'input')
    moose.connect(Z2, 'nOut', Fdot.x[7], 'input')
    moose.connect(Fdot, 'valueOut', F, 'increment')
    return compt
コード例 #2
0
ファイル: class_9_concise.py プロジェクト: jkopsick/NEUR634
import moose
import util as u
import pylab as plt
import numpy as np

neuron = moose.Neutral('/neuron')
spikegen = moose.SpikeGen('/neuron/spikegen')
spikegen.threshold = 0.0
spikegen.refractT = 1e-3
soma_l = 30e-6
soma_rad = 10e-6
dend_l = 100e-6
dend_rad = 1e-6
RM = 2
CM = 0.01
RA = 10
Em = -65e-3
pulse_dur = 100e-3
pulse_amp = 0.1e-9
pulse_delay = 50e-3
pulse_delay2 = 1e9
soma = u.createCompartment(neuron, 'swagginSoma', soma_l, soma_rad, RM, CM, RA,
                           Em, Em)
dend = u.createCompartment(neuron, 'swagginDend', dend_l, dend_rad, RM, CM, RA,
                           Em, Em)
moose.connect(soma, 'axialOut', dend, 'handleAxial')

# Create data tables to store the voltage for the soma and each compartment
# making up the dendritic branch
data = moose.Neutral('/data')
soma_pulse = u.createPulse(soma, 'rollingWave', pulse_dur, pulse_amp,
コード例 #3
0
def makeElecPlots():
    graphs = moose.Neutral('/graphs')
    elec = moose.Neutral('/graphs/elec')
    addPlot('/model/elec/soma', 'getVm', 'elec/somaVm')
    addPlot('/model/elec/spine_head_14_4', 'getVm', 'elec/spineVm')
コード例 #4
0
    filemode='w')
# logging.basicConfig(level=LOG_LEVEL, format='%(asctime)s %(levelname)s %(name)s %(filename)s %(funcName)s: %(message)s', filemode='w')

logger = logging.getLogger('traub2005')

# Add a logging handler to print messages to stderr
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
# create formatter and add it to the handlers
formatter = logging.Formatter(
    '%(asctime)s %(name)s %(levelname)s %(filename)s %(funcName)s: %(message)s'
)
ch.setFormatter(formatter)
# add the handlers to logger
logger.addHandler(ch)

import os

os.environ['NUMPTHREADS'] = '1'
import sys

sys.path.append('../../../python')
import moose
############################################################
# Initialize library and other containers.
############################################################
library = moose.Neutral(modelSettings.libpath)

#
# config.py ends here
コード例 #5
0
ファイル: MorphML.py プロジェクト: Vio8023/moose
    def readMorphML(self, cell, params={}, lengthUnits="micrometer"):
        """
        returns cellDict = { cellname: (segDict, cableDict) } # note: single cell only
        where segDict = { segid1 : [ segname,(proximalx,proximaly,proximalz),
            (distalx,distaly,distalz),diameter,length,[potential_syn1, ... ] ] , ... }
        segname is "<name>_<segid>" because 1) guarantees uniqueness,
            & 2) later scripts obtain segid from the compartment's name!
        and cableDict = { cablegroupname : [campartment1name, compartment2name, ... ], ... }
        """
        if lengthUnits in ['micrometer', 'micron']:
            self.length_factor = 1e-6
        else:
            self.length_factor = 1.0
        cellname = cell.attrib["name"]
        moose.Neutral(
            '/library')  # creates /library in MOOSE tree; elif present, wraps
        pu.info("Loading cell %s into /library ." % cellname)

        #~ moosecell = moose.Cell('/library/'+cellname)
        #using moose Neuron class - in previous version 'Cell' class Chaitanya
        moosecell = moose.Neuron('/library/' + cellname)
        self.cellDictBySegmentId[cellname] = [moosecell, {}]
        self.cellDictByCableId[cellname] = [moosecell, {}]
        self.segDict = {}
        if 'combineSegments' in list(params.keys()):
            self.combineSegments = params['combineSegments']
        else:
            self.combineSegments = False
        if 'createPotentialSynapses' in list(params.keys()):
            self.createPotentialSynapses = params['createPotentialSynapses']
        else:
            self.createPotentialSynapses = False
        pu.info("readMorphML using combineSegments = %s" %
                self.combineSegments)

        ###############################################
        #### load cablegroups into a dictionary
        self.cablegroupsDict = {}
        ## Two ways of specifying cablegroups in neuroml 1.x
        ## <cablegroup>s with list of <cable>s
        cablegroups = cell.findall(".//{" + self.mml + "}cablegroup")
        for cablegroup in cablegroups:
            cablegroupname = cablegroup.attrib['name']
            self.cablegroupsDict[cablegroupname] = []
            for cable in cablegroup.findall(".//{" + self.mml + "}cable"):
                cableid = cable.attrib['id']
                self.cablegroupsDict[cablegroupname].append(cableid)
        ## <cable>s with list of <meta:group>s
        cables = cell.findall(".//{" + self.mml + "}cable")
        for cable in cables:
            cableid = cable.attrib['id']
            cablegroups = cable.findall(".//{" + self.meta + "}group")
            for cablegroup in cablegroups:
                cablegroupname = cablegroup.text
                if cablegroupname in list(self.cablegroupsDict.keys()):
                    self.cablegroupsDict[cablegroupname].append(cableid)
                else:
                    self.cablegroupsDict[cablegroupname] = [cableid]

        ###################################################
        ## load all mechanisms in this cell into /library for later copying
        ## set which compartments have integrate_and_fire mechanism
        self.intFireCableIds = {
        }  # dict with keys as Compartments/cableIds which are IntFire
        # with mechanismnames as values
        for mechanism in cell.findall(".//{" + self.bio + "}mechanism"):
            mechanismname = mechanism.attrib["name"]
            passive = False
            if "passive_conductance" in mechanism.attrib:
                if mechanism.attrib['passive_conductance'] in [
                        "true", 'True', 'TRUE'
                ]:
                    passive = True
            if not passive:
                ## if channel does not exist in library load it from xml file
                if not moose.exists("/library/" + mechanismname):
                    pu.info("Loading mechanism %s into library." %
                            mechanismname)
                    cmlR = ChannelML(self.nml_params)
                    model_filename = mechanismname + '.xml'
                    model_path = neuroml_utils.find_first_file(
                        model_filename, self.model_dir)
                    if model_path is not None:
                        cmlR.readChannelMLFromFile(model_path)
                    else:
                        raise IOError(
                            'For mechanism {0}: files {1} not found under {2}.'
                            .format(mechanismname, model_filename,
                                    self.model_dir))

                    ## set those compartments to be LIF for which
                    ## any integrate_and_fire parameter is set
                    if not moose.exists("/library/" + mechanismname):
                        print "Mechanism doesn't exist: ", mechanismname
                        moose.le('/library')
                    moosemech = moose.element("/library/" + mechanismname)
                    if moose.exists(moosemech.path + "/integrate_and_fire"):
                        mooseIaF = moose.element(
                            moosemech.path + "/integrate_and_fire")  # Mstring
                        if mooseIaF.value in ['true', 'True', 'TRUE']:
                            mech_params = mechanism.findall(".//{" + self.bio +
                                                            "}parameter")
                            for parameter in mech_params:
                                parametername = parameter.attrib['name']
                                ## check for the integrate_and_fire parameters
                                if parametername in [
                                        'threshold', 't_refrac', 'v_reset',
                                        'g_refrac'
                                ]:
                                    for group in parameter.findall(".//{" +
                                                                   self.bio +
                                                                   "}group"):
                                        cablegroupname = group.text
                                        if cablegroupname == 'all':
                                            self.intFireCableIds = {
                                                'all': mechanismname
                                            }
                                            break
                                        else:
                                            for cableid in self.cablegroupsDict[
                                                    cablegroupname]:
                                                ## only one intfire mechanism is allowed in a cable
                                                ## the last one parsed will override others
                                                self.intFireCableIds[
                                                    cableid] = mechanismname
                                if 'all' in list(self.intFireCableIds.keys()):
                                    break

        ############################################################
        #### load morphology and connections between compartments
        ## Many neurons exported from NEURON have multiple segments in a section
        ## If self.combineSegments = True,
        ##  then combine those segments into one Compartment / section
        ##  for combining, assume segments of a compartment/section are in increasing order
        ##  and assume all segments of a compartment/section have the same cableid
        ## findall() returns elements in document order:
        running_cableid = ''
        running_segid = ''
        running_comp = None
        running_diameter = 0.0
        running_dia_nums = 0
        segments = cell.findall(".//{" + self.mml + "}segment")
        segmentstotal = len(segments)
        for segnum, segment in enumerate(segments):
            segmentname = segment.attrib['name']
            ## cable is an optional attribute. WARNING: Here I assume it is always present.
            cableid = segment.attrib['cable']
            segmentid = segment.attrib['id']
            ## if old cableid still running AND self.combineSegments == True,
            ## then don't start a new compartment, skip to next segment
            if cableid == running_cableid and self.combineSegments:
                self.cellDictBySegmentId[cellname][1][segmentid] = running_comp
                proximal = segment.find('./{' + self.mml + '}proximal')
                if proximal is not None:
                    running_diameter += float(
                        proximal.attrib["diameter"]) * self.length_factor
                    running_dia_nums += 1
                distal = segment.find('./{' + self.mml + '}distal')
                if distal is not None:
                    running_diameter += float(
                        distal.attrib["diameter"]) * self.length_factor
                    running_dia_nums += 1
            ## if (self.combineSegments and new cableid starts) or if not self.combineSegments,
            ##  then start a new compartment
            else:
                ## Create a new compartment
                ## the moose "hsolve" method assumes compartments to be
                ## asymmetric compartments and symmetrizes them
                ## but that is not what we want when translating
                ## from Neuron which has only symcompartments -- so be careful!

                ## Check if integrate_and_fire mechanism is present,
                ## if so use LIF instead of Compartment
                moosecompname = segmentname + '_' + segmentid  # just segmentname is NOT unique
                # eg: mitral bbmit exported from NEURON
                moosecomppath = moosecell.path + '/' + moosecompname
                IntFireIds = list(self.intFireCableIds.keys())
                mechanismname = None
                if 'all' in IntFireIds:
                    mechanismname = self.intFireCableIds['all']
                if cableid in IntFireIds:
                    mechanismname = self.intFireCableIds[cableid]
                if mechanismname is not None:  # this cableid is an intfire
                    ## create LIF (subclass of Compartment) and set to default values
                    moosecomp = moose.LIF(moosecomppath)
                    moosechannel = moose.Neutral('/library/' + mechanismname)
                    moosechannelval = moose.Mstring(moosechannel.path +
                                                    '/vReset')
                    moosecomp.vReset = moosechannelval.value
                    moosechannelval = moose.Mstring(moosechannel.path +
                                                    '/thresh')
                    moosecomp.thresh = moosechannelval.value
                    moosechannelval = moose.Mstring(moosechannel.path +
                                                    '/refracT')
                    moosecomp.refractoryPeriod = moosechannelval.value
                    ## refracG is currently not supported by moose.LIF
                    ## when you implement it, check if refracG or g_refrac
                    ## is a conductance density or a conductance, I think the former
                    #moosechannelval = moose.Mstring(moosechannel.path+'/refracG')
                else:
                    moosecomp = moose.Compartment(moosecomppath)
                self.cellDictBySegmentId[cellname][1][segmentid] = moosecomp
                ## cables are grouped and mechanism densities are set for cablegroups later.
                ## hence I will need to refer to segment according to which cable it belongs to.
                ## if combineSegments is False, there can be multiple segments per cable,
                ##  so make array of compartments for cellDictByCableId[cellname][1][cableid]
                if cableid in list(self.cellDictByCableId[cellname][1].keys()):
                    self.cellDictByCableId[cellname][1][cableid].append(
                        moosecomp)
                else:
                    self.cellDictByCableId[cellname][1][cableid] = [moosecomp]
                running_cableid = cableid
                running_segid = segmentid
                running_comp = moosecomp
                running_diameter = 0.0
                running_dia_nums = 0
                if 'parent' in segment.attrib:
                    parentid = segment.attrib[
                        'parent']  # I assume the parent is created before the child
                    # so that I can immediately connect the child.
                    parent = self.cellDictBySegmentId[cellname][1][parentid]
                    ## It is always assumed that axial of parent is connected to raxial of moosesegment
                    ## THIS IS WHAT GENESIS readcell() DOES!!! UNLIKE NEURON!
                    ## THIS IS IRRESPECTIVE OF WHETHER PROXIMAL x,y,z OF PARENT = PROXIMAL x,y,z OF CHILD.
                    ## THIS IS ALSO IRRESPECTIVE OF fraction_along_parent SPECIFIED IN CABLE!
                    ## THUS THERE WILL BE NUMERICAL DIFFERENCES BETWEEN MOOSE/GENESIS and NEURON.
                    ## moosesegment sends Ra and Vm to parent, parent sends only Vm
                    ## actually for symmetric compartment, both parent and moosesegment require each other's Ra/2,
                    ## but axial and raxial just serve to distinguish ends.
                    moose.connect(parent, 'axial', moosecomp, 'raxial')
                else:
                    parent = None
                proximal = segment.find('./{' + self.mml + '}proximal')
                if proximal is None:  # If proximal tag is not present,
                    # then parent attribute MUST be present in the segment tag!
                    ## if proximal is not present, then
                    ## by default the distal end of the parent is the proximal end of the child
                    moosecomp.x0 = parent.x
                    moosecomp.y0 = parent.y
                    moosecomp.z0 = parent.z
                else:
                    moosecomp.x0 = float(
                        proximal.attrib["x"]) * self.length_factor
                    moosecomp.y0 = float(
                        proximal.attrib["y"]) * self.length_factor
                    moosecomp.z0 = float(
                        proximal.attrib["z"]) * self.length_factor
                    running_diameter += float(
                        proximal.attrib["diameter"]) * self.length_factor
                    running_dia_nums += 1
                distal = segment.find('./{' + self.mml + '}distal')
                if distal is not None:
                    running_diameter += float(
                        distal.attrib["diameter"]) * self.length_factor
                    running_dia_nums += 1
                ## finished creating new compartment

            ## Update the end position, diameter and length, and segDict of this comp/cable/section
            ## with each segment that is part of this cable (assumes contiguous segments in xml).
            ## This ensures that we don't have to do any 'closing ceremonies',
            ## if a new cable is encoutered in next iteration.
            if distal is not None:
                running_comp.x = float(distal.attrib["x"]) * self.length_factor
                running_comp.y = float(distal.attrib["y"]) * self.length_factor
                running_comp.z = float(distal.attrib["z"]) * self.length_factor
            ## Set the compartment diameter as the average diameter of all the segments in this section
            running_comp.diameter = running_diameter / float(running_dia_nums)
            ## Set the compartment length
            running_comp.length = math.sqrt((running_comp.x-running_comp.x0)**2+\
                (running_comp.y-running_comp.y0)**2+(running_comp.z-running_comp.z0)**2)
            ## NeuroML specs say that if (x0,y0,z0)=(x,y,z), then round compartment e.g. soma.
            ## In Moose set length = dia to give same surface area as sphere of dia.
            if running_comp.length == 0.0:
                running_comp.length = running_comp.diameter
            ## Set the segDict
            ## the empty list at the end below will get populated
            ## with the potential synapses on this segment, in function set_compartment_param(..)
            self.segDict[running_segid] = [running_comp.name,\
                (running_comp.x0,running_comp.y0,running_comp.z0),\
                (running_comp.x,running_comp.y,running_comp.z),\
                running_comp.diameter,running_comp.length,[]]
            if neuroml_utils.neuroml_debug:
                pu.info('Set up compartment/section %s' % running_comp.name)

        ###############################################
        #### load biophysics into the compartments
        biophysics = cell.find(".//{" + self.neuroml + "}biophysics")
        if biophysics is not None:
            ## see pg 219 (sec 13.2) of Book of Genesis for Physiological Units
            if biophysics.attrib["units"] == 'Physiological Units':
                CMfactor = 1e-2  # F/m^2 from microF/cm^2
                Cfactor = 1e-6  # F from microF
                RAfactor = 1e1  # Ohm*m from KOhm*cm
                RMfactor = 1e-1  # Ohm*m^2 from KOhm*cm^2
                Rfactor = 1e-3  # Ohm from KOhm
                Efactor = 1e-3  # V from mV
                Gfactor = 1e1  # S/m^2 from mS/cm^2
                Ifactor = 1e-6  # A from microA
                Tfactor = 1e-3  # s from ms
            else:
                CMfactor = 1.0
                Cfactor = 1.0
                RAfactor = 1.0
                RMfactor = 1.0
                Rfactor = 1.0
                Efactor = 1.0
                Gfactor = 1.0
                Ifactor = 1.0
                Tfactor = 1.0

            spec_capacitance = cell.find(".//{" + self.bio +
                                         "}spec_capacitance")
            for parameter in spec_capacitance.findall(".//{" + self.bio +
                                                      "}parameter"):
                self.set_group_compartment_param(cell, cellname, parameter,\
                 'CM', float(parameter.attrib["value"])*CMfactor, self.bio)
            spec_axial_resitance = cell.find(".//{" + self.bio +
                                             "}spec_axial_resistance")
            for parameter in spec_axial_resitance.findall(".//{" + self.bio +
                                                          "}parameter"):
                self.set_group_compartment_param(cell, cellname, parameter,\
                 'RA', float(parameter.attrib["value"])*RAfactor, self.bio)
            init_memb_potential = cell.find(".//{" + self.bio +
                                            "}init_memb_potential")
            for parameter in init_memb_potential.findall(".//{" + self.bio +
                                                         "}parameter"):
                self.set_group_compartment_param(cell, cellname, parameter,\
                 'initVm', float(parameter.attrib["value"])*Efactor, self.bio)
            for mechanism in cell.findall(".//{" + self.bio + "}mechanism"):
                mechanismname = mechanism.attrib["name"]
                passive = False
                if "passive_conductance" in mechanism.attrib:
                    if mechanism.attrib['passive_conductance'] in [
                            "true", 'True', 'TRUE'
                    ]:
                        passive = True
                pu.info("Loading mechanism %s " % mechanismname)
                ## ONLY creates channel if at least one parameter (like gmax) is specified in the xml
                ## Neuroml does not allow you to specify all default values.
                ## However, granule cell example in neuroconstruct has Ca ion pool without
                ## a parameter, applying default values to all compartments!
                mech_params = mechanism.findall(".//{" + self.bio +
                                                "}parameter")
                ## if no params, apply all default values to all compartments
                if len(mech_params) == 0:
                    for compartment_list in list(
                            self.cellDictByCableId[cellname][1].values()):
                        for compartment in compartment_list:
                            self.set_compartment_param(compartment, None,
                                                       'default',
                                                       mechanismname)
                ## if params are present, apply params to specified cable/compartment groups
                for parameter in mech_params:
                    parametername = parameter.attrib['name']
                    if passive:
                        if parametername in ['gmax']:
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             'RM', RMfactor*1.0/float(parameter.attrib["value"]), self.bio)
                        elif parametername in ['e', 'erev']:
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             'Em', Efactor*float(parameter.attrib["value"]), self.bio)
                        elif parametername in ['inject']:
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             'inject', Ifactor*float(parameter.attrib["value"]), self.bio)
                        else:
                            pu.warn([
                                "Yo programmer of MorphML! You didn't",
                                " implement parameter %s " % parametername,
                                " in mechanism %s " % mechanismname
                            ])
                    else:
                        if parametername in ['gmax']:
                            gmaxval = float(
                                eval(parameter.attrib["value"],
                                     {"__builtins__": None}, {}))
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             'Gbar', Gfactor*gmaxval, self.bio, mechanismname)
                        elif parametername in ['e', 'erev']:
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             'Ek', Efactor*float(parameter.attrib["value"]), self.bio, mechanismname)
                        elif parametername in [
                                'depth'
                        ]:  # has to be type Ion Concentration!
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             'thick', self.length_factor*float(parameter.attrib["value"]),\
                             self.bio, mechanismname)
                        elif parametername in ['v_reset']:
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             'v_reset', Efactor*float(parameter.attrib["value"]),\
                             self.bio, mechanismname)
                        elif parametername in ['threshold']:
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             'threshold', Efactor*float(parameter.attrib["value"]),\
                             self.bio, mechanismname)
                        elif parametername in ['t_refrac']:
                            self.set_group_compartment_param(cell, cellname, parameter,\
                             't_refrac', Tfactor*float(parameter.attrib["value"]),\
                             self.bio, mechanismname)
                        else:
                            pu.warn([
                                "Yo programmer of MorphML import! You didn't",
                                " implement parameter %s " % parametername,
                                " in mechanism %s " % mechanismname
                            ])
            #### Connect the Ca pools and channels
            #### Am connecting these at the very end so that all channels and pools have been created
            #### Note: this function is in moose.utils not moose.neuroml.utils !
            for compartment_list in list(
                    self.cellDictByCableId[cellname][1].values()):
                moose_utils.connect_CaConc(compartment_list,\
                    self.temperature+neuroml_utils.ZeroCKelvin) # temperature should be in Kelvin for Nernst

        ##########################################################
        #### load connectivity / synapses into the compartments
        connectivity = cell.find(".//{" + self.neuroml + "}connectivity")
        if connectivity is not None:
            for potential_syn_loc in cell.findall(".//{" + self.nml +
                                                  "}potential_syn_loc"):
                if 'synapse_direction' in list(
                        potential_syn_loc.attrib.keys()):
                    if potential_syn_loc.attrib['synapse_direction'] in [
                            'post', 'preAndOrPost'
                    ]:
                        self.set_group_compartment_param(cell, cellname, potential_syn_loc,\
                            'synapse_type', potential_syn_loc.attrib['synapse_type'],\
                            self.nml, mechanismname='synapse')
                    if potential_syn_loc.attrib['synapse_direction'] in [
                            'pre', 'preAndOrPost'
                    ]:
                        self.set_group_compartment_param(cell, cellname, potential_syn_loc,\
                            'spikegen_type', potential_syn_loc.attrib['synapse_type'],\
                            self.nml, mechanismname='spikegen')

        ##########################################################
        #### annotate each compartment with the cablegroups it belongs to
        self.cableDict = {}
        for cablegroupname in list(self.cablegroupsDict.keys()):
            comp_list = []
            for cableid in self.cablegroupsDict[cablegroupname]:
                for compartment in self.cellDictByCableId[cellname][1][
                        cableid]:
                    cableStringPath = compartment.path + '/cable_groups'
                    cableString = moose.Mstring(cableStringPath)
                    if cableString.value == '':
                        cableString.value += cablegroupname
                    else:
                        cableString.value += ',' + cablegroupname
                    comp_list.append(compartment.name)
            self.cableDict[cablegroupname] = comp_list

        pu.info("Finished loading into library, cell: %s " % cellname)
        return {cellname: (self.segDict, self.cableDict)}
コード例 #6
0
ファイル: config.py プロジェクト: salthcl/thalamocortical
    os.mkdir(data_dir)

filename_suffix = '_%s_%d' % (timestamp.strftime('%Y%m%d_%H%M%S'), mypid)
DATA_FILENAME = os.path.join(data_dir, 'data%s.h5' % (filename_suffix))
MODEL_FILENAME = os.path.join(data_dir, 'network%s.h5' % (filename_suffix))

LOGGER = logging.getLogger('traub2005')
BENCHMARK_LOGGER = logging.getLogger('traub2005.benchmark')
BENCHMARK_LOGGER.setLevel(logging.DEBUG)
benchmarking = True  # Dump benchmarking information

#---------------------------------------------------------------------
# moose components
#---------------------------------------------------------------------
context = moose.PyMooseBase.getContext()
lib = moose.Neutral('/library')
root = moose.Neutral("/")
clockjob = moose.ClockJob('sched/cj')
clockjob.autoschedule = 1
solver = 'hsolve'
simdt = 0.5e-4
plotdt = 1e-3
gldt = 1e-2
vmin = -120e-3
vmax = 40e-3
ndivs = 640
dv = (vmax - vmin) / ndivs
channel_name_list = [
    'AR', 'CaPool', 'CaL', 'CaT', 'CaT_A', 'K2', 'KA', 'KA_IB', 'KAHP',
    'KAHP_DP', 'KAHP_SLOWER', 'KC', 'KC_FAST', 'KDR', 'KDR_FS', 'KM', 'NaF',
    'NaF2', 'NaF_TCR', 'NaP', 'NaPF', 'NaPF_SS', 'NaPF_TCR', 'NaF2_nRT'
コード例 #7
0
def vclamp_demo(simtime=50.0, dt=1e-2):
    ## It is good practice to modularize test elements inside a
    ## container
    container = moose.Neutral('/vClampDemo')
    ## Create a compartment with properties of a squid giant axon
    comp = SquidAxon('/vClampDemo/axon')
    # Create and setup the voltage clamp object
    clamp = moose.VClamp('/vClampDemo/vclamp')
    ## The defaults should work fine
    # clamp.mode = 2
    # clamp.tau = 10*dt
    # clamp.ti = dt
    # clamp.td = 0
    # clamp.gain = comp.Cm / dt
    ## Setup command voltage time course
    command = moose.PulseGen('/vClampDemo/command')
    command.delay[0] = 10.0
    command.width[0] = 20.0
    command.level[0] = 50.0
    command.delay[1] = 1e9
    moose.connect(command, 'output', clamp, 'commandIn')
    ## Connect the Voltage Clamp to the compartemnt
    moose.connect(clamp, 'currentOut', comp, 'injectMsg')
    moose.connect(comp, 'VmOut', clamp, 'sensedIn')
    ## setup stimulus recroding - this is the command pulse
    stimtab = moose.Table('/vClampDemo/vclamp_command')
    moose.connect(stimtab, 'requestOut', command, 'getOutputValue')
    ## Set up Vm recording
    vmtab = moose.Table('/vClampDemo/vclamp_Vm')
    moose.connect(vmtab, 'requestOut', comp, 'getVm')
    ## setup command potential recording - this is the filtered input
    ## to PID controller
    commandtab = moose.Table('/vClampDemo/vclamp_filteredcommand')
    moose.connect(commandtab, 'requestOut', clamp, 'getCommand')
    ## setup current recording
    Imtab = moose.Table('/vClampDemo/vclamp_inject')
    moose.connect(Imtab, 'requestOut', clamp, 'getCurrent')
    # Scheduling
    moose.setClock(0, dt)
    moose.setClock(1, dt)
    moose.setClock(2, dt)
    moose.setClock(3, dt)
    moose.useClock(0, '%s/##[TYPE=Compartment]' % (container.path), 'init')
    moose.useClock(0, '%s/##[TYPE=PulseGen]' % (container.path), 'process')
    moose.useClock(1, '%s/##[TYPE=Compartment]' % (container.path), 'process')
    moose.useClock(2, '%s/##[TYPE=HHChannel]' % (container.path), 'process')
    moose.useClock(2, '%s/##[TYPE=VClamp]' % (container.path), 'process')
    moose.useClock(3, '%s/##[TYPE=Table]' % (container.path), 'process')
    moose.reinit()
    print 'RC filter in VClamp:: tau:', clamp.tau
    print 'PID controller in VClamp:: ti:', clamp.ti, 'td:', clamp.td, 'gain:', clamp.gain
    moose.start(simtime)
    print 'Finished simulation for %g seconds' % (simtime)
    tseries = linspace(0, simtime, len(vmtab.vector))
    subplot(211)
    title('Membrane potential and clamp voltage')
    plot(tseries, vmtab.vector, 'g-', label='Vm (mV)')
    plot(tseries, commandtab.vector, 'b-', label='Filtered command (mV)')
    plot(tseries, stimtab.vector, 'r-', label='Command (mV)')
    xlabel('Time (ms)')
    ylabel('Voltage (mV)')
    legend()
    # print len(commandtab.vector)
    subplot(212)
    title('Current through clamp circuit')
    # plot(tseries, stimtab.vector, label='stimulus (uA)')
    plot(tseries, Imtab.vector, label='injected current (uA)')
    xlabel('Time (ms)')
    ylabel('Current (uA)')
    legend()
    show()
コード例 #8
0
def create_output_table(table_element='/output', table_name='somaVm'):
    ''' Creates and returns a moose table element.
    '''
    output = moose.Neutral(table_element)
    membrane_voltage_table = moose.Table('/'.join((table_element, table_name)))
    return membrane_voltage_table
コード例 #9
0
    synH.synapse.weight = 1.0
    synH.connect('activationOut', syn, 'activation')
    print(('Synapses:', len(synH.synapse), 'w=', synH.synapse[0].weight ))

    spikegen = moose.SpikeGen('%s/spike' % (syn.parent.path))
    spikegen.edgeTriggered = False # Make it fire continuously when input is high
    spikegen.refractT = 10.0 # With this setting it will fire at 1 s / 10 ms = 100 Hz
    spikegen.threshold = 0.5
    # This will send alternatind -1 and +1 to SpikeGen to make it fire
    spike_stim = moose.PulseGen('%s/spike_stim' % (syn.parent.path))
    spike_stim.delay[0] = 1.0
    spike_stim.level[0] = 1.0
    spike_stim.width[0] = 100.0
    moose.connect(spike_stim, 'output', spikegen, 'Vm')
    m = moose.connect(spikegen, 'spikeOut', synH.synapse.vec, 'addSpike', 'Sparse')
    m.setRandomConnectivity(1.0, 1)
    m = moose.connect(spikegen, 'spikeOut', synH.synapse[0], 'addSpike') # this causes segfault
    return syn, spikegen

if __name__ == '__main__':
    model = moose.Neutral('/model')
    syn, spikegen = make_synapse('/model/synchan')
    moose.setClock(0, 0.01)
    moose.useClock(0, '/model/##', 'process')
    moose.reinit()
    moose.start(100)


#
# test_synchan.py ends here
コード例 #10
0
ファイル: trbsim.py プロジェクト: salthcl/thalamocortical
 # for debugging only
 #
 print 'PRINTING Synapse info'
 config.LOGGER.debug('PRINTING Synapse info')
 for celltype, count in config.runconfig.items('cellcount'):
     if int(count) == 0:
         continue
     synchans = moose.context.getWildcardList('%s/%s_0/##[ISA=SynChan]' % (net.network_container.path, celltype), True)
     nmdachans = moose.context.getWildcardList('%s/%s_0/##[TYPE=NMDAChan]' % (net.network_container.path, celltype), True)
     config.LOGGER.debug('No. of synchans on SpinyStellate_0 : %d' % (len(synchans)))
     config.LOGGER.debug('No. of nmdachans on SpinyStellate_0 : %d' % (len(nmdachans)))
     syn_tabs = []
     for synid in chain(synchans, nmdachans):
         synapse = moose.SynChan(synid)
         config.LOGGER.debug('Recording from %s' % (synapse.path))
         comp = moose.Neutral(synapse.parent)
         cell = moose.Neutral(comp.parent)
         synapse_data = moose.Neutral('synapse', sim.data)
         tab = moose.Table('gk_%s_%s_%s' % (cell.name, comp.name, synapse.name), synapse_data)
         tab.stepMode = 3
         config.LOGGER.info('Connected recording table %s: %s' % (tab.name, tab.connect('inputRequest', synapse, 'Gk')))
         syn_tabs.append(tab)
         tab = moose.Table('Ik_%s_%s_%s' % (cell.name, comp.name, synapse.name), synapse_data)
         tab.stepMode = 3
         config.LOGGER.info('Connected recording table %s: %s' % (tab.name, tab.connect('inputRequest', synapse, 'Ik')))
         syn_tabs.append(tab)
         config.LOGGER.debug('== start synapse info')
         config.LOGGER.debug(synapse.path)
         msg_list = pymoose.listmsg(synapse)
         for msg in msg_list:
             config.LOGGER.debug(msg)
コード例 #11
0
ファイル: trbsim.py プロジェクト: salthcl/thalamocortical
def main(*argv):
    """-c cell-count-file

    -g celltype-graph-file

    -s synaptic-scaling-file

    -v synaptic-conductance-values-file

    -t simulationtime

    -d simdt

    -p plotdt

    -r randomseed

    -s -- do explicit scheduling

    --reseed -- seed the rng with PID of current process

    -x prelease_unknown -- default release probability in stochastic simulations.

    --stochastic -- synapses are stochastic

    -i -- interstimulus interval
    """
    print '******** Starting run _{timestamp}_{PID} :', config.filename_suffix
    config.LOGGER.info('Running moose version: %s revision: %s' % (moose.version, moose.revision))
    celltypegraph_file = None
    cellcount_file = None
    synscale_file = None
    synval_file = None
    notes = None
    netfile = None
    optlist, args = getopt(argv[0], 'i:m:n:ehc:s:v:t:d:p:r:g:lx:', ['reseed', 'stochastic', 'netfile='])
    print 'Program arguments: '
    print 'Options:', optlist
    print 'Args:', args
    for arg in optlist:        
        if arg[0] == '-c':
            cellcount_file = arg[1]
        elif arg[0] == '-n':
            notes = arg[1]
        elif arg[0] == '-m':
            with open(arg[1], 'r') as notes_file:
                notes = '\n'.join(notes_file.readlines())
        elif arg[0] == '-s':
            synscale_file = arg[1]
        elif arg[0] == '-v':
            synval_file = arg[1]
        elif arg[0] == '-t':
            config.simtime = float(arg[1])
        elif arg[0] == '-d':
            config.simdt = float(arg[1])
        elif arg[0] == '-p':
            config.plotdt = float(arg[1])
        elif arg[0] == '-r':
            config.rngseed = int(arg[1])
        elif arg[0] == '-g':
            celltypegraph_file = arg[1]
        elif '--reseed' == arg[0]:
            config.to_reseed = True
        elif '--stochastic' == arg[0]:
            config.stochastic = True
        elif '--netfile' == arg[0]:
            netfile = arg[1]
        elif '-e' == arg[0]:
            config.solver = 'ee'
        elif arg[0] == '-l':
            config.clockjob.autoschedule = 0
        elif arg[0] == '-x':
            config.default_releasep = float(arg[1])
            assert((config.default_releasep < 1.0) and (config.default_releasep >= 0.0))
        elif arg[0] == '-i':
            config.runconfig.set('stimulus', 'isi', arg[1])
            print 'Set isi to', arg[1]
        elif '-h' == arg[0]:
            print main.__doc__
            sys.exit(0)

        
    sim = Simulation('sim%s' % (config.filename_suffix))
    net = TraubNet(container=sim.model, netfile=netfile)
    if notes is not None:
        net.tweaks_doc.append(notes)
    if celltypegraph_file is None:
        net._generate_celltype_graph()
    else:
        net.setup_from_celltype_file(celltype_file=celltypegraph_file)
    net.set_populations()
    net.set_conductances(synval_file)
    net.tune_conductances(synscale_file)
    scale_nmda = config.runconfig.get('NMDA', 'conductance_scale')
    if scale_nmda:
        net.scale_conductance('gnmda', {('*', '*'):float(scale_nmda)})
    scale_ampa = config.runconfig.get('AMPA', 'conductance_scale')
    if scale_ampa:
        net.scale_conductance('gampa', {('*', '*'):float(scale_ampa)})
    scale_gaba = config.runconfig.get('GABA', 'conductance_scale')
    if scale_gaba:
        net.scale_conductance('ggaba', {('*', '*'):float(scale_gaba)})    
    net.set_unknown_prelease(config.default_releasep)
    net._generate_cell_graph()
    net.create_network()
    if config.runconfig.get('stimulus', 'ectopic_spike') in ['1', 'yes', 'Yes', 'YES', 'true', 'True', 'TRUE']:
        net.setup_ectopic_input()
    # Comment out the following line to use original K+ reversal potential.
    # net.tweak_Ek(KChannel, 10e-3)
    net.randomize_passive_properties()
    net.randomize_active_conductances()
    background_celltype = config.runconfig.get('stimulus', 'background')
    probe_celltype = config.runconfig.get('stimulus', 'probe')
    bg_count = int(config.runconfig.get('stimulus', 'bg_count'))
    probe_count = int(config.runconfig.get('stimulus', 'probe_count'))
    onset = float(config.runconfig.get('stimulus', 'onset'))
    bg_interval = float(config.runconfig.get('stimulus', 'bg_interval'))
    bg_interval_spread = float(config.runconfig.get('stimulus', 'bg_interval_spread'))
    pulse_width = float(config.runconfig.get('stimulus', 'pulse_width'))
    isi = float(config.runconfig.get('stimulus', 'isi'))
    print 'trbsim - isi', isi
    amp = float(config.runconfig.get('stimulus', 'amplitude'))
    print bg_interval, pulse_width, isi
    if bg_interval_spread > 0.0:
        num_bg_pulses = (config.simtime - onset) / (bg_interval + bg_interval_spread/2)
    else:
        num_bg_pulses = 0
    stim_dict = net.setup_stimulus(bg_cells=background_celltype,
                       probe_cells=probe_celltype,
                       bg_count=bg_count,
                       probe_count=probe_count,
                       stim_onset=onset,
                       bg_interval=bg_interval,
                       bg_interval_spread=bg_interval_spread,
                       num_bg_pulses=num_bg_pulses,
                       pulse_width=pulse_width,
                       isi=isi,
                       level=amp)
    # Record post synaptic Vm for cells with highest convergent connections
    pspfrac = float(config.runconfig.get('record', 'pspfrac'))
    pspcontainer = moose.Neutral('%s/psp' % (sim.data.path))
    if pspfrac > 0:
        bg_target_cells = [comppath.rpartition('/')[0] for comppath in stim_dict['bg_targets']]
        target_source_map = get_targets(bg_target_cells)
        max_targets = get_max_targets(target_source_map, pspfrac)
        for celltype, cells in max_targets.items():
            config.LOGGER.debug('Recording Vm for 1 hop from stimulus for %s: %s' % (celltype, cells))
            for cellpath, count in cells:
                soma = MyCompartment(cellpath + '/comp_1')
                if soma.className == 'Compartment':
                    soma.insertRecorder(cellpath.rpartition('/')[-1], 'Vm', pspcontainer)
    # for cpath in stim_dict['bg_targets']:
    #     cell = cpath.rpartition('/')[0]
    #     comp = MyCompartment(cpath)
    #     comp.insertRecorder(
    #     , stim_dict['probe_targtes']):
        
    if net.from_netfile is not None and synscale_file is not None:
        net.scale_synapses(synscale_file)
    net.save_network_model(config.MODEL_FILENAME)
    net.verify_saved_model(config.MODEL_FILENAME)
    net.save_cell_network(config.MODEL_FILENAME + '.new')
    net.setup_spike_recording(sim.data)
    # net.setup_current_injection_test([-0.9e-9, -0.3e-9, 0.0, 0.1e-9, 0.0, 0.3e-9, 0.0, 0.9e-9], 1.0, 1.0, sim.data)
    # Setup the bias currents
    bias_current_delays = defaultdict(dict)
    bias_current_levels = defaultdict(dict)
    bias_current_widths = defaultdict(dict)
    for key, value in config.runconfig.items('bias_current'):
        if not value:
            continue
        tokens = key.split('_')
        celltype = tokens[0]
        param = tokens[1]
        index = int(tokens[2])
        try:
            if param == 'delay':
                bias_current_delays[celltype][index] = float(value)
            elif param == 'width':
                bias_current_widths[celltype][index] = float(value)
            elif param == 'level':
                bias_current_levels[celltype][index] = float(value)
        except ValueError, e:
            print 'Value:"', value, '"'
            raise(e)
コード例 #12
0
ファイル: simple_example.py プロジェクト: agravier/pynn
SIMDT = 0.01*ms
PLOTDT = 0.01*ms
RUNTIME = 5*ms
EREST = -70.0*mV
VLEAK = EREST + 10.613*mV
RM = 424.4e3
#RA = 7639.44e3
CM = 0.007854e-6
INJECT = 0.1e-6
VK = -90*mV
VNa = 40*mV
GK = 0.282743e-3
GNa = 0.94248e-3


model = moose.Neutral("/model")
#data = moose.Neutral("/data")
comp = moose.Compartment("/model/compartment")
comp.Rm = RM
#comp.Ra = RA
comp.Cm = CM
comp.Em = VLEAK
comp.initVm = EREST
comp.inject = INJECT

na = moose.HHChannel("na", comp)
na.Ek = VNa
na.Gbar = GNa
na.Xpower = 3
na.Ypower = 1
# (A + Bv)/(C + exp(D/E))
コード例 #13
0
ファイル: test_muparser.py プロジェクト: upibhalla/moose-core
    dt, tplot, avec = runPanelDEFG( 'negFB', 5.0, 2.0, 5, seq, 1.0 )
    xplot.append( avec )
    t = np.arange( 0, len( tplot[0] ), 1.0 ) * dt

    dt, tplot, avec = runPanelDEFG( 'negFF', 10.0, 1.0, 5, seq, 1.0 )
    xplot.append( avec )
    t = np.arange( 0, len( tplot[0] ), 1.0 ) * dt
    dt, tplot, avec = runPanelDEFG( 'fhn', 5.0, 1.5, 5, seq, 0.4 )
    xplot.append( avec )
    t = np.arange( 0, len( tplot[0] ), 1.0 ) * dt

    dt, tplot, avec = runPanelDEFG( 'bis', 15.0, 2.0, 5, seq, 1.0 )
    xplot.append( avec )
    t = np.arange( 0, len( tplot[0] ), 1.0 ) * dt
    ref = np.array( [0.04840247926323106, 0.060446860947786119
        , 0.047612129439079991, 0.081329604404641223, 0.050365470686926379] )
    res = np.array( [ np.mean( x )  for x in tplot ] )
    assert np.isclose( ref.all(), res.all() ), "Expected %s got %s" % (ref,res)

if __name__ == '__main__':
    moose.Neutral( '/library' )
    moose.Neutral( '/model' )
    plotPanelC()
    #if sys.version_info[0] == 2:
    #    plotPanelDEFG( [0,1,2,3,4], 3 )
    #    plotPanelDEFG( [4,1,0,3,2], 4 )
    #else:
    #    print( 'TODO: Running any of the following two functions causes seg-fault' )
    print( 'All done' )
コード例 #14
0
ファイル: HW6_part2.py プロジェクト: jkopsick/NEUR634
gran_cell = u.createMultiCompCell(swcfile, container, libraryName, compType,
                                  chan_set, cond_set, rateParams, RM, CM, RA,
                                  initVm, Em)
moose.showfield('/gran_cell/soma')

# Re-create the python variable pointing to the gran_cell to limit results just to
# type compartment (excludes the spines and allows for createDataTables function to
# work properly)
gran_cell = moose.wildcardFind('/gran_cell/#[TYPE=Compartment]')

# Create the pulse and apply it to the granule cell's soma
g_soma_pulse = u.createPulse(gran_cell[0], 'rollingWave', pulse_dur, pulse_amp,
                             pulse_delay1, pulse_delay2)

# Create a neutral object to store the data in
gran_data = moose.Neutral('/gran_data')
gran_tables = []
for comp in gran_cell:
    gran_tables.append(u.createDataTables(comp, gran_data, g_soma_pulse))

# Choose the soma and a representative dendrite to view how voltage changes
# for the granule cell
g_soma0_Vm = gran_tables[0][0]
g_soma0_Iex = gran_tables[0][1]
g_dend_5_00_Vm = gran_tables[-11][0]
g_dend_5_00_Iex = gran_tables[-11][1]

# Plot the simulation
simTime = 0.5
simdt = 0.25e-5
plotdt = 0.25e-3
コード例 #15
0
ファイル: testWigglySpines.py プロジェクト: AdrianW15/moose
def main():
    """
    This illustrates the use of rdesigneur to build a simple dendrite with
    spines, and then to resize them using spine fields. These are the
    fields that would be changed dynamically in a simulation with reactions
    that affect spine geometry.
    """
    makeModel()
    elec = moose.element('/model/elec')
    elec.setSpineAndPsdMesh(moose.element('/model/chem/spine'),
                            moose.element('/model/chem/psd'))
    caDend = moose.vec('/model/chem/dend/Ca')
    caHead = moose.vec('/model/chem/spine/Ca')
    caPsd = moose.vec('/model/chem/psd/Ca')
    eHead = moose.wildcardFind('/model/elec/#head#')
    graphs = moose.Neutral('/graphs')
    psdTab = moose.Table2('/graphs/psdTab', len(caPsd)).vec
    headTab = moose.Table2('/graphs/headTab', len(caHead)).vec
    dendTab = moose.Table2('/graphs/dendTab', len(caDend)).vec
    eTab = moose.Table('/graphs/eTab', len(eHead)).vec
    stimtab = moose.StimulusTable('/stim')
    stimtab.stopTime = 0.3
    stimtab.loopTime = 0.3
    stimtab.doLoop = True
    stimtab.vector = [
        1.0 + numpy.sin(x) for x in numpy.arange(0, 2 * PI, PI / 1000)
    ]
    estimtab = moose.StimulusTable('/estim')
    estimtab.stopTime = 0.001
    estimtab.loopTime = 0.001
    estimtab.doLoop = True
    estimtab.vector = [
        1e-9 * numpy.sin(x) for x in numpy.arange(0, 2 * PI, PI / 1000)
    ]

    for i in range(len(caPsd)):
        moose.connect(psdTab[i], 'requestOut', caPsd[i], 'getConc')
    for i in range(len(caHead)):
        moose.connect(headTab[i], 'requestOut', caHead[i], 'getConc')
    for i in range(len(caDend)):
        moose.connect(dendTab[i], 'requestOut', caDend[i], 'getConc')
    for i in range(len(eHead)):
        moose.connect(eTab[i], 'requestOut', eHead[i], 'getVm')
    moose.connect(stimtab, 'output', caDend, 'setConc', 'OneToAll')
    dend = moose.element('/model/elec/dend')
    moose.connect(estimtab, 'output', dend, 'setInject')

    moose.reinit()
    moose.start(1)

    head0 = moose.element('/model/elec/head0')
    shaft1 = moose.element('/model/elec/shaft1')
    head2 = moose.element('/model/elec/head2')

    # Here we scale the spine head length while keeping all vols constt.
    print("Spine 0: longer head, same vol\nSpine 1: longer shaft")
    print("Spine 2: Bigger head, same diffScale\n")
    elecParms = [(i.Rm, i.Cm, i.Ra) for i in (head0, shaft1, head2)]
    chemParms = [
        i.volume for i in (caHead[0], caPsd[0], caHead[1], caPsd[1], caHead[2],
                           caPsd[2])
    ]

    elec.spine[0].headLength *= 4  # 4x length
    print("############## {0}   {1}    {2}".format(elecParms[0][0], head0.Rm,
                                                   elec.spine[0].headLength))
    elec.spine[0].headDiameter *= 0.5  #  1/2 x dia

    # Here we scale the shaft length. Vols are not touched.
    elec.spine[1].shaftLength *= 2  # 2 x length

    #Here we scale the spine head vol while retaining diffScale = xArea/len
    # This gives 4x vol.
    hdia = elec.spine[2].headDiameter
    sdsolve = moose.element('/model/chem/spine/dsolve')
    elec.spine[2].headLength *= 2  # 2x length
    elec.spine[2].headDiameter *= numpy.sqrt(2)  # sqrt(2) x dia
    hdia = elec.spine[2].headDiameter

    print("Checking scaling assertions: ")
    assertEq(elecParms[0][0] * 0.5, head0.Rm)
    assertEq(elecParms[0][1] * 2, head0.Cm)
    assertEq(elecParms[0][2] * 16, head0.Ra)
    assertEq(chemParms[0], caHead[0].volume)
    assertEq(chemParms[1] * 0.25, caPsd[0].volume)

    assertEq(elecParms[1][0] * 0.5, shaft1.Rm)
    assertEq(elecParms[1][1] * 2, shaft1.Cm)
    assertEq(elecParms[1][2] * 2, shaft1.Ra)
    assertEq(chemParms[2], caHead[1].volume)
    assertEq(chemParms[3], caPsd[1].volume)

    ratio = 2 * numpy.sqrt(2)
    assertEq(elecParms[2][0] / ratio, head2.Rm)
    assertEq(elecParms[2][1] * ratio, head2.Cm)
    assertEq(elecParms[2][2], head2.Ra)
    assertEq(chemParms[4] * 4, caHead[2].volume)
    assertEq(chemParms[5] * 2, caPsd[2].volume)
    print("\nAll assertions cleared")

    moose.start(2)
    for i in range(len(psdTab)):
        pylab.plot(psdTab[i].vector, label='PSD' + str(i))
    pylab.legend()
    pylab.figure()
    for i in range(len(headTab)):
        pylab.plot(headTab[i].vector, label='head' + str(i))
    pylab.legend()
    pylab.figure()
    for i in range(len(dendTab)):
        pylab.plot(dendTab[i].vector, label='dendCa' + str(i))
    pylab.legend()
    pylab.figure()
    for i in range(len(eTab)):
        pylab.plot(eTab[i].vector, label='headVm' + str(i))
        #print i, len( eTab[i].vector ), eTab[i].vector
    pylab.legend()
    pylab.show()

    app = QtGui.QApplication(sys.argv)
    #widget = mv.MoogliViewer( '/model' )
    morphology = moogli.read_morphology_from_moose(name="", path='/model/elec')
    widget = moogli.MorphologyViewerWidget(morphology)
    widget.show()
    return app.exec_()
    quit()
コード例 #16
0
def main():
    """
This illustrates the use of rdesigneur to build a simple dendrite with
spines, and to confirm that the chemical contents of the spines align
with the electrical. Just a single molecule Ca is involved.
It diffuses and we plot the distribution.
It causes 'inject' of the relevant compartment to rise.

    """
    makeModel()

    # Create the output tables
    graphs = moose.Neutral('/graphs')
    #dendVm = addPlot( 'model/elec/dend', 'getVm', 'dendVm', 8 )
    addPlot('model/chem/dend/Ca[0]', 'getConc', 'dCa0', 18)
    addPlot('model/chem/dend/Ca[25]', 'getConc', 'dCa25', 18)
    addPlot('model/chem/dend/Ca[49]', 'getConc', 'dCa49', 18)
    addPlot('model/chem/spine/Ca[0]', 'getN', 'sCa0', 18)
    addPlot('model/chem/spine/Ca[25]', 'getN', 'sCa25', 18)
    addPlot('model/chem/spine/Ca[49]', 'getN', 'sCa49', 18)
    addPlot('model/chem/psd/Ca[0]', 'getConc', 'pCa0', 18)
    addPlot('model/chem/psd/Ca[25]', 'getConc', 'pCa25', 18)
    addPlot('model/chem/psd/Ca[49]', 'getConc', 'pCa49', 18)

    d = moose.vec('/model/chem/dend/Ca')
    s = moose.vec('/model/chem/spine/Ca')
    p = moose.vec('/model/chem/psd/Ca')
    s[5].nInit = 1000
    s[40].nInit = 5000
    moose.reinit()
    moose.start(runtime)

    fig = plt.figure(figsize=(13, 10))
    p1 = fig.add_subplot(311)
    plotVm(p1, 'dend')
    plotVm(p1, 'head')
    plotVm(p1, 'psd')
    p1.legend()
    #time = numpy.arange( 0, dendVm.vector.size, 1 ) * dendVm.dt
    #p1.plot( time, dendVm.vector, label = 'dendVm' )
    p2 = fig.add_subplot(312)
    p2.plot(d.conc, label='idendCa')
    p2.plot(s.conc, label='ispineCa')
    p2.plot(p.conc, label='ipsdCa')
    p2.legend()
    '''
    p2 = fig.add_subplot( 312 )
    for i in moose.wildcardFind( '/graphs/#Ca#' ):
        time = numpy.arange( 0, i.vector.size, 1 ) * i.dt
        p2.plot( time, i.vector, label = i.name )
    p2.legend()
    '''
    p3 = fig.add_subplot(313)
    p3.plot(getMidpts('dend'), d.conc, label='dendCa')
    #p3.plot( range( 0, len( d ) ), d.conc, label = 'dendCa' )

    p3.plot(getMidpts('spine'), s.conc, label='spineCa')
    p3.plot(getMidpts('psd'), p.conc, label='psdCa')
    p3.legend()

    plt.show()
    app = QtGui.QApplication(sys.argv)
    #widget = mv.MoogliViewer( '/model' )
    morphology = moogli.read_morphology_from_moose(name="", path='/model/elec')
    widget = moogli.MorphologyViewerWidget(morphology)
    widget.show()
    return app.exec_()
    quit()
コード例 #17
0
def makeSpineProto2(name):
    spine = moose.Neutral('/library/' + name)
    shaft = rd.buildCompt(spine, 'shaft', 0.5e-6, 0.4e-6, 0, RM, RA, CM)
    head = rd.buildCompt(spine, 'head', 0.5e-6, 0.5e-6, 0.5e-6, RM, RA, CM)
    moose.connect(shaft, 'axial', head, 'raxial')
def main():
    library=moose.Neutral('/library')
    #makePassiveSoma( 'cell', params['dendL'], params['dendDia'] )
    makeDendProto()
    makeChemProto()
    rdes=rd.rdesigneur(
        turnOffElec=True,
        chemPlotDt = 0.1, 
        diffusionLength=params['diffusionL'],
        #cellProto=[['cell','soma']],
        cellProto=[['elec','dend']],
        chemProto=[['hydra','hydra']],
        chemDistrib=[['hydra', '#soma#,#dend#', 'install', '1']],
        plotList=[
            ['soma', '1', 'dend/A', 'n', '# of A'],
            ['soma', '1', 'dend/B', 'n', '# of B']
        ],
    #    moogList = [['soma', '1', 'dend/A', 'n', 'num of A (number)']]
        )
    moose.le( '/library' )
    moose.le( '/library/hydra' )
    #moose.showfield( '/library/soma/soma' )
    rdes.buildModel()
    #moose.element('/model/chem/dend/B').vec[50].nInit=15.5
    
    A = moose.element('/model/chem/dend/A')
    B = moose.element('/model/chem/dend/B')
    C = moose.element('/model/chem/dend/C')
    A.diffConst=1e-13
    B.diffConst=0
    C.diffConst=0
    B.motorConst=1e-06
    C.motorConst=-1e-06
#    A.concInit=1
#    B.concInit=10
    moose.element('/model/chem/dend/A').vec[200].nInit=1.2
    moose.element('/model/chem/dend/A').vec[100].nInit=1.2
    #moose.element('/model/chem/dend/A').vec[95].nInit=1.2
    #moose.element('/model/chem/dend/A').vec[127].nInit=1.2
    #moose.element('/model/chem/dend/B').vec[244].nInit=1.2
    #moose.element('/model/chem/dend/C').vec[400].nInit=1.2
    #moose.element('/model/chem/dend/A').vec[105].nInit=1.2
    #moose.element('/model/chem/dend/B').vec[105].nInit=1.2
    
    #moose.element('/model/chem/dend/B').vec[25].nInit=0
    #A.nInit=1
    #B.nInit=15
    #for i in range(0,499):
        #moose.element('/model/chem/dend/A').vec[i].diffConst=9.45e-12
        #moose.element('/model/chem/dend/A').vec[i].diffConst=1e-13
        #moose.element('/model/chem/dend/B').vec[i].diffConst=1e-13
        #moose.element('/model/chem/dend/B').vec[i].diffConst=0.27e-09
        
    #for i in range(500,999):
        #moose.element('/model/chem/dend/A').vec[i].diffConst=9.45e-12
        #moose.element('/model/chem/dend/A').vec[i].diffConst=1e-13
        #moose.element('/model/chem/dend/B').vec[i].diffConst=1e-13
        #moose.element('/model/chem/dend/B').vec[i].diffConst=0.27e-09
        
    #for i in range(0,200):
        #moose.element('/model/chem/dend/A').vec[i].diffConst=1e-13
        
    #for i in range(700,999):
        #moose.element('/model/chem/dend/A').vec[i].diffConst=1e-13
        
    moose.reinit()
    #moose.start(2)
    for t in range(0,2000,200):
        moose.start(200)
        avec=moose.vec('/model/chem/dend/A').n
        plt.plot(avec)
        
    avec = moose.vec( '/model/chem/dend/A' ).n
    bvec = moose.vec( '/model/chem/dend/B' ).n
    cvec = moose.vec( '/model/chem/dend/C' ).n
    #plt.plot(bvec) 
    

        

    
    return bvec,avec,cvec
コード例 #19
0
def main():
    library = moose.Neutral('/library')
    #makePassiveSoma( 'cell', params['dendL'], params['dendDia'] )
    makeDendProto()
    makeChemProto()
    rdes = rd.rdesigneur(
        turnOffElec=True,
        chemPlotDt=0.1,
        diffusionLength=params['diffusionL'],
        #cellProto=[['cell','soma']],
        cellProto=[['elec', 'dend']],
        chemProto=[['hydra', 'hydra']],
        chemDistrib=[['hydra', '#soma#,#dend#', 'install', '1']],
        #stimList=[['soma','1','.','inject','(t>0.01&&t<0.2)*1e-10']],
        plotList=[['soma', '1', 'dend/A', 'n', '# of A'],
                  ['soma', '1', 'dend/B', 'n', '# of B']],
    )
    moose.le('/library')
    moose.le('/library/hydra')
    rdes.buildModel()

    A = moose.element('/model/chem/dend/A')
    B = moose.element('/model/chem/dend/B')
    S = moose.element('/model/chem/dend/S')
    space = moose.element('/model/chem/dend/space')
    A.diffConst = 1e-13
    B.diffConst = 1e-11
    S.diffConst = 0
    space.diffConst = 0
    #moose.element('/model/chem/dend/A').vec[50].nInit=1.2
    #moose.element('/model/chem/dend/B').vec[50].nInit=1.2
    totLen = len(moose.vec('/model/chem/dend/A').n)
    sourceApply = range(int(totLen * 0.1) + 1)
    xl = 0
    for j in range(totLen):
        moose.element('/model/chem/dend/A').vec[j].concInit = 0.268331
        moose.element('/model/chem/dend/B').vec[j].concInit = 2.0

    for i in sourceApply:
        #moose.element('/model/chem/dend/A').vec[i].concInit=0.268331
        #moose.element('/model/chem/dend/B').vec[i].concInit=2
        moose.element('/model/chem/dend/S').vec[i].concInit = 1
        moose.element('/model/chem/dend/space').vec[i].concInit = xl * 0.1
        print moose.element('/model/chem/dend/space').vec[i].concInit, xl
        print moose.element('/model/chem/dend/S').vec[i].concInit
        xl = xl + 1

    #randper=np.random.uniform(1,2,savec)
    print 'simulation start'
    dtSol = 0.01
    moose.setClock(16, dtSol)
    moose.setClock(10, dtSol)
    moose.reinit()
    #avec=moose.vec('/model/chem/dend/A').n
    #bvec=moose.vec('/model/chem/dend/B').n
    #source=moose.vec('/model/chem/dend/S').n
    storeAvec = []
    numSteps = 2500
    time = 0
    t1 = 20
    t2 = 25
    maxs = 0.05
    space = moose.vec('/model/chem/dend/space').n
    # print 'coordinates are', space, np.cos(np.pi)

    for i in range(0, numSteps):
        #if t<20:
        #  source = maxs/2
        #elif t > 20 and t < 25:
        #  s = (maxs/4)*(1+np.cos(np.pi*(t-t1)/(t2-t1)))
        #else:
        #  s = 0
        avec = moose.vec('/model/chem/dend/A').conc
        #print moose.vec('/model/chem/dend/S').n
        bvec = moose.vec('/model/chem/dend/B').conc
        source = moose.vec('/model/chem/dend/S').conc
        space = moose.vec('/model/chem/dend/space').conc
        moose.start(dtSol)
        storeAvec.append(avec)
        time = time + dtSol
        print time

    #plt.ion()
    #fig = plt.figure(figsize=(6,6))
    trialNum = '1'
    fileName = 'Mori.xml'
    writeXML(storeAvec, trialNum, fileName)
    plt.plot(avec)
    plt.show()
    raw_input()
    print 'press any key to exit'

    return bvec, avec, source, space, storeAvec
コード例 #20
0
def makeNeuroMeshModel():
    makeSpinyCompt()
    diffLength = moose.element('/n/compt').length
    diffLength = diffLength / 10.0
    elec = moose.element('/n')
    elec.name = 'elec'
    model = moose.Neutral('/model')
    moose.move(elec, model)
    synInput = moose.element('/model/elec/compt/synInput')
    synInput.refractT = 47e-3

    chem = moose.Neutral('/model/chem')
    neuroCompt = moose.NeuroMesh('/model/chem/neuroMesh')
    neuroCompt.separateSpines = 1
    neuroCompt.diffLength = diffLength
    neuroCompt.geometryPolicy = 'cylinder'
    spineCompt = moose.SpineMesh('/model/chem/spineMesh')
    moose.connect(neuroCompt, 'spineListOut', spineCompt, 'spineList',
                  'OneToOne')
    psdCompt = moose.PsdMesh('/model/chem/psdMesh')
    moose.connect(neuroCompt, 'psdListOut', psdCompt, 'psdList', 'OneToOne')

    createChemModel(neuroCompt, spineCompt, psdCompt)

    # Put in the solvers, see how they fare.
    nmksolve = moose.GslStoich('/model/chem/neuroMesh/ksolve')
    nmksolve.path = '/model/chem/neuroMesh/##'
    nmksolve.compartment = moose.element('/model/chem/neuroMesh')
    nmksolve.method = 'rk5'
    nm = moose.element('/model/chem/neuroMesh/mesh')
    moose.connect(nm, 'remesh', nmksolve, 'remesh')
    #print "neuron: nv=", nmksolve.numLocalVoxels, ", nav=", nmksolve.numAllVoxels, nmksolve.numVarPools, nmksolve.numAllPools

    #print 'setting up smksolve'
    smksolve = moose.GslStoich('/model/chem/spineMesh/ksolve')
    smksolve.path = '/model/chem/spineMesh/##'
    smksolve.compartment = moose.element('/model/chem/spineMesh')
    smksolve.method = 'rk5'
    sm = moose.element('/model/chem/spineMesh/mesh')
    moose.connect(sm, 'remesh', smksolve, 'remesh')
    #print "spine: nv=", smksolve.numLocalVoxels, ", nav=", smksolve.numAllVoxels, smksolve.numVarPools, smksolve.numAllPools
    #
    #print 'setting up pmksolve'
    pmksolve = moose.GslStoich('/model/chem/psdMesh/ksolve')
    pmksolve.path = '/model/chem/psdMesh/##'
    pmksolve.compartment = moose.element('/model/chem/psdMesh')
    pmksolve.method = 'rk5'
    pm = moose.element('/model/chem/psdMesh/mesh')
    moose.connect(pm, 'remesh', pmksolve, 'remesh')
    #print "psd: nv=", pmksolve.numLocalVoxels, ", nav=", pmksolve.numAllVoxels, pmksolve.numVarPools, pmksolve.numAllPools
    #

    #print 'Assigning the cell model'
    # Now to set up the model.
    neuroCompt.cell = elec
    ns = neuroCompt.numSegments
    #assert( ns == 11 ) # dend, 5x (shaft+head)
    ndc = neuroCompt.numDiffCompts
    assert (ndc == 10)
    ndc = neuroCompt.mesh.num
    assert (ndc == 10)
    sdc = spineCompt.mesh.num
    assert (sdc == 5)
    pdc = psdCompt.mesh.num
    assert (pdc == 5)
    #
    # We need to use the spine solver as the master for the purposes of
    # these calculations. This will handle the diffusion calculations
    # between head and dendrite, and between head and PSD.
    smksolve.addJunction(nmksolve)
    #print "spine: nv=", smksolve.numLocalVoxels, ", nav=", smksolve.numAllVoxels, smksolve.numVarPools, smksolve.numAllPools
    smksolve.addJunction(pmksolve)
    #print "psd: nv=", pmksolve.numLocalVoxels, ", nav=", pmksolve.numAllVoxels, pmksolve.numVarPools, pmksolve.numAllPools
    # Have to pass a message between the various solvers.
    foo = moose.vec('/model/chem/spineMesh/headGluR')

    # oddly, numLocalFields does not work.
    ca = moose.element('/model/chem/neuroMesh/Ca')
    assert (ca.lastDimension == ndc)

    moose.vec('/model/chem/spineMesh/headGluR').nInit = 100
    moose.vec('/model/chem/psdMesh/psdGluR').nInit = 0

    # set up adaptors
    aCa = moose.Adaptor('/model/chem/spineMesh/adaptCa', 5)
    adaptCa = moose.vec('/model/chem/spineMesh/adaptCa')
    chemCa = moose.vec('/model/chem/spineMesh/Ca')
    assert (len(adaptCa) == 5)
    for i in range(5):
        path = '/model/elec/head' + str(i) + '/ca'
        elecCa = moose.element(path)
        moose.connect(elecCa, 'concOut', adaptCa[i], 'input', 'Single')
    moose.connect(adaptCa, 'outputSrc', chemCa, 'setConc', 'OneToOne')
    adaptCa.outputOffset = 0.0001  # 100 nM offset in chem.
    adaptCa.scale = 0.05  # 0.06 to 0.003 mM

    aGluR = moose.Adaptor('/model/chem/psdMesh/adaptGluR', 5)
    adaptGluR = moose.vec('/model/chem/psdMesh/adaptGluR')
    chemR = moose.vec('/model/chem/psdMesh/psdGluR')
    assert (len(adaptGluR) == 5)
    for i in range(5):
        path = '/model/elec/head' + str(i) + '/gluR'
        elecR = moose.element(path)
        moose.connect(adaptGluR[i], 'outputSrc', elecR, 'setGbar', 'Single')
    #moose.connect( chemR, 'nOut', adaptGluR, 'input', 'OneToOne' )
    # Ksolve isn't sending nOut. Not good. So have to use requestOut.
    moose.connect(adaptGluR, 'requestOut', chemR, 'getN', 'OneToOne')
    adaptGluR.outputOffset = 1e-7  # pS
    adaptGluR.scale = 1e-6 / 100  # from n to pS

    adaptK = moose.Adaptor('/model/chem/neuroMesh/adaptK')
    chemK = moose.element('/model/chem/neuroMesh/kChan')
    elecK = moose.element('/model/elec/compt/K')
    moose.connect(adaptK, 'requestOut', chemK, 'getConc', 'OneToAll')
    moose.connect(adaptK, 'outputSrc', elecK, 'setGbar', 'Single')
    adaptK.scale = 0.3  # from mM to Siemens
    """
コード例 #21
0
def makeModel():
    # create container for model
    num = 1  # number of compartments
    model = moose.Neutral('/model')
    compartment = moose.CylMesh('/model/compartment')
    compartment.x1 = 1.0e-6  # Set it to a 1 micron single-voxel cylinder

    # create molecules and reactions
    s = moose.Pool('/model/compartment/s')
    rXfer = moose.Reac('/model/compartment/rXfer')
    #####################################################################
    # Put in endo compartment. Add molecule s
    endo = moose.EndoMesh('/model/endo')
    endo.isMembraneBound = True
    endo.surround = compartment
    es = moose.Pool('/model/endo/s')
    erXfer = moose.Reac('/model/compartment/erXfer')
    #####################################################################
    moose.connect(erXfer, 'sub', es, 'reac')
    moose.connect(erXfer, 'prd', s, 'reac')
    moose.connect(rXfer, 'sub', s, 'reac')
    moose.connect(rXfer, 'prd', es, 'reac')
    rXfer.Kf = 0.04  # 0.04/sec
    rXfer.Kb = 0.0  # 0.02/sec
    erXfer.Kf = 0.02  # 0.04/sec
    erXfer.Kb = 0.0  # 0.02/sec

    #####################################################################
    fixXreacs.fixXreacs('/model')
    fixXreacs.restoreXreacs('/model')
    fixXreacs.fixXreacs('/model')
    #####################################################################
    rx = moose.element('/model/compartment/rXfer')
    erx = moose.element('/model/compartment/erXfer')

    # Make solvers
    ksolve = moose.Ksolve('/model/compartment/ksolve')
    dsolve = moose.Dsolve('/model/dsolve')
    eksolve = moose.Ksolve('/model/endo/ksolve')
    edsolve = moose.Dsolve('/model/endo/dsolve')

    stoich = moose.Stoich('/model/compartment/stoich')
    stoich.compartment = compartment
    stoich.ksolve = ksolve
    stoich.dsolve = dsolve
    stoich.path = "/model/compartment/##"
    assert (dsolve.numPools == 2)
    s.vec.concInit = [1] * num

    estoich = moose.Stoich('/model/endo/stoich')
    estoich.compartment = endo
    estoich.ksolve = eksolve
    estoich.dsolve = edsolve
    estoich.path = "/model/endo/##"
    assert (edsolve.numPools == 1)

    edsolve.buildMeshJunctions(dsolve)

    plot1 = moose.Table2('/model/plot1')
    plot2 = moose.Table2('/model/plot2')
    moose.connect('/model/plot1', 'requestOut', s, 'getN')
    moose.connect('/model/plot2', 'requestOut', es, 'getN')
    plot3 = moose.Table2('/model/plot3')
    plot4 = moose.Table2('/model/plot4')
    moose.connect('/model/plot3', 'requestOut', s, 'getConc')
    moose.connect('/model/plot4', 'requestOut', es, 'getConc')
コード例 #22
0

def addOneChan(chanpath, gbar,comp):

    SA = np.pi * comp.length * comp.diameter
    proto = moose.element('/library/' + chanpath)
    chan = moose.copy(proto, comp, chanpath)
    chan.Gbar = gbar * SA
    # If we are using GHK AND it is a calcium channel, connect it to GHK
    moose.connect(comp, 'VmOut', chan, 'Vm')
    moose.connect(chan, "channelOut", comp, "handleChannel")
    return chan


if __name__ == '__main__':
    lib = moose.Neutral('/library')
    for tick in range(0, 7):
        moose.setClock(tick, dt)
    moose.setClock(8, 0.005)  # set output clock
    model = moose.Neutral('/model')
    dend = moose.Compartment('/model/dend')
    pulse = moose.PulseGen('/model/pulse')
    data = moose.Neutral('/data')
    vmtab = moose.Table('/data/dend_Vm')
    gktab = moose.Table('/data/CaT_Gk')
    iktab = moose.Table('/data/CaT_Ik')

    dend.Cm = Cm
    dend.Rm = Rm
    dend.Em = Em
    dend.initVm = Vm_0
コード例 #23
0
ファイル: MorphML.py プロジェクト: Vio8023/moose
 def set_compartment_param(self, compartment, name, value, mechanismname):
     """ Set the param for the compartment depending on name and mechanismname. """
     if name == 'CM':
         compartment.Cm = value * math.pi * compartment.diameter * compartment.length
     elif name == 'RM':
         compartment.Rm = value / (math.pi * compartment.diameter *
                                   compartment.length)
     elif name == 'RA':
         compartment.Ra = value * compartment.length / (
             math.pi * (compartment.diameter / 2.0)**2)
     elif name == 'Em':
         compartment.Em = value
     elif name == 'initVm':
         compartment.initVm = value
     elif name == 'inject':
         # this reader converts to SI
         pu.info("Comparment %s inject %s A." % (compartment.name, value))
         compartment.inject = value
     elif name == 'v_reset':
         compartment.vReset = value  # compartment is a moose.LIF instance (intfire)
     elif name == 'threshold':
         compartment.thresh = value  # compartment is a moose.LIF instance (intfire)
     elif name == 't_refrac':
         compartment.refractoryPeriod = value  # compartment is a moose.LIF instance (intfire)
     elif name == 'g_refrac':
         pu.info("SORRY, current moose.LIF doesn't support g_refrac.")
     elif mechanismname is 'synapse':  # synapse being added to the compartment
         ## these are potential locations, we do not actually make synapses,
         ## unless the user has explicitly asked for it
         if self.createPotentialSynapses:
             syn_name = value
             if not moose.exists(compartment.path + '/' + syn_name):
                 make_new_synapse(syn_name, compartment, syn_name,
                                  self.nml_params)
         ## I assume below that compartment name has _segid at its end
         segid = string.split(
             compartment.name,
             '_')[-1]  # get segment id from compartment name
         self.segDict[segid][5].append(value)
     elif mechanismname is 'spikegen':  # spikegen being added to the compartment
         ## these are potential locations, we do not actually make the spikegens.
         ## spikegens for different synapses can have different thresholds,
         ## hence include synapse_type in its name
         ## value contains name of synapse i.e. synapse_type
         #spikegen = moose.SpikeGen(compartment.path+'/'+value+'_spikegen')
         #moose.connect(compartment,"VmSrc",spikegen,"Vm")
         pass
     ## previous were mechanism that don't need a ChannelML definition
     ## including integrate_and_fire (I ignore the ChannelML definition)
     ## thus integrate_and_fire mechanism default values cannot be used
     ## i.e. nothing needed in /library, but below mechanisms need.
     elif mechanismname is not None:
         ## if mechanism is not present in compartment, deep copy from library
         ## all mechanisms have been loaded into the library earlier
         if not moose.exists(compartment.path + '/' + mechanismname):
             neutralObj = moose.element(
                 "/library/" + mechanismname)  # gives error if not present
             if 'CaConc' == neutralObj.className:  # Ion concentration pool
                 libcaconc = moose.CaConc("/library/" + mechanismname)
                 ## deep copies the library caconc under the compartment
                 caconc = moose.copy(libcaconc, compartment, mechanismname)
                 caconc = moose.CaConc(caconc)
                 ## CaConc connections are made later using connect_CaConc()
                 ## Later, when calling connect_CaConc,
                 ## B is set for caconc based on thickness of Ca shell and compartment l and dia
                 ## OR based on the Mstring phi under CaConc path.
                 channel = None
             elif 'HHChannel2D' == neutralObj.className:  ## HHChannel2D
                 libchannel = moose.HHChannel2D("/library/" + mechanismname)
                 ## deep copies the library channel under the compartment
                 channel = moose.copy(libchannel, compartment,
                                      mechanismname)
                 channel = moose.HHChannel2D(channel)
                 moose.connect(channel, 'channel', compartment, 'channel')
             elif 'HHChannel' == neutralObj.className:  ## HHChannel
                 libchannel = moose.HHChannel("/library/" + mechanismname)
                 ## deep copies the library channel under the compartment
                 channel = moose.copy(libchannel, compartment,
                                      mechanismname)
                 channel = moose.HHChannel(channel)
                 moose.connect(channel, 'channel', compartment, 'channel')
         ## if mechanism is present in compartment, just wrap it
         else:
             neutralObj = moose.Neutral(compartment.path + '/' +
                                        mechanismname)
             if 'CaConc' == neutralObj.className:  # Ion concentration pool
                 caconc = moose.CaConc(
                     compartment.path + '/' +
                     mechanismname)  # wraps existing channel
                 channel = None
             elif 'HHChannel2D' == neutralObj.className:  ## HHChannel2D
                 channel = moose.HHChannel2D(
                     compartment.path + '/' +
                     mechanismname)  # wraps existing channel
             elif 'HHChannel' == neutralObj.className:  ## HHChannel
                 channel = moose.HHChannel(
                     compartment.path + '/' +
                     mechanismname)  # wraps existing channel
         if name == 'Gbar':
             if channel is None:  # if CaConc, neuroConstruct uses gbar for thickness or phi
                 ## If child Mstring 'phi' is present, set gbar as phi
                 ## BUT, value has been multiplied by Gfactor as a Gbar,
                 ## SI or physiological not known here,
                 ## ignoring Gbar for CaConc, instead of passing units here
                 child = moose_utils.get_child_Mstring(caconc, 'phi')
                 if child is not None:
                     #child.value = value
                     pass
                 else:
                     #caconc.thick = value
                     pass
             else:  # if ion channel, usual Gbar
                 channel.Gbar = value * math.pi * compartment.diameter * compartment.length
         elif name == 'Ek':
             channel.Ek = value
         elif name == 'thick':  # thick seems to be NEURON's extension to NeuroML level 2.
             caconc.thick = value  ## JUST THIS WILL NOT DO - HAVE TO SET B based on this thick!
             ## Later, when calling connect_CaConc,
             ## B is set for caconc based on thickness of Ca shell and compartment l and dia.
             ## OR based on the Mstring phi under CaConc path.
     if neuroml_utils.neuroml_debug:
         pu.info("Setting %s  for comparment %s to %s" %
                 (name, compartment.path, value))
コード例 #24
0
def main():
    """
This example illustrates loading a model from an SWC file, inserting
spines, and viewing it.

    """
    PI = 3.14159265358979
    frameRunTime = 0.0002
    runtime = 1.0
    inject = 5e-10
    simdt = 5e-5
    RM = 1.0
    RA = 1.0
    CM = 0.01
    spineSpacing = 2.0e-6
    minSpacing = 0.2e-6
    spineSize = 1.0
    spineSizeDistrib = 0.5
    spineAngle = 0
    spineAngleDistrib = 2 * PI

    app = QtGui.QApplication(sys.argv)
    filename = 'barrionuevo_cell1zr.CNG.swc'
    #filename = 'h10.CNG.swc'
    moose.Neutral('/library')
    rdes = rd.rdesigneur( \
            cellProto = [[ filename, 'elec' ] ],\
            spineProto = [['makeSpineProto()', 'spine' ]] ,\
            spineDistrib = [ \
                ['spine', '#apical#', \
                'spacing', str( spineSpacing ), \
                'spacingDistrib', str( minSpacing ), \
                'angle', str( spineAngle ), \
                'angleDistrib', str( spineAngleDistrib ), \
                'size', str( spineSize ), \
                'sizeDistrib', str( spineSizeDistrib ) ] \
            ] \
        )
    rdes.buildModel('/model')
    moose.reinit()

    # Now we set up the display
    compts = moose.wildcardFind("/model/elec/#[ISA=CompartmentBase]")
    compts[0].inject = inject
    ecomptPath = [x.path for x in compts]
    morphology = moogli.extensions.moose.read(path="/model/elec", vertices=15)
    #morphology = moogli.read_morphology_from_moose(name = "", path = "/model/elec")
    #morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, \
    #        [0.0, 0.5, 1.0, 1.0], [1.0, 0.0, 0.0, 0.9] )
    #morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, gnuplot )

    #viewer = moogli.DynamicMorphologyViewerWidget(morphology)
    viewer = moogli.Viewer("Viewer")

    viewer.attach_shapes(morphology.shapes.values())
    view = moogli.View("main-view")
    viewer.attach_view(view)

    #viewer.set_background_color( 1.0, 1.0, 1.0, 1.0 )
    def callback(morphology, viewer):
        moose.start(frameRunTime)
        Vm = [moose.element(x).Vm for x in compts]
        morphology.set_color("group_all", Vm)
        currTime = moose.element('/clock').currentTime
        #print currTime, compts[0].Vm
        if (currTime < runtime):
            return True
        return False

    #viewer.set_callback( callback, idletime = 0 )
    #viewer.showMaximized()
    viewer.show()
    app.exec_()
コード例 #25
0
def test_function_chemsys():
    moose.Neutral('/library')
    moose.Neutral('/model')
    run()
    print('All done')
コード例 #26
0
ファイル: reacDiffSpinyNeuron.py プロジェクト: tdeuling/moose
def makeModel():
    model = moose.Neutral('/model')
    # Make neuronal model. It has no channels, just for geometry
    cell = moose.loadModel('./spinyNeuron.p', '/model/cell', 'Neutral')
    # We don't want the cell to do any calculations. Disable everything.
    for i in moose.wildcardFind('/model/cell/##'):
        i.tick = -1

    diffConst = 0.0
    # create container for model
    model = moose.element('/model')
    chem = moose.Neutral('/model/chem')
    # The naming of the compartments is dicated by the places that the
    # chem model expects to be loaded.
    compt0 = moose.NeuroMesh('/model/chem/compt0')
    compt0.separateSpines = 1
    compt0.geometryPolicy = 'cylinder'
    compt1 = moose.SpineMesh('/model/chem/compt1')
    moose.connect(compt0, 'spineListOut', compt1, 'spineList', 'OneToOne')
    compt2 = moose.PsdMesh('/model/chem/compt2')
    moose.connect(compt0, 'psdListOut', compt2, 'psdList', 'OneToOne')

    #reacSystem = moose.loadModel( 'simpleOsc.g', '/model/chem', 'ee' )
    makeChemModel(compt0)  # Populate all 3 compts with the chem system.
    makeChemModel(compt1)
    makeChemModel(compt2)

    compt0.diffLength = 2e-6  # This will be over 100 compartments.
    # This is the magic command that configures the diffusion compartments.
    compt0.subTreePath = cell.path + "/#"
    moose.showfields(compt0)

    # Build the solvers. No need for diffusion in this version.
    ksolve0 = moose.Ksolve('/model/chem/compt0/ksolve')
    ksolve1 = moose.Ksolve('/model/chem/compt1/ksolve')
    ksolve2 = moose.Ksolve('/model/chem/compt2/ksolve')
    dsolve0 = moose.Dsolve('/model/chem/compt0/dsolve')
    dsolve1 = moose.Dsolve('/model/chem/compt1/dsolve')
    dsolve2 = moose.Dsolve('/model/chem/compt2/dsolve')
    stoich0 = moose.Stoich('/model/chem/compt0/stoich')
    stoich1 = moose.Stoich('/model/chem/compt1/stoich')
    stoich2 = moose.Stoich('/model/chem/compt2/stoich')

    # Configure solvers
    stoich0.compartment = compt0
    stoich1.compartment = compt1
    stoich2.compartment = compt2
    stoich0.ksolve = ksolve0
    stoich1.ksolve = ksolve1
    stoich2.ksolve = ksolve2
    stoich0.dsolve = dsolve0
    stoich1.dsolve = dsolve1
    stoich2.dsolve = dsolve2
    stoich0.path = '/model/chem/compt0/#'
    stoich1.path = '/model/chem/compt1/#'
    stoich2.path = '/model/chem/compt2/#'
    assert (stoich0.numVarPools == 3)
    assert (stoich0.numProxyPools == 0)
    assert (stoich0.numRates == 4)
    assert (stoich1.numVarPools == 3)
    assert (stoich1.numProxyPools == 0)
    assert (stoich1.numRates == 4)
    assert (stoich2.numVarPools == 3)
    assert (stoich2.numProxyPools == 0)
    assert (stoich2.numRates == 4)
    dsolve0.buildNeuroMeshJunctions(dsolve1, dsolve2)
    stoich0.buildXreacs(stoich1)
    stoich1.buildXreacs(stoich2)
    stoich0.filterXreacs()
    stoich1.filterXreacs()
    stoich2.filterXreacs()

    moose.element('/model/chem/compt2/a[0]').concInit *= 1.5

    # Create the output tables
    num = compt0.numDiffCompts - 1
    graphs = moose.Neutral('/model/graphs')
    moose.le('/model/chem/compt1')
    a = moose.element('/model/chem/compt1')
    print((a.voxelVolume))
    makeTab('a_soma', '/model/chem/compt0/a[0]')
    makeTab('b_soma', '/model/chem/compt0/b[0]')
    makeTab('a_apical', '/model/chem/compt0/a[' + str(num) + ']')
    makeTab('b_apical', '/model/chem/compt0/b[' + str(num) + ']')
    makeTab('a_spine', '/model/chem/compt1/a[5]')
    makeTab('b_spine', '/model/chem/compt1/b[5]')
    makeTab('a_psd', '/model/chem/compt2/a[5]')
    makeTab('b_psd', '/model/chem/compt2/b[5]')
コード例 #27
0
import moose
from pylab import *
from moose.utils import *
import numpy as np

inputGiven = 1
moose.Neutral('/elec')
pg = moose.PulseGen('/elec/inPulGen')
pgTable = moose.Table('/elec/inPulGen/pgTable')
moose.connect(pgTable, 'requestOut', pg, 'getOutputValue')

pg.firstDelay = 10e-3
pg.firstWidth = 2e-03
pg.firstLevel = 3
pg.secondDelay = 1.0

cellPath = '/cell'

# cell = moose.LeakyIaF(cellPath)
# cell.setField('Cm',1e-6)
# cell.setField('Rm',1e4)
# cell.setField('Em',-0.07)
# cell.setField('initVm',-0.05)
# cell.setField('Vreset',-0.07)
# cell.setField('Vthreshold',0.0)
# cell.setField('refractoryPeriod',0.01)

cell = moose.IntFire(cellPath)
cell.setField('tau', 10e-3)
#cell.setField('Vm', 1.0)
cell.setField('refractoryPeriod', 5e-3)
コード例 #28
0
    def set_compartment_param(self, compartment, name, value, mechName):
        """ Set the param for the compartment depending on name and mechName. """
        if name == 'CM':
            compartment.Cm = value * math.pi * compartment.diameter * compartment.length
        elif name == 'RM':
            compartment.Rm = value / (math.pi * compartment.diameter *
                                      compartment.length)
        elif name == 'RA':
            compartment.Ra = value * compartment.length / \
                    (math.pi*(compartment.diameter/2.0)**2)
        elif name == 'Em':
            compartment.Em = value
        elif name == 'initVm':
            compartment.initVm = value
        elif name == 'inject':
            msg = " {0} inject {1} A.".format(compartment.name, value)
            debug.printDebug("INFO", msg)
            compartment.inject = value
        elif mechName is 'synapse':

            # synapse being added to the compartment
            # these are potential locations, we do not actually make synapses.
            # I assume below that compartment name has _segid at its end

            # get segment id from compartment name
            segid = moose_methods.getCompartmentId(compartment.name)
            self.segDict[segid][5].append(value)

        # spikegen being added to the compartment
        elif mechName is 'spikegen':
            # these are potential locations, we do not actually make the
            # spikegens.  spikegens for different synapses can have different
            # thresholds, hence include synapse_type in its name value contains
            # name of synapse i.e. synapse_type
            #spikegen = moose.SpikeGen(compartment.path+'/'+value+'_spikegen')
            #moose.connect(compartment,"VmSrc",spikegen,"Vm")
            pass
        elif mechName is not None:

            # if mechanism is not present in compartment, deep copy from library
            if not moose.exists(compartment.path + '/' + mechName):

                # if channel does not exist in library load it from xml file
                if not moose.exists(self.libraryPath + "/" + mechName):
                    cmlR = ChannelML(self.nml_params)
                    model_filename = mechName + '.xml'
                    model_path = neuroml_utils.find_first_file(
                        model_filename, self.model_dir)
                    if model_path is not None:
                        cmlR.readChannelMLFromFile(model_path)
                    else:
                        msg = 'Mechanism {0}: files {1} not found under {2}'\
                                .format( mechName
                                        , model_filename
                                        , self.model_dir
                                        )
                        debug.printDebug("ERROR",
                                         msg,
                                         frame=inspect.currentframe())
                        sys.exit(0)

                neutralObj = moose.Neutral(self.libraryPath + "/" + mechName)

                # Ion concentration pool
                if 'CaConc' == neutralObj.className:
                    libcaconc = moose.CaConc(self.libraryPath + "/" + mechName)

                    # deep copies the library caconc under the compartment
                    caconc = moose.copy(libcaconc, compartment, mechName)
                    caconc = moose.CaConc(caconc)

                    # CaConc connections are made later using connect_CaConc()
                    # Later, when calling connect_CaConc, B is set for caconc
                    # based on thickness of Ca shell and compartment l and dia
                    # OR based on the Mstring phi under CaConc path.
                    channel = None

                elif 'HHChannel2D' == neutralObj.className:  ## HHChannel2D
                    libchannel = moose.HHChannel2D(self.libraryPath + "/" +
                                                   mechName)
                    ## deep copies the library channel under the compartment
                    channel = moose.copy(libchannel, compartment, mechName)
                    channel = moose.HHChannel2D(channel)
                    moose.connect(channel, 'channel', compartment, 'channel')
                elif 'HHChannel' == neutralObj.className:  ## HHChannel
                    libchannel = moose.HHChannel(self.libraryPath + "/" +
                                                 mechName)

                    # deep copies the library channel under the compartment
                    channel = moose.copy(libchannel, compartment, mechName)
                    channel = moose.HHChannel(channel)
                    moose.connect(channel, 'channel', compartment, 'channel')
            # if mechanism is present in compartment, just wrap it
            else:
                neutralObj = moose.Neutral(compartment.path + '/' + mechName)
                # Ion concentration pool
                if 'CaConc' == neutralObj.className:
                    # wraps existing channel
                    caconc = moose.CaConc(compartment.path + '/' + mechName)
                    channel = None
                elif 'HHChannel2D' == neutralObj.className:  ## HHChannel2D
                    # wraps existing channel
                    channel = moose.HHChannel2D(compartment.path + '/' +
                                                mechName)
                elif 'HHChannel' == neutralObj.className:  ## HHChannel
                    # wraps existing channel
                    channel = moose.HHChannel(compartment.path + '/' +
                                              mechName)
            if name == 'Gbar':
                # if CaConc, neuroConstruct uses gbar for thickness or phi
                if channel is None:
                    # If child Mstring 'phi' is present, set gbar as phi BUT,
                    # value has been multiplied by Gfactor as a Gbar, SI or
                    # physiological not known here, ignoring Gbar for CaConc,
                    # instead of passing units here
                    child = moose_utils.get_child_Mstring(caconc, 'phi')
                    if child is not None:
                        #child.value = value
                        pass
                    else:
                        #caconc.thick = value
                        pass
                else:  # if ion channel, usual Gbar
                    channel.Gbar = value * math.pi * compartment.diameter \
                            * compartment.length
            elif name == 'Ek':
                channel.Ek = value

            # thick seems to be NEURON's extension to NeuroML level 2.
            elif name == 'thick':
                # JUST THIS WILL NOT DO - HAVE TO SET B based on this thick!
                caconc.thick = value
                # Later, when calling connect_CaConc, B is set for caconc based
                # on thickness of Ca shell and compartment l and dia.  OR based
                # on the Mstring phi under CaConc path.

        if neuroml_utils.neuroml_debug:
            msg = "Setting {0} for {1} value {2}".format(
                name, compartment.path, value)
            debug.printDebug("DEBUG", msg, frame=inspect.currentframe())
コード例 #29
0
ファイル: minchan.py プロジェクト: lhhhu1990/moose
def makeElecPlots():
    graphs = moose.Neutral('/graphs')
    elec = moose.Neutral('/graphs/elec')
    addPlot('/model/elec/soma', 'getVm', 'elec/somaVm')
    addPlot('/model/elec/spine_head', 'getVm', 'elec/spineVm')
    addPlot('/model/elec/soma/Ca_conc', 'getCa', 'elec/somaCa')
def main():
    library = moose.Neutral('/library')
    #makePassiveSoma( 'cell', params['dendL'], params['dendDia'] )
    makeDendProto()
    makeChemProto()
    rdes = rd.rdesigneur(
        turnOffElec=True,
        chemPlotDt=0.1,
        diffusionLength=params['diffusionL'],
        #cellProto=[['cell','soma']],
        cellProto=[['elec', 'dend']],
        chemProto=[['hydra', 'hydra']],
        chemDistrib=[['hydra', '#soma#,#dend#', 'install', '1']],
        plotList=[['soma', '1', 'dend/A', 'n', '# of A'],
                  ['soma', '1', 'dend/B', 'n', '# of B'],
                  ['soma', '1', 'dend/C', 'n', '# of C'],
                  ['soma', '1', 'dend/D', 'n', '# of D'],
                  ['soma', '1', 'dend/E', 'n', '# of E'],
                  ['soma', '1', 'dend/F', 'n', '# of F']],
        #    moogList = [['soma', '1', 'dend/A', 'n', 'num of A (number)']]
    )
    moose.le('/library')
    moose.le('/library/hydra')
    #moose.showfield( '/library/soma/soma' )
    rdes.buildModel()
    #moose.element('/model/chem/dend/B').vec[50].nInit=15.5

    A = moose.element('/model/chem/dend/A')
    B = moose.element('/model/chem/dend/B')
    C = moose.element('/model/chem/dend/C')
    D = moose.element('/model/chem/dend/D')
    E = moose.element('/model/chem/dend/E')
    F = moose.element('/model/chem/dend/F')
    Z1 = moose.element('/model/chem/dend/Z1')
    Z2 = moose.element('/model/chem/dend/Z2')

    A.diffConst = 1e-13
    B.diffConst = 1e-13
    C.diffConst = 1e-13
    D.diffConst = 1e-13
    E.diffConst = 1e-13
    F.diffConst = 1e-13
    Z1.diffConst = 0
    Z2.diffConst = 0

    #moose.element('/model/chem/dend/Z1').vec.nInit = 0
    moose.element('/model/chem/dend/Z1').vec.nInit = 1
    #moose.element('/model/chem/dend/Z2').vec.nInit = 0
    moose.element('/model/chem/dend/Z2').vec.nInit = 1
    #for i in range(50,55):
    # moose.element('/model/chem/dend/Z1').vec[i].nInit = 1
    # moose.element('/model/chem/dend/Z2').vec[i].nInit = 1

    moose.element('/model/chem/dend/A').vec[20].nInit = 1
    moose.element('/model/chem/dend/B').vec[20].nInit = 1
    moose.element('/model/chem/dend/C').vec[20].nInit = 1
    #moose.element('/model/chem/dend/D').vec[30].nInit=2
    #moose.element('/model/chem/dend/E').vec[30].nInit=2
    #moose.element('/model/chem/dend/F').vec[30].nInit=2
    moose.element('/model/chem/dend/D').vec[60].nInit = 1
    moose.element('/model/chem/dend/E').vec[60].nInit = 1
    moose.element('/model/chem/dend/F').vec[60].nInit = 1
    #moose.element('/model/chem/dend/A').vec[120].nInit=1
    #moose.element('/model/chem/dend/B').vec[120].nInit=1
    #moose.element('/model/chem/dend/C').vec[120].nInit=1
    #moose.element('/model/chem/dend/D').vec[160].nInit=1
    #moose.element('/model/chem/dend/E').vec[160].nInit=1
    #moose.element('/model/chem/dend/F').vec[160].nInit=1
    storeAvec = []
    storeBvec = []
    storeCvec = []
    storeDvec = []
    storeEvec = []
    storeFvec = []

    moose.reinit()
    for i in range(1, 5000, 10):
        moose.start(10)
        avec = moose.vec('/model/chem/dend/A').n
        bvec = moose.vec('/model/chem/dend/B').n
        cvec = moose.vec('/model/chem/dend/C').n
        dvec = moose.vec('/model/chem/dend/D').n
        evec = moose.vec('/model/chem/dend/E').n
        fvec = moose.vec('/model/chem/dend/F').n
        storeAvec.append(avec)
        storeBvec.append(bvec)
        storeCvec.append(cvec)
        storeDvec.append(dvec)
        storeEvec.append(evec)
        storeFvec.append(fvec)

    return storeAvec, storeBvec, storeCvec, storeDvec, storeEvec, storeFvec