Пример #1
0
def func2map(i):
    cell = h.Import3d_SWC_read()
    print(len(nfs))
    print(i)
    morphology_filename = nfs[i]
    cell = h.Import3d_SWC_read()
    cell.input(morphology_filename)
    i3d = h.Import3d_GUI(cell, 0)
    i3d.instantiate(None)
    file_name = str(nfs[i]) + str('.wrl')
    print(file_name)
    ctng(show=False, magnification=200, file_name=file_name)
    mlab.savefig(str(nfs[i]) + '.wrl')
Пример #2
0
def initialize_neuron(swc_path, file_paths):
    h.load_file("stdgui.hoc")
    h.load_file("import3d.hoc")

    swc = h.Import3d_SWC_read()
    swc.input(swc_path)
    imprt = h.Import3d_GUI(swc, 0)
    h("objref this")
    imprt.instantiate(h.this)

    print file_paths

    for sec in h.allsec():
        if sec.name().startswith("axon"):
            h.delete_section(sec=sec)

    axon = h.Section()
    axon.L = 60
    axon.diam = 1
    axon.connect(h.soma[0], 0.5, 0)

    h.define_shape()

    for sec in h.allsec():
        sec.insert('pas')
        for seg in sec:
            seg.pas.e = 0

    for file_path in file_paths:
        h.load_file(file_path.encode("ascii", "ignore"))
Пример #3
0
    def build_morphology(self):
        """
        Loads a 3D morphology of the neuron
        """
        # Load hoc routines to import 3D morphologies
        h.load_file('stdlib.hoc')
        h.load_file("import3d.hoc")
        cell = h.Import3d_SWC_read()  # We have a .swc morphology file
        #cell = h.Import3d_Neurolucida3() # We have an .asc morphology file

        # Read the file and creates automatically section.connect(parent) statements
        cell.input('Pyr_01.swc')

        # Instantiate morphology for simulation and
        # execute the connect statements and loads the cell into h scope
        self.importedcell = h.Import3d_GUI(cell, 0)
        self.importedcell.instantiate(None)

        # Create python lists from the morphology with the different sections: soma, dend, apic and axon
        self.soma = []
        self.dend = []
        self.apic = []
        self.axon = []  # for the moment we will forget about the axon
        self.all = []
        for sec in h.allsec():
            if 'soma' in sec.name():
                self.soma.append(sec)
            if 'dend' in sec.name():
                self.dend.append(sec)
            if 'apic' in sec.name():
                self.apic.append(sec)
            if 'axon' in sec.name():
                self.axon.append(sec)
Пример #4
0
    def load_morpho(self, filepath):
        """
        :param filepath:
            swc file path
        """
        if not path.exists(filepath):
            raise FileNotFoundError(filepath)

        # SWC
        fileformat = filepath.split('.')[-1]
        if fileformat == 'swc':
            morpho = h.Import3d_SWC_read()
        # Neurolucida
        elif fileformat == 'asc':
            morpho = h.Import3d_Neurolucida3()
        else:
            raise Exception('file format `%s` not recognized' % filepath)

        self.all = []
        morpho.input(filepath)
        i3d = h.Import3d_GUI(morpho, 0)
        i3d.instantiate(self)

        for hoc_sec in self.all:
            name = hoc_sec.name().split('.')[-1]  # eg. name="dend[19]"
            if len(self.filter_secs(name)) > 0:
                raise LookupError(
                    "The name '%s' is already taken by another section of the cell: '%s' of type: '%s'."
                    % (name, self.name, self.__class__.__name__))
            sec = Sec(hoc_sec, cell=self, name=name)
            self.secs.append(sec)

        del self.all
Пример #5
0
def load_morphology(filename):
    h = get_h()
    swc = h.Import3d_SWC_read()
    swc.input(str(filename))
    imprt = h.Import3d_GUI(swc, 0)
    h("objref this")
    imprt.instantiate(h.this)
Пример #6
0
def import_swc_cell(path):

    morph = h.Import3d_SWC_read()
    morph.input(path)

    i3d = h.Import3d_GUI(morph, 0)
    i3d.instantiate(h.nil)

    return i3d
Пример #7
0
def set_morphology(hobj, morph_file):
    """Set morphology for the cell from a swc

    :param hobj: NEURON's cell object
    :param morph_file: name of swc file containing 3d coordinates of morphology
    """
    swc = h.Import3d_SWC_read()
    swc.quiet = True
    swc.input(str(morph_file))
    imprt = h.Import3d_GUI(swc, 0)
    imprt.quiet = True
    imprt.instantiate(hobj)
Пример #8
0
def create_morph(swc_file, template):
    h.load_file("import3d.hoc")
    h.load_file("nrngui.hoc")
    h("objref cell, tobj")
    h.load_file(template + ".hoc")
    h.execute("cell = new " + template + "()")  #replace
    nl = h.Import3d_SWC_read()
    nl.quiet = 1
    nl.input(swc_file)
    imprt = h.Import3d_GUI(nl, 0)
    imprt.instantiate(h.cell)
    return h.cell
Пример #9
0
    def _load_geometry(self):
        '''Load the morphology-file in NEURON'''
        try:
            h.sec_counted = 0
        except LookupError:
            h('sec_counted = 0')

        #import the morphology, try and determine format
        fileEnding = self.morphology.split('.')[-1]
        if fileEnding == 'hoc' or fileEnding == 'HOC':
            h.load_file(1, self.morphology)
        elif fileEnding == 'py':
            geom_func = imp.load_source('shape_3D', self.morphology)
            geom_func.shape_3D(self)
        else:
            neuron.h('objref this')
            if fileEnding == 'asc' or fileEnding == 'ASC':
                Import = h.Import3d_Neurolucida3()
                if not self.verbose:
                    Import.quiet = 1
            elif fileEnding == 'swc' or fileEnding == 'SWC':
                Import = h.Import3d_SWC_read()
            elif fileEnding == 'xml' or fileEnding == 'XML':
                Import = h.Import3d_MorphML()
            else:
                raise ValueError(
                    '%s is not a recognised morphology file format!'
                ).with_traceback('Should be either .hoc, .asc, .swc, .xml!' %
                                 self.morphology)

            #assuming now that morphologies file is the correct format
            try:
                Import.input(self.morphology)
            except:
                if not hasattr(neuron, 'neuroml'):
                    raise Exception('Can not import, try and copy the ' + \
                    'nrn/share/lib/python/neuron/neuroml ' + \
                    'folder into %s' % neuron.__path__[0])
                else:
                    raise Exception('something wrong with file, see output')
            try:
                imprt = neuron.h.Import3d_GUI(Import, 0)
            except:
                raise Exception('See output, try to correct the file')
            imprt.instantiate(neuron.h.this)

        h.define_shape()
        self._create_sectionlists()
Пример #10
0
def swc2morph(swc_file: str):
    """
    Generate morph sectioning data from .swc file.
    """
    if HAS_NEURON:
        h.load_file('stdlib.hoc')
        h.load_file('import3d.hoc')

        cell = h.Import3d_SWC_read()
        cell.input(swc_file)

        i3d = h.Import3d_GUI(cell, 0)
        i3d.instantiate(None)
        return neuron2morph(h)

    else:
        print("NEURON module is not available.")
Пример #11
0
def mkswc(swc_contents):
  f = open("temp.tmp", "w")
  f.write(swc_contents)
  f.close()
  swc = h.Import3d_SWC_read()
  swc.input("temp.tmp")
  ig = h.Import3d_GUI(swc)
  ig.box.unmap()
  h.doNotify()
  ig.box.map("Import3d", 650, 200, -1, -1)
  h.doNotify()
  ig.instantiate(None)

  print (swc_contents)
  h.topology()
  print (secinfo())
  print ("\n\n\n")
  return ig
Пример #12
0
def swc2morph(swc_file):
    """
    Generate morph sectioning data from swc file.
    """

    from neuron import h
    h.load_file('stdlib.hoc')
    h.load_file('import3d.hoc')

    cell = h.Import3d_SWC_read()
    cell.input(swc_file)

    i3d = h.Import3d_GUI(cell, 0)
    i3d.instantiate(None)

    sections = {}

    for sec in h.allsec():
        sections[sec.name()] = {}
        sections[sec.name()]["name"] = sec.name()
        sr = h.SectionRef(sec=sec)
        if sr.has_parent():
            parent = sr.parent.name()
        else:
            parent = None
        sections[sec.name()]["parent"] = parent

        children = []
        for child in sr.child:
            children.append(child.name())

        sections[sec.name()]["children"] = children
        x = []
        y = []
        z = []
        d = []
        n3d = int(h.n3d())
        sections[sec.name()]["points"] = []
        for i in range(n3d):
            sections[sec.name()]["points"].append(
                [h.x3d(i), h.y3d(i), h.z3d(i),
                 h.diam3d(i)])
    return sections
Пример #13
0
    def _load_morphology(self, Jonas_cell):
        ''' internal function: loads morphology and creates section lists'''
        fileEnding = self.morphology.split('.')[-1]
        if fileEnding == 'hoc':
            h.load_file(1, self.morphology)
        else:
            h('objref this')  # why do i need this?
            if fileEnding == 'swc':
                Import = h.Import3d_SWC_read()
                Import.input(self.morphology)
                imprt = h.Import3d_GUI(Import, 0)
            imprt.instantiate(h.this)
        h.define_shape()  # not sure what this does either

        # set up section names: You need to clarify differences between h.allsec(), h.SectionList() - just makes a new #sectionlist - to do with if have multple cells?
        self.all_section_names = []
        self.sec_list = h.SectionList()
        self.nsec = 0
        self.dendrites = h.SectionList(
        )  # maybe these should be h.SectionList()? rather than python lists
        self.axon = h.SectionList()
        self.soma = h.SectionList()
        self.root = 'none'

        for sec in h.allsec():
            self.all_section_names.append(sec.name())
            self.sec_list.append(sec=sec)
            self.nsec += 1
            # Set up categories for different cell regions
            if sec.name().find('soma') >= 0:
                self.soma.append(sec=sec)
                if sec.name().find('0') >= 0:
                    self.root = sec
                    if self.verbose:
                        print(sec.name(), 'is root')
                elif Jonas_cell:
                    self.root = sec
            if sec.name().find('dend') >= 0:
                self.dendrites.append(sec=sec)
            if sec.name().find('axon') >= 0:
                self.dendrites.append(sec=sec)
Пример #14
0
    def load_morpho(self, filepath, seg_per_L_um=1.0, add_const_segs=11):
        """
        :param filepath:
            swc file path
        :param seg_per_L_um:
            how many segments per single um of L, Length.  Can be < 1. None is 0.
        :param add_const_segs:
            how many segments have each section by default.
            With each um of L this number will be increased by seg_per_L_um
        """
        if not path.exists(filepath):
            raise FileNotFoundError()

        # SWC
        fileformat = filepath.split('.')[-1]
        if fileformat == 'swc':
            morpho = h.Import3d_SWC_read()
        # Neurolucida
        elif fileformat == 'asc':
            morpho = h.Import3d_Neurolucida3()
        else:
            raise Exception('file format `%s` not recognized' % filepath)

        morpho.input(filepath)
        h.Import3d_GUI(morpho, 0)
        i3d = h.Import3d_GUI(morpho, 0)
        i3d.instantiate(self)

        # add all SWC sections to self.secs; self.all is defined by SWC import
        new_secs = {}
        for sec in self.all:
            name = sec.name().split('.')[-1]  # eg. name="dend[19]"
            new_secs[name] = sec

        # change segment number based on seg_per_L_um and add_const_segs
        for sec in new_secs.values():
            add = int(sec.L * seg_per_L_um) if seg_per_L_um is not None else 0
            sec.nseg = add_const_segs + add

        self.secs.update(new_secs)
        del self.all
Пример #15
0
def initialize_neuron(swc_path, file_paths):
    """ Initialize neuron with morphology and load hoc files

    Parameters
    ----------
    swc_path : str
        Path to SWC file
    file_paths : list
        List of str file paths of files for NEURON to load

    """
    h.load_file("stdgui.hoc")
    h.load_file("import3d.hoc")

    swc = h.Import3d_SWC_read()
    swc.input(swc_path)
    imprt = h.Import3d_GUI(swc, 0)
    h("objref this")
    imprt.instantiate(h.this)

    for sec in h.allsec():
        if sec.name().startswith("axon"):
            h.delete_section(sec=sec)

    axon = h.Section()
    axon.L = 60
    axon.diam = 1
    axon.connect(h.soma[0], 0.5, 0)

    h.define_shape()

    for sec in h.allsec():
        sec.insert('pas')
        for seg in sec:
            seg.pas.e = 0

    for file_path in file_paths:
        h.load_file(file_path.encode("ascii", "ignore"))
def instantiate_swc(filename):
    """load an swc file and instantiate it"""

    ### I have done this already: ###########################################
    ## load the NEURON library (just in case h is defined otherwise elsewhere)
    #from neuron import h, gui

    ## a helper library, included with NEURON
    #h.load_file('import3d.hoc')
    #########################################################################

    # load the data. Use Import3d_SWC_read for swc, Import3d_Neurolucida3 for
    # Neurolucida V3, Import3d_MorphML for MorphML (level 1 of NeuroML), or
    # Import3d_Eutectic_read for Eutectic. (There is also an
    # Import3d_Neurolucida_read for old Neurolucida files, but I've never seen one
    # in practice; try Import3d_Neurolucida3 first.)
    cell = h.Import3d_SWC_read()
    cell.input(filename)

    # easiest to instantiate by passing the loaded morphology to the Import3d_GUI
    # tool; with a second argument of 0, it won't display the GUI, but it will allow
    # use of the GUI's features
    i3d = h.Import3d_GUI(cell, 0)
    i3d.instantiate(None)
Пример #17
0
    dx = 0.25
    has_dx = False

if len(sys.argv) > 3 or (not has_dx and len(sys.argv) == 3):
    filename_out = sys.argv[2]

from neuron import h
from mayavi import mlab
import geometry3d
import time

h.load_file('stdlib.hoc')
h.load_file('import3d.hoc')

if filename.lower()[-4:] == '.swc':
    cell = h.Import3d_SWC_read()
else:
    cell = h.Import3d_Neurolucida3()
cell.input(filename)

start = time.time()
tri_mesh = geometry3d.surface(cell, dx, n_soma_step=100, nouniform=nouniform)
mlab.triangular_mesh(tri_mesh.x, tri_mesh.y, tri_mesh.z, tri_mesh.faces, color=(1, 0, 0))
print 'time to construct mesh:', time.time() - start

start = time.time()
area = tri_mesh.area
print 'area: ', area
print 'time to compute area:', time.time() - start

start = time.time()
Пример #18
0
def load(filename,
         fileformat=None,
         cell=None,
         use_axon=True,
         xshift=0,
         yshift=0,
         zshift=0):
    """
    Load an SWC from filename and instantiate inside cell. Code kindly provided
    by @ramcdougal.

    Args:
        filename = .swc file containing morphology
        cell = Cell() object. (Default: None, creates new object)
        filename = the filename of the SWC file
        use_axon = include the axon? Default: True (yes)
        xshift, yshift, zshift = use to position the cell

    Returns:
        Cell() object with populated soma, axon, dend, & apic fields

    Minimal example:
        # pull the morphology for the demo from NeuroMorpho.Org
        from PyNeuronToolbox import neuromorphoorg
        with open('c91662.swc', 'w') as f:
            f.write(neuromorphoorg.morphology('c91662'))
        cell = load_swc(filename)

    """

    if cell is None:
        cell = Cell(name=string.join(filename.split('.')[:-1]))

    if fileformat is None:
        fileformat = filename.split('.')[-1]

    name_form = {1: 'soma[%d]', 2: 'axon[%d]', 3: 'dend[%d]', 4: 'apic[%d]'}

    # load the data. Use Import3d_SWC_read for swc, Import3d_Neurolucida3 for
    # Neurolucida V3, Import3d_MorphML for MorphML (level 1 of NeuroML), or
    # Import3d_Eutectic_read for Eutectic.
    if fileformat == 'swc':
        morph = h.Import3d_SWC_read()
    elif fileformat == 'asc':
        morph = h.Import3d_Neurolucida3()
    else:
        raise Exception('file format `%s` not recognized' % (fileformat))
    morph.input(filename)

    # easiest to instantiate by passing the loaded morphology to the Import3d_GUI
    # tool; with a second argument of 0, it won't display the GUI, but it will allow
    # use of the GUI's features
    i3d = h.Import3d_GUI(morph, 0)

    # get a list of the swc section objects
    swc_secs = i3d.swc.sections
    swc_secs = [swc_secs.object(i) for i in xrange(int(swc_secs.count()))]

    # initialize the lists of sections
    sec_list = {1: cell.soma, 2: cell.axon, 3: cell.dend, 4: cell.apic}

    # name and create the sections
    real_secs = {}
    for swc_sec in swc_secs:
        cell_part = int(swc_sec.type)

        # skip everything else if it's an axon and we're not supposed to
        # use it... or if is_subsidiary
        if (not (use_axon) and cell_part == 2) or swc_sec.is_subsidiary:
            continue

        # figure out the name of the new section
        if cell_part not in name_form:
            raise Exception('unsupported point type')
        name = name_form[cell_part] % len(sec_list[cell_part])

        # create the section
        sec = h.Section(name=name)

        # connect to parent, if any
        if swc_sec.parentsec is not None:
            sec.connect(real_secs[swc_sec.parentsec.hname()](swc_sec.parentx))

        # define shape
        if swc_sec.first == 1:
            h.pt3dstyle(1,
                        swc_sec.raw.getval(0, 0),
                        swc_sec.raw.getval(1, 0),
                        swc_sec.raw.getval(2, 0),
                        sec=sec)

        j = swc_sec.first
        xx, yy, zz = [swc_sec.raw.getrow(i).c(j) for i in xrange(3)]
        dd = swc_sec.d.c(j)
        if swc_sec.iscontour_:
            # never happens in SWC files, but can happen in other formats supported
            # by NEURON's Import3D GUI
            raise Exception('Unsupported section style: contour')

        if dd.size() == 1:
            # single point soma; treat as sphere
            x, y, z, d = [dim.x[0] for dim in [xx, yy, zz, dd]]
            for xprime in [x - d / 2., x, x + d / 2.]:
                h.pt3dadd(xprime + xshift, y + yshift, z + zshift, d, sec=sec)
        else:
            for x, y, z, d in zip(xx, yy, zz, dd):
                h.pt3dadd(x + xshift, y + yshift, z + zshift, d, sec=sec)

        # store the section in the appropriate list in the cell and lookup table
        sec_list[cell_part].append(sec)
        real_secs[swc_sec.hname()] = sec

    cell.all = cell.soma + cell.apic + cell.dend + cell.axon
    return cell
Пример #19
0
lng = []
GRs = []
mean_lng = []
max_lng = []
Total_lng = []
max_BO = []
mean_BO = []
max_PL = []
min_PL = []
mean_PL = []
symm = []

for i in range(len(qual_files_list)):
    print qual_files_list[i]
    h.load_file('import3d.hoc')
    Import3d = h.Import3d_SWC_read()

    Import3d.input(qual_files_list[i])

    imprt = h.Import3d_GUI(Import3d, 0)
    imprt.instantiate(None)
    print qual_files_list[i]
    num_axon_sec = 0
    for sec in h.allsec():
        if (str(sec)[0:2] == "ax"):
            num_axon_sec = num_axon_sec + 1

    tbl = []
    for sec in range(num_axon_sec - 1):
        tbl.append([
            sec, h.axon[sec].L, h.axon[sec].diam,
    def __init__(self, params=defparams, factors=None):
        Import = h.Import3d_SWC_read()
        Import.input(morphology + 'latest_WT-P270-20-14ak.swc')
        imprt = h.Import3d_GUI(Import, 0)
        imprt.instantiate(None)
        h.define_shape()
        # h.cao0_ca_ion = 2  # default in nrn
        h.celsius = 35
        self._create_sectionlists()
        self._set_nsegs()
        self.v_init = -80
        for sec in self.allseclist:
            sec.Ra = 150
            sec.cm = 1.0
            sec.insert('pas')
            #sec.g_pas = 1e-5 # set using json file
            sec.e_pas = -70 # -73
        for sec in self.somalist:
            sec.insert('naf')
            sec.insert('kaf')
            sec.insert('kas')
            sec.insert('kdr')
            sec.insert('kir')
            sec.ena = 50
            sec.ek = -85 # -90
            sec.insert('cal12')
            sec.insert('cal13')
            sec.insert('car')
            sec.insert('cadyn')
            sec.insert('caldyn')
            sec.insert('sk')
            sec.insert('bk')
            sec.insert('can')
	    #sec.kb_cadyn = 200.
        for sec in self.axonlist:
            sec.insert('naf')
            #sec.insert('kaf')
            sec.insert('kas')
            #sec.insert('kdr')
            #sec.insert('kir')
            sec.ena = 50
            sec.ek = -85 # -90
        for sec in self.dendlist:
            sec.insert('naf')
            sec.insert('kaf')
            sec.insert('kas')
            sec.insert('kdr')
            sec.insert('kir')
            sec.ena = 50
            sec.ek = -85 # -90
            sec.insert('cal12')
            sec.insert('cal13')
            sec.insert('car')
            sec.insert('cadyn')
            sec.insert('caldyn')
            sec.insert('sk')
            sec.insert('bk')
            sec.insert('cat32')
            sec.insert('cat33')

        with open(params) as file:
            par = json.load(file)

        self.distribute_channels("soma", "g_pas", 0, 1, 0, 0, 0, float(par['g_pas_all']['Value']))
        self.distribute_channels("axon", "g_pas", 0, 1, 0, 0, 0, float(par['g_pas_all']['Value']))
        self.distribute_channels("dend", "g_pas", 0, 1, 0, 0, 0, float(par['g_pas_all']['Value']))

        self.distribute_channels("soma", "gbar_naf", 0, 1, 0, 0, 0, float(par['gbar_naf_somatic']['Value']),factors=factors)
        self.distribute_channels("soma", "gbar_kaf", 0, 1, 0, 0, 0, float(par['gbar_kaf_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kas", 0, 1, 0, 0, 0, float(par['gbar_kas_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kdr", 0, 1, 0, 0, 0, float(par['gbar_kdr_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kir", 0, 1, 0, 0, 0, float(par['gbar_kir_somatic']['Value']))
        self.distribute_channels("soma", "gbar_sk", 0, 1, 0, 0, 0, float(par['gbar_sk_somatic']['Value']))
        self.distribute_channels("soma", "gbar_bk", 0, 1, 0, 0, 0, float(par['gbar_bk_somatic']['Value']))
        
        #self.distribute_channels("axon", "gbar_naf", 0, 1, 0, 0, 0, float(par['gbar_naf_somatic']['Value']),factors=factors)
        self.distribute_channels("axon", "gbar_naf", 3, 1, 1.1, 30, 500, float(par['gbar_naf_axonal']['Value']),factors=factors)
        #self.distribute_channels("axon", "gbar_naf", 3, 1, 1.1, 20, 500, float(par['gbar_naf_axonal']['Value']))
        #self.distribute_channels("dend", "gbar_naf", 1, 1,  1.2, 30, -5, float(par['gbar_naf_axonal']['Value']))
        self.distribute_channels("axon", "gbar_kas", 0, 1, 0, 0, 0, float(par['gbar_kas_axonal']['Value']))
        
        self.distribute_channels("dend", "gbar_naf", 1, 0.1, 0.9, 60.0, 10.0, float(par['gbar_naf_basal']['Value']),factors=factors)
        self.distribute_channels("dend", "gbar_kaf", 1, 1,  0.5, 120, -30, float(par['gbar_kaf_basal']['Value']))
        #self.distribute_channels("dend", "gbar_naf", 0, 1, -0.0072, 0, 0, float(par['gbar_naf_basal']['Value']))
        #self.distribute_channels("dend", "gbar_kaf", 0, 1,  0.0167, 0, 0, float(par['gbar_kaf_basal']['Value']))
        self.distribute_channels("dend", "gbar_kas", 2, 1, 9.0, 0.0, -5.0, float(par['gbar_kas_basal']['Value']))
        self.distribute_channels("dend", "gbar_kdr", 0, 1, 0, 0, 0, float(par['gbar_kdr_basal']['Value']))
        self.distribute_channels("dend", "gbar_kir", 0, 1, 0, 0, 0, float(par['gbar_kir_basal']['Value']))
        self.distribute_channels("dend", "gbar_sk", 0, 1, 0, 0, 0, float(par['gbar_sk_basal']['Value']))
        self.distribute_channels("dend", "gbar_bk", 0, 1, 0, 0, 0, float(par['gbar_bk_basal']['Value']))

        self.distribute_channels("soma", "pbar_cal12", 0, 1, 0, 0, 0, 1e-5)
        self.distribute_channels("soma", "pbar_cal13", 0, 1, 0, 0, 0, 1e-6)
        self.distribute_channels("soma", "pbar_car", 0, 1, 0, 0, 0, 1e-4)
        self.distribute_channels("soma", "pbar_can", 0, 1, 0, 0, 0, 3e-5)
        #self.distribute_channels("soma", "kb_cadyn", 0, 1, 0, 0, 0, 200.0)
        self.distribute_channels("dend", "pbar_cal12", 0, 1, 0, 0, 0, 1e-5)
        self.distribute_channels("dend", "pbar_cal13", 0, 1, 0, 0, 0, 1e-6)
        self.distribute_channels("dend", "pbar_car", 0, 1, 0, 0, 0, 1e-4)
        self.distribute_channels("dend", "pbar_cat32", 1, 0, 1.0, 70.0, -4.5, 1e-7)
        self.distribute_channels("dend", "pbar_cat33", 1, 0, 1.0, 70.0, -4.5, 1e-8)
Пример #21
0
    def createPops(self):

        #  Get info from nodes files
        for n in self.network_config['networks']['nodes']:
            nodes_file = self.subs(n['nodes_file'])
            node_types_file = self.subs(n['node_types_file'])

            print("\nLoading nodes from %s and %s" %
                  (nodes_file, node_types_file))

            h5file = tables.open_file(nodes_file, mode='r')

            self.parse_group(h5file.root.nodes)
            h5file.close()
            self.nodes_info[self.current_node] = load_csv_props(
                node_types_file)
            self.current_node = None

        pp.pprint(self.nodes_info)

        #  Use extracted node/cell info to create populations
        for sonata_pop in self.cell_info:
            # iterate over cell types -- will make one netpyne population per cell type
            for type in self.cell_info[sonata_pop]['type_numbers']:
                info = self.nodes_info[sonata_pop][type]
                pop_name = info['pop_name'] if 'pop_name' in info else None

                ref = info['model_name'] if 'model_name' in info else info[
                    'model_type']
                model_type = info['model_type']
                model_template = info[
                    'model_template'] if 'model_template' in info else '- None -'

                if pop_name:
                    pop_id = '%s_%s' % (sonata_pop, pop_name)
                else:
                    pop_id = '%s_%s_%s' % (sonata_pop, ref, type)

                self.pop_id_from_type[(sonata_pop, type)] = pop_id

                print(" - Adding population: %s which has model info: %s" %
                      (pop_id, info))

                size = self.cell_info[sonata_pop]['type_numbers'][type]

                # create netpyne pop
                # Note: alternatively could create sim.net.params.popParams and then call sim.createPops()
                popTags = {}
                popTags['cellModel'] = model_type
                popTags['cellType'] = info[
                    'model_name'] if 'model_name' in info else pop_id
                popTags['numCells'] = size
                popTags['pop'] = pop_id
                popTags['ei'] = info['ei'] if 'ei' in info else ''
                sim.net.pops[pop_id] = sim.Pop(pop_id, popTags)

                # create population cell template (sections) from morphology and dynamics params files
                if model_type == 'biophysical':
                    sim.net.pops[pop_id].cellModelClass = sim.CompartCell

                    # morphology
                    morphology_file = self.subs(
                        self.network_config['components']['morphologies_dir']
                    ) + '/' + info['morphology'] + '.swc'
                    cellMorph = EmptyCell()
                    swcData = h.Import3d_SWC_read()
                    swcData.input(morphology_file)
                    swcSecs = h.Import3d_GUI(swcData, 0)
                    swcSecs.instantiate(cellMorph)

                    # replace axon with AIS stub
                    if self.replaceAxon:
                        fix_axon_peri_v2(cellMorph)

                    # extract netpyne parameters
                    secs, secLists, synMechs, globs = neuronPyHoc.getCellParams(
                        cellMorph)

                    if self.setdLNseg:
                        fix_sec_nseg(secs, sim.cfg.dL)

                    # create mapping of sec ids
                    secLists['SONATA_sec_id'] = [
                        sim.conversion.getSecName(sec) for sec in cellMorph.all
                    ]

                    cellRule = {
                        'conds': {
                            'pop': pop_id
                        },
                        'secs': secs,
                        'secLists': secLists,
                        'globals': globs
                    }

                    # dynamics params
                    dynamics_params_file = self.subs(
                        self.network_config['components']
                        ['biophysical_neuron_models_dir'] + '/' +
                        info['model_template'])
                    if info['model_template'].startswith('nml'):
                        dynamics_params_file = dynamics_params_file.replace(
                            'nml:', '')
                        nml_doc = read_neuroml2_file(dynamics_params_file)
                        cell_dynamic_params = nml_doc.cells[0]
                        cellRule = self.setCellRuleDynamicParamsFromNeuroml(
                            cell_dynamic_params, cellRule)

                    elif info['dynamics_params'].startswith('json'):
                        dynamics_params = load_json(dynamics_params_file)
                        pass

                    # set extracted cell params in cellParams rule
                    sim.net.params.cellParams[pop_id] = cellRule

                    # clean up before next import
                    del swcSecs, cellMorph
                    h.initnrn()

                # create population of virtual cells (VecStims so can add spike times)
                elif model_type == 'virtual':
                    popTags['cellModel'] = 'VecStim'
                    sim.net.pops[pop_id].cellModelClass = sim.PointCell
Пример #22
0
    def __init__(self,  params=None,                                \
                        morphology='latest_WT-P270-20-14ak.swc'     ):
        Import = h.Import3d_SWC_read()
        Import.input(morphology)
        imprt = h.Import3d_GUI(Import, 0)
        imprt.instantiate(None)
        h.define_shape()
        # h.cao0_ca_ion = 2  # default in nrn
        h.celsius = 35
        self._create_sectionlists()
        self._set_nsegs()
        self.v_init = -80

        for sec in self.somalist:
            for mech in [
                    "naf", "kaf", "kas", "kdr", "kir", "cal12", "cal13", "can",
                    "car", "cadyn", "caldyn", "sk", "bk"
            ]:
                sec.insert(mech)

        for sec in self.axonlist:
            for mech in ["naf", "kas"]:
                sec.insert(mech)

        for sec in self.dendlist:
            for mech in [
                    "naf", "kaf", "kas", "kdr", "kir", "cal12", "cal13", "car",
                    "cat32", "cat33", "cadyn", "caldyn", "sk", "bk"
            ]:
                sec.insert(mech)

        for sec in self.allseclist:
            sec.Ra = 150
            sec.cm = 1.0
            sec.insert('pas')
            #sec.g_pas = 1e-5 # set using json file
            sec.e_pas = -70  # -73
            sec.ena = 50
            sec.ek = -85  # -90

        with open(params) as file:
            par = json.load(file)

        self.distribute_channels("soma", "g_pas", 0, 1, 0, 0, 0,
                                 float(par['g_pas_all']['Value']))
        self.distribute_channels("axon", "g_pas", 0, 1, 0, 0, 0,
                                 float(par['g_pas_all']['Value']))
        self.distribute_channels("dend", "g_pas", 0, 1, 0, 0, 0,
                                 float(par['g_pas_all']['Value']))

        self.distribute_channels("soma", "gbar_naf", 0, 1, 0, 0, 0,
                                 float(par['gbar_naf_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kaf", 0, 1, 0, 0, 0,
                                 float(par['gbar_kaf_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kas", 0, 1, 0, 0, 0,
                                 float(par['gbar_kas_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kdr", 0, 1, 0, 0, 0,
                                 float(par['gbar_kdr_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kir", 0, 1, 0, 0, 0,
                                 float(par['gbar_kir_somatic']['Value']))
        self.distribute_channels("soma", "gbar_sk", 0, 1, 0, 0, 0,
                                 float(par['gbar_sk_somatic']['Value']))
        self.distribute_channels("soma", "gbar_bk", 0, 1, 0, 0, 0,
                                 float(par['gbar_bk_somatic']['Value']))

        self.distribute_channels("axon", "gbar_naf", 3, 1, 1.1, 30, 500,
                                 float(par['gbar_naf_axonal']['Value']))
        self.distribute_channels("axon", "gbar_kas", 0, 1, 0, 0, 0,
                                 float(par['gbar_kas_axonal']['Value']))
        self.distribute_channels("dend", "gbar_naf", 1, 0.1, 0.9, 60.0, 10.0,
                                 float(par['gbar_naf_basal']['Value']))
        self.distribute_channels("dend", "gbar_kaf", 1, 1, 0.5, 120.0, -30.0,
                                 float(par['gbar_kaf_basal']['Value']))

        self.distribute_channels("dend", "gbar_kas", 2, 1, 9.0, 0.0, -5.0,
                                 float(par['gbar_kas_basal']['Value']))
        self.distribute_channels("dend", "gbar_kdr", 0, 1, 0, 0, 0,
                                 float(par['gbar_kdr_basal']['Value']))
        self.distribute_channels("dend", "gbar_kir", 0, 1, 0, 0, 0,
                                 float(par['gbar_kir_basal']['Value']))
        self.distribute_channels("dend", "gbar_sk", 0, 1, 0, 0, 0,
                                 float(par['gbar_sk_basal']['Value']))
        self.distribute_channels("dend", "gbar_bk", 0, 1, 0, 0, 0,
                                 float(par['gbar_bk_basal']['Value']))

        self.distribute_channels("soma", "pbar_cal12", 0, 1, 0, 0, 0, 1e-5)
        self.distribute_channels("soma", "pbar_cal13", 0, 1, 0, 0, 0, 1e-6)
        self.distribute_channels("soma", "pbar_car", 0, 1, 0, 0, 0, 1e-4)
        self.distribute_channels("soma", "pbar_can", 0, 1, 0, 0, 0, 3e-5)
        self.distribute_channels("dend", "pbar_cal12", 0, 1, 0, 0, 0, 1e-5)
        self.distribute_channels("dend", "pbar_cal13", 0, 1, 0, 0, 0, 1e-6)
        self.distribute_channels("dend", "pbar_car", 0, 1, 0, 0, 0, 1e-4)
        self.distribute_channels("dend", "pbar_cat32", 1, 0, 1.0, 120.0, -30.0,
                                 1e-7)
        self.distribute_channels("dend", "pbar_cat33", 1, 0, 1.0, 120.0, -30.0,
                                 1e-8)
Пример #23
0
    def createPops(self):

        #  Get info from nodes files
        for n in self.network_config['networks']['nodes']:
            nodes_file = self.subs(n['nodes_file'])
            node_types_file = self.subs(n['node_types_file'])

            print("\nLoading nodes from %s and %s"%(nodes_file, node_types_file))

            h5file = tables.open_file(nodes_file,mode='r')

            self.parse_group(h5file.root.nodes)
            h5file.close()
            self.nodes_info[self.current_node] = load_csv_props(node_types_file)
            self.current_node = None

        pp.pprint(self.nodes_info)


        #  Use extracted node/cell info to create populations
        for sonata_pop in self.cell_info:
            # iterate over cell types -- will make one netpyne population per cell type
            for type in self.cell_info[sonata_pop]['type_numbers']:
                info = self.nodes_info[sonata_pop][type]
                pop_name = info['pop_name'] if 'pop_name' in info else None

                ref = info['model_name'] if 'model_name' in info else info['model_type']
                model_type = info['model_type']
                model_template = info['model_template'] if 'model_template' in info else '- None -'

                if pop_name:
                    pop_id = '%s_%s'%(sonata_pop, pop_name)
                else:
                    pop_id = '%s_%s_%s'%(sonata_pop,ref,type)

                self.pop_id_from_type[(sonata_pop, type)] = pop_id

                print(" - Adding population: %s which has model info: %s"%(pop_id, info))

                size = self.cell_info[sonata_pop]['type_numbers'][type]

                # create netpyne pop
                # Note: alternatively could create sim.net.params.popParams and then call sim.createPops()
                popTags = {}
                popTags['cellModel'] = model_type
                popTags['cellType'] = info['model_name'] if 'model_name' in info else pop_id
                popTags['numCells'] = size
                popTags['pop'] = pop_id
                popTags['ei'] = info['ei'] if 'ei' in info else ''
                sim.net.pops[pop_id] = sim.Pop(pop_id, popTags)
                sim.net.params.popParams[pop_id] = popTags

                # create population cell template (sections) from morphology and dynamics params files
                if model_type == 'biophysical':
                    sim.net.pops[pop_id].cellModelClass = sim.CompartCell

                    # morphology
                    morphology_file = self.subs(self.network_config['components']['morphologies_dir']) +'/'+info['morphology'] + '.swc'
                    cellMorph = EmptyCell()
                    swcData = h.Import3d_SWC_read()
                    swcData.input(morphology_file)
                    swcSecs = h.Import3d_GUI(swcData, 0)
                    swcSecs.instantiate(cellMorph)

                    # replace axon with AIS stub
                    if self.replaceAxon:
                        fix_axon_peri(cellMorph)

                    # extract netpyne parameters
                    secs, secLists, synMechs, globs = neuronPyHoc.getCellParams(cellMorph)

                    # remove sec vinits since imported temporary cell with morph
                    for secName in secs:
                        del secs[secName]['vinit']

                    # fix nseg based on dL
                    if self.setdLNseg:
                        fix_sec_nseg(secs, sim.cfg.dL)

                    # invert y coordinates
                    # if self.swapSomaXY:
                    #    swap_soma_xy(secs)

                    # make soma mid segment (x,y,z) = (0,0,0)
                    # somaLabel = next((s for s in secs.keys() if 'soma' in s), None)
                    # somaPtFirst = secs[somaLabel]['geom']['pt3d'][0]
                    # somaPtLast = secs[somaLabel]['geom']['pt3d'][-1]
                    # somaPt = [(p1+p2)/2.0 for p1,p2 in zip(somaPtFirst, somaPtLast)]
                    # for secLabel in secs:
                    #     for ipt3d in range(len(secs[secLabel]['geom']['pt3d'])):
                    #         origPt = secs[secLabel]['geom']['pt3d'][ipt3d]
                    #         offsetX = 0.0
                    #         if 'apic' in secLabel:
                    #             offsetX = 0.0
                    #         newpt = (origPt[0] - somaPt[0] + offsetX, origPt[1] - somaPt[1], origPt[2] - somaPt[2], origPt[3])
                    #         secs[secLabel]['geom']['pt3d'][ipt3d] = newpt

                    # create mapping of sec ids
                    secLists['SONATA_sec_id'] = [sim.conversion.getSecName(sec) for sec in cellMorph.all]

                    cellRule = {'conds': {'pop': pop_id}, 'secs': secs, 'secLists': secLists, 'globals': globs}

                    # dynamics params
                    if info['model_template'].startswith('nml'):
                        dynamics_params_file = self.subs(self.network_config['components']['biophysical_neuron_models_dir']+'/'+info['model_template'])
                        dynamics_params_file = dynamics_params_file.replace('nml:', '')

                        #nml_doc = read_neuroml2_file(dynamics_params_file)
                        #cell_dynamic_params = nml_doc.cells[0]
                        cell_dynamic_params = NMLTree(dynamics_params_file)

                        cellRule = self.setCellRuleDynamicParamsFromNeuroml(cell_dynamic_params, cellRule)

                    elif info['dynamics_params'].endswith('json'):
                        dynamics_params_file = self.subs(self.network_config['components']['biophysical_neuron_models_dir']+'/'+info['dynamics_params'])
                        cell_dynamic_params = load_json(dynamics_params_file)
                        cellRule = self.setCellRuleDynamicParamsFromJson(cell_dynamic_params, cellRule)


                    # set extracted cell params in cellParams rule
                    sim.net.params.cellParams[pop_id] = cellRule

                    # clean up before next import
                    del swcSecs, cellMorph
                    h.initnrn()

                # create population of virtual cells (VecStims so can add spike times)
                elif model_type == 'virtual':
                    popTags['cellModel'] = 'VecStim'
                    sim.net.pops[pop_id].cellModelClass = sim.PointCell
Пример #24
0
 def __init__(self,  params=None,
                     morphology=None,
                     mechanisms=None,
                     variables=None,
                     replace_axon=True,
                     section=None
                     ):
     Import = h.Import3d_SWC_read()
     Import.input(morphology)
     imprt = h.Import3d_GUI(Import, 0)
     imprt.instantiate(None)
     h.define_shape()
     
     self._set_nsegs()
     self._create_sectionlists(replace_axon=replace_axon)
     self._read_param_file(params)
     
     # initialize soma as start point of distance function
     #h.distance(sec=self.soma)
     # Define origin of distance function
     h.distance(0, 0.5, sec=self.soma)
     
     # global params---hard coded for now. TODO find better solution
     h.celsius = self.par['global']['celsius']['value']
     self.v_init = self.par['global']['v_init']['value']
     
     if mechanisms:
         with open(mechanisms) as file:
             mechLists = json.load(file)
          
     
     # set channels and parameters
     for region, seclist in zip(['somatic', 'axonal', 'basal'],[self.somalist, self.axonlist, self.dendlist]):
         
         # if no mechanism file is passed assumes cadyn objects for spn. 
         if mechanisms:              cl = mechLists[region]
         elif region == 'axonal':    cl = self.channel_lists[region]
         else:                       cl = self.channel_lists[region]+["cadyn_ms", "caldyn_ms"]
         
         for sec in seclist:
             for mech in cl:
                 sec.insert(mech)
             
             if not mechanisms or ('all' in mechLists and 'pas' in mechLists['all']):
                 sec.insert('pas')
                 sec.e_pas = self.par['section'][region]['e_pas']['value']
                 sec.g_pas = self.par['section'][region]['g_pas']['value']
                 
             # passive params (section params)---hard coded for now. TODO find better solution
             sec.Ra = self.par['section'][region]['Ra']['value']
             sec.cm = self.par['section'][region]['cm']['value']
             sec.ena = self.par['section'][region]['ena']['value']
             sec.ek = self.par['section'][region]['ek']['value']
             
             # channels (range params)
             for rp in self.par['range'][region].keys():
                 
                 value = self.par['range'][region][rp]['value']
                 
                 if self.par['range'][region][rp]['dist_type'] in ['exp','distance']:
                     function = self.par['range'][region][rp]['dist']
                     # get dist
                     for seg in sec:
                         distance = h.distance(1, seg.x, sec=sec)
                         val = eval( function.format(distance=distance, value=value) )
                         
                         cmd = 'seg.{} = {}'.format(rp, val)
                         exec(cmd)
                 else:
                     val = value 
                     for seg in sec:
                         cmd = 'seg.{} = {}'.format(rp, val)
                         exec(cmd)
    def __init__(self,  params=None,                                        \
                        morphology=None,     \
                        variables=None,                                     \
                        section=None                                        ):
        Import = h.Import3d_SWC_read()
        Import.input(morphology)
        imprt = h.Import3d_GUI(Import, 0)
        imprt.instantiate(None)
        h.define_shape()
        # h.cao0_ca_ion = 2  # default in nrn
        h.celsius = 35
        self._create_sectionlists()
        self._set_nsegs(section=section)
        self.v_init = -85

        self.dendritic_channels =   [
                    "naf",
                    "kaf",
                    "kas",
                    "kdr",
                    "kir",
                    "cal12",
                    "cal13",
                    "can",
                    "car",
                    "cav32",
                    "cav33",
                    "sk",
                    "bk"            ]

        self.somatic_channels = [
                    "naf",
                    "kaf",
                    "kas",
                    "kdr",
                    "kir",
                    "cal12",
                    "cal13",
                    "can",
                    "car",
                    "sk",
                    "bk"        ]

        self.axonal_channels = [
                    "naf",
                    "kas" ,
                    "Im"       ]

        # insert active mechanisms (related to channels) -------------
        for sec in self.somalist:
            for mech in self.somatic_channels+["cadyn", "caldyn"]:
                sec.insert(mech)

        for sec in self.axonlist:
            for mech in self.axonal_channels:
                sec.insert(mech)

        for sec in self.dendlist:
            for mech in self.dendritic_channels+["cadyn", "caldyn"]:
                sec.insert(mech)

        with open(params) as file:
            par = json.load(file)

        # set passive parameters --------------------------------------------
        for sec in self.allseclist:
            sec.Ra = 150
            sec.cm = 1.0
            sec.insert('pas')
            #sec.g_pas = 1e-5 # set using json file
            sec.e_pas = -70 # -73
            sec.g_pas = float(par['g_pas_all']['Value'])
            sec.ena = 50
            sec.ek = -85 # -90

        self.distribute_channels("soma", "gbar_naf",   0, 1, 0, 0, 0, float(par['gbar_naf_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kaf",   0, 1, 0, 0, 0, float(par['gbar_kaf_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kas",   0, 1, 0, 0, 0, float(par['gbar_kas_somatic']['Value']))
        self.distribute_channels("soma", "gbar_kdr",   0, 1, 0, 0, 0, float(par['gbar_kdr_somatic']['Value']))
        self.distribute_channels("soma", "gbar_bk",    0, 1, 0, 0, 0, float(par['gbar_bk_somatic' ]['Value']))
        self.distribute_channels("soma", "pbar_cal12", 0, 1, 0, 0, 0, 1.34e-5)
        self.distribute_channels("soma", "pbar_cal13", 0, 1, 0, 0, 0, 1.34e-6)
        self.distribute_channels("soma", "pbar_car",   0, 1, 0, 0, 0, 1.34e-4)
        self.distribute_channels("soma", "pbar_can",   0, 1, 0, 0, 0,    4e-5)

        self.distribute_channels("dend", "gbar_kdr",   0, 1, 0, 0, 0, float(par['gbar_kdr_basal']['Value']))
        self.distribute_channels("dend", "gbar_bk",    0, 1, 0, 0, 0, float(par['gbar_bk_basal' ]['Value']))
        self.distribute_channels("dend", "pbar_cal12", 0, 1, 0, 0, 0, 1e-5)
        self.distribute_channels("dend", "pbar_cal13", 0, 1, 0, 0, 0, 1e-6)
        self.distribute_channels("dend", "pbar_car",   0, 1, 0, 0, 0, 1e-4)

        self.distribute_channels("axon", "gbar_kas",   0, 1, 0, 0, 0,      float(par['gbar_kas_axonal']['Value']))
        self.distribute_channels("axon", "gbar_naf",   3, 1, 1.1, 30, 500, float(par['gbar_naf_axonal']['Value']))
        self.distribute_channels("axon", "gbar_Im",   0, 1, 0, 0, 0, 1.0e-3)
        # in ephys step functions are not supported so something like below formula will be used instead.
        #self.distribute_channels("axon", "gbar_naf",   1, 1, 0.1, 30, -1, float(par['gbar_naf_axonal']['Value']))
        #(1 + 0.9/(1 + math.exp(({distance}-30.0)/-1.0) ))

        if variables:
            self.distribute_channels("dend", "gbar_naf", 1,   1.0-variables['naf'][1],  \
                                                              variables['naf'][1],      \
                                                              variables['naf'][2],      \
                                                              variables['naf'][3],      \
                                                              np.power(10,variables['naf'][0])*float(par['gbar_naf_basal']['Value']))
            self.distribute_channels("dend", "gbar_kaf", 1,   1.0,                      \
                                                              variables['kaf'][1],      \
                                                              variables['kaf'][2],      \
                                                              variables['kaf'][3],      \
                                                              np.power(10,variables['kaf'][0])*float(par['gbar_kaf_basal']['Value']))
            self.distribute_channels("dend", "gbar_kas", 1,   0.1,                      \
                                                              0.9,                      \
                                                              variables['kas'][1],      \
                                                              variables['kas'][2],      \
                                                              np.power(10,variables['kas'][0])*float(par['gbar_kas_basal']['Value']))

            self.distribute_channels("dend", "gbar_kir", 0,   np.power(10,variables['kir'][0]), 0, 0, 0,    float(par['gbar_kir_basal'  ]['Value']))
            self.distribute_channels("soma", "gbar_kir", 0,   np.power(10,variables['kir'][0]), 0, 0, 0,    float(par['gbar_kir_somatic']['Value']))
            self.distribute_channels("dend", "gbar_sk",  0,   np.power(10,variables['sk' ][0]), 0, 0, 0,    float(par['gbar_sk_basal'   ]['Value']))
            self.distribute_channels("soma", "gbar_sk",  0,   np.power(10,variables['sk' ][0]), 0, 0, 0,    float(par['gbar_sk_somatic' ]['Value']))

            self.distribute_channels("dend", "pbar_can",   1, 1.0-variables['can'][1],  \
                                                              variables['can'][1],      \
                                                              variables['can'][2],      \
                                                              variables['can'][3],      \
                                                              np.power(10,variables['can'][0]))
            self.distribute_channels("dend", "pbar_cav32", 1, 0,                        \
                                                              1,                        \
                                                              variables['c32'][1],      \
                                                              variables['c32'][2],      \
                                                              np.power(10,variables['c32'][0]))
            self.distribute_channels("dend", "pbar_cav33", 1, 0,                        \
                                                              1,                        \
                                                              variables['c33'][1],      \
                                                              variables['c33'][2],      \
                                                              np.power(10,variables['c33'][0]))
        else:
            self.distribute_channels("dend", "gbar_naf", 1, 0.1, 0.9,   60.0,   10.0, float(par['gbar_naf_basal']['Value']))
            self.distribute_channels("dend", "gbar_kaf", 1,   1, 0.5,  120.0,  -30.0, float(par['gbar_kaf_basal']['Value']))
            self.distribute_channels("dend", "gbar_kas", 2,   1, 9.0,  0.0, -5.0, float(par['gbar_kas_basal']['Value']))
            self.distribute_channels("dend", "gbar_kir", 0, 1, 0, 0, 0, float(par['gbar_kir_basal']['Value']))
            self.distribute_channels("soma", "gbar_kir", 0, 1, 0, 0, 0, float(par['gbar_kir_somatic']['Value']))
            self.distribute_channels("dend", "gbar_sk",  0, 1, 0, 0, 0, float(par['gbar_sk_basal']['Value']))
            self.distribute_channels("soma", "gbar_sk",  0, 1, 0, 0, 0, float(par['gbar_sk_basal']['Value']))
            self.distribute_channels("dend", "pbar_can", 0, 1, 0, 0, 0, 1e-7)
            self.distribute_channels("dend", "pbar_cav32", 1, 0, 1.0, 120.0, -30.0, 1e-7)
            self.distribute_channels("dend", "pbar_cav33", 1, 0, 1.0, 120.0, -30.0, 1e-8)