Example #1
0
 def createPopulations(self):
     self.populationDict = {}
     for population in self.network.findall(".//{" + nml_ns +
                                            "}population"):
         cellname = population.attrib["cell_type"]
         populationname = population.attrib["name"]
         print "loading", populationname
         ## if channel does not exist in library load it from xml file
         if not self.context.exists('/library/' + cellname):
             mmlR = MorphML(self.nml_params)
             cellDict = mmlR.readMorphMLFromFile(cellname + '.morph.xml')
             self.cellSegmentDict.update(cellDict)
         libcell = moose.Cell('/library/' + cellname)
         self.populationDict[populationname] = (cellname, {})
         for instance in population.findall(".//{" + nml_ns + "}instance"):
             instanceid = instance.attrib['id']
             location = instance.find('./{' + nml_ns + '}location')
             rotationnote = instance.find('./{' + meta_ns + '}notes')
             if rotationnote is not None:
                 ## the text in rotationnote is zrotation=xxxxxxx
                 zrotation = float(string.split(rotationnote.text, '=')[1])
             else:
                 zrotation = 0
             ## deep copies the library cell to an instance
             cell = moose.Cell(libcell,
                               "/" + populationname + "_" + instanceid)
             self.populationDict[populationname][1][int(instanceid)] = cell
             x = float(location.attrib['x']) * self.length_factor
             y = float(location.attrib['y']) * self.length_factor
             z = float(location.attrib['z']) * self.length_factor
             self.translate_rotate(cell, x, y, z, zrotation)
Example #2
0
def test_twocomp(sim):
    """Pass a simulation object as parameter"""
    spine_area_mult = 2.0
    cell = moose.Cell('mycell', sim.model)
    soma = MyCompartment('soma', cell)
    soma.length = 20e-6
    soma.diameter = 2 * 7.5e-6
    soma.Em = -65e-3
    soma.initVm = -65e-3
    soma.setSpecificCm(9e-3)
    soma.setSpecificRm(5.0)
    soma.setSpecificRa(2.5)
    
    dend = MyCompartment('dend', cell)
    dend.length = 40e-6
    dend.diameter = 2 * 1.06e-6
    dend.Em = -65e-3
    dend.initVm = -65e-3
    dend.setSpecificCm(9e-3 * spine_area_mult)
    dend.setSpecificRm(5.0 / spine_area_mult)
    dend.setSpecificRa(2.5)
    soma.traubConnect(dend)
    vm_table = dend.insertRecorder("Vm1", "Vm", sim.data)
    dend.insertPulseGen("pulsegen1", sim.model, firstLevel=3e-10, firstDelay=20e-3, firstWidth=100e-3)
#     sim.schedule()
#     sim.run(100e-3)
#     sim.dump_data("data")
    return cell
Example #3
0
def test_copy():
    cellcount = 100
    proto = SpinyStellate.prototype
    cells = []
    start_0 = datetime.now()
    for ii in range(cellcount):
        start = datetime.now()
        cell = moose.Cell(proto, 'cell' + str(ii))
        end = datetime.now()
        delta = end - start
        config.BENCHMARK_LOGGER.info(
            'TEST1 - %d: %g s.' %
            (ii, delta.seconds + 1e-6 * delta.microseconds))
        cells.append(cell)
    end_0 = datetime.now()
    delta_0 = end_0 - start_0
    config.BENCHMARK_LOGGER.info(
        'TEST1: %g s.' % (delta_0.seconds + 1e-6 * delta_0.microseconds))

    config.BENCHMARK_LOGGER.info('TEST2.A: Starting making TraubCell copies.')
    ss = []
    start_0 = datetime.now()
    for ii in range(cellcount):
        start = datetime.now()
        cell = SpinyStellate(proto, 'ss' + str(ii))
        end = datetime.now()
        ss.append(cell)
        delta = end - start
        config.BENCHMARK_LOGGER.info(
            'TEST2.A - %d: %g s.' %
            (ii, delta.seconds + 1e-6 * delta.microseconds))
    end_0 = datetime.now()
    config.BENCHMARK_LOGGER.info('TEST2.A: %d s.' %
                                 (delta.seconds + 1e-6 * delta.microseconds))
 def loadCell(self):
     self.context.readCell('gran_aditya_migliore.p',self.path)
     self._gran = moose.Cell(self.path)
     self._granSoma = moose.Compartment(self.path+'/soma')
     self._granSomaKA = moose.Compartment(self.path+'/soma/KA_ms')
     self._granPeri = moose.Compartment(self.path+'/periphery')
     self._granPeriNa = moose.HHChannel(self.path+'/periphery/Na_rat_ms')
     self._granPeriKA = moose.HHChannel(self.path+'/periphery/KA_ms')
Example #5
0
def printNetTree():
    """ Prints all the cells under /, and recursive prints the cell tree for each cell. """
    root = moose.Neutral("/")
    for id in root.children:  # all subelements of 'root'
        if moose.Neutral(id).className == "Cell":
            cell = moose.Cell(id)
            print(
                "-------------------- CELL : ",
                cell.name,
                " ---------------------------",
            )
            printCellTree(cell)
Example #6
0
    def read_proto(cls,
                   filename,
                   cellname,
                   level_dict=None,
                   depth_dict=None,
                   params=None):
        """Read a prototype cell from .p file into library.  

        Each cell type class should initialize its prototype with a
        call to this function. with something like this within the
        class declaration:

        prototype = TraubCell.read_proto("MyCellType.p", "MyClassName")

        filename -- path(relative/absolute) of the cell prototype file.

        cellname -- path of the cell to be Created

        params -- if specified, channels in /library are adjusted with
        the parameters specified in this (via a call to
        adjust_chanlib).

        """
        config.LOGGER.debug('Reading proto:%s' % (filename))
        if params is not None:
            TraubCell.adjust_chanlib(params)
        ret = None
        cellpath = config.lib.path + '/' + cellname
        if not config.context.exists(cellpath):
            config.LOGGER.debug(__name__ + ' reading cell: ' + cellpath)
            for handler in config.LOGGER.handlers:
                handler.flush()
            config.context.readCell(filename, cellpath)
        else:
            config.LOGGER.debug(__name__ + ' cell exists: ' + cellpath)
        ret = moose.Cell(cellpath)
        # TraubCell.generate_morphology(ret)
        if (depth_dict is not None) and (level_dict is not None):
            for level, comp_nos in level_dict.items():
                try:
                    depth = depth_dict[level]
                    for comp_no in comp_nos:
                        comp = get_comp(ret, comp_no)
                        comp.z = depth
                except KeyError:
                    print 'No depth info for level %s' % (level)

        config.LOGGER.debug('Returning cell %s' % (ret.path))
        for handler in config.LOGGER.handlers:
            handler.flush()
        return ret
Example #7
0
 def loadCell(self):
     self.context.readCell('mit_aditya_davison_reduced.p', self.path)
     self._mitral = moose.Cell(self.path)
     self._mitralSoma = moose.Compartment(self.path + '/soma')
     self._mitralGlom = moose.Compartment(self.path + '/glom')
     self._mitralDend = moose.Compartment(self.path + '/dend')
     self._mitralDendNa = moose.HHChannel(self.path + '/dend/Na_mit_usb')
     self._mitralSomaNa = moose.HHChannel(self.path + '/soma/Na_mit_usb')
     self._mitralSomaCaPool = moose.CaConc(self.path + '/soma/Ca_mit_conc')
     self._mitralSomaLCa = moose.HHChannel(self.path + '/soma/LCa3_mit_usb')
     self._mitralSomaKCa = moose.HHChannel(self.path + '/soma/Kca_mit_usb')
     # Connect the LCa current to the Ca Pool
     self._mitralSomaLCa.connect('IkSrc', self._mitralSomaCaPool, 'current')
     # Connect the KCa channel to the Ca concentration of Ca Pool
     self._mitralSomaCaPool.connect('concSrc', self._mitralSomaKCa,
                                    'concen')
Example #8
0
# 
# 

# Code:

from subprocess import call
call(['/home/subha/neuron/nrn/x86_64/bin/nrngui', 'test_suppyrRS_1comp.hoc'], cwd='../nrn')
from datetime import datetime
import moose
import config
from cell import *
from capool import CaPool
from compartment import MyCompartment
from simulation import Simulation
sim = Simulation()
cell = moose.Cell('cell', sim.model)
soma = MyCompartment('soma', cell)
soma.diameter = 16e-6
soma.length = 15e-6
soma.Em = -70e-3
soma.initVm = -65e-3
soma.setSpecificRm(5.0)
soma.setSpecificRa(2.5)
soma.setSpecificCm(9e-3)
soma.insertChannel('NaF', specificGbar=1875.0, Ek=50e-3, shift=-3.5e-3)
soma.insertChannel('CaL', specificGbar=10.0, Ek=125e-3)
soma.insertCaPool(2600000.0, 100e-3)
vmTable = soma.insertRecorder('Vm', 'Vm', sim.data)
caTable = moose.Table('ca', sim.data)
caTable.stepMode = 3
soma.ca_pool.connect('Ca', caTable, 'inputRequest')