Exemplo n.º 1
0
 def __init__(self, name='IG', inject=70.0, gbarGABA=1.0):
     """IG model based on Izhikevich type neuron."""
     self.sec = h.Section(name)
     self.izhi = h.IzhiGS(self.sec(0.5))
     self.izhi.celltype = 1  # Regular Spiking
     self.izhi.Iin = inject
     self.izhi.gbarGraded = gbarGABA
     self.netcons = []        
Exemplo n.º 2
0
def make_kc_with_dynaclamp(kc_name,
                           kc_file,
                           inject,
                           tstart,
                           tend,
                           ggn_vm=None):
    """Read KC model from `kc_file`, inject current `inject` nA, apply
    dynamic clamp `ggn_vm`, which should be a 2D array with time (ms)
    in column 0, and voltage (mV) in column 1.

    """
    global model_dict
    kc = nu.create_cell(kc_name, filename=kc_file)
    model_dict[kc] = None
    iclamp = ephys.setup_current_clamp(kc.soma,
                                       pos=0.5,
                                       delay=Q_(tstart, 'ms'),
                                       duration=Q_((tend - tstart), 'ms'),
                                       amplitude=Q_(inject, 'nA'))
    model_dict[iclamp] = None
    ggn_g_vec = None
    if ggn_vm is not None:
        syn = h.GradedSyn(kc.soma(0.5))
        for attr, value in GGN_KC_SYN_PARAMS.items():
            setattr(syn, attr, value)
        model_dict[syn] = None
        ggn_comp = h.Section('ggn')
        model_dict[ggn_comp] = None
        h.setpointer(ggn_comp(0.5)._ref_v, 'vpre', syn)
        ggn_vm_vec = h.Vector(ggn_vm[:, 1])
        tvec = h.Vector(ggn_vm[:, 0])
        model_dict[tvec] = None
        # vec.play(var_reference, t, continuous) for interpolating
        ret = ggn_vm_vec.play(ggn_comp(0.5)._ref_v, tvec, 1)
        print('####', ret)
        model_dict[ggn_vm_vec] = None
        ggn_g_vec = h.Vector()
        ggn_g_vec.record(syn._ref_g)
        model_dict[ggn_g_vec] = None
    kc_vm_vec = h.Vector()
    kc_vm_vec.record(kc.soma(0.5)._ref_v)
    model_dict[kc_vm_vec] = None
    print('Built model')
    return (kc_vm_vec, ggn_g_vec)
Exemplo n.º 3
0
def create_cable(name,
                 diameter,
                 length,
                 nseg,
                 RA,
                 CM=Q_('1.0uF/cm**2'),
                 mechs=[],
                 ek=Q_('-80.0mV'),
                 ena=Q_('60.0mV'),
                 eca=Q_('60.0mV'),
                 verbose=False):
    """Create a cable with specified dimeter, length and number of
    segments and insert the mechanisms in mechs list.

    Parameters:

    diameter (um):  cable diameter

    length (um): cable length

    nseg: number of segments to divide the cable into

    RA (ohm-cm): specific axial resistance

    CM (uF/cm2): specific membrane capacitance.

    mechs (Mechanism): list of mechanisms to be inserted into the
    section. You may want to update the properties later using
    `set_mech_param`.

    ek (mV): K+ reversal potential

    ena (mV): Na+ reversal potential

    eca (mV): Ca2+ reversal potential.

    Returns:

    cable: a new Section with all the properties and mechanisms.

    """
    cable = h.Section(name=name)
    cable.diam = diameter.to(ur.um).m
    cable.L = length.to(ur.um).m
    cable.cm = CM.to('uF/cm**2').m
    cable.Ra = RA.to('ohm*cm').m
    cable.nseg = nseg
    for mech in mechs:
        mech.insert_into(cable)
    if hasattr(cable, 'ek'):
        cable.ek = ek.to('mV').m
    if hasattr(cable, 'ena'):
        cable.ena = ena.to('mV').m
    if hasattr(cable, 'eca'):
        cable.eca = eca.to('mV').m
    if verbose:
        print('Created cable', name, 'with', nseg, 'segments')
        for x in cable:
            print(
                'Segment at', x.x, 'diam=', x.diam, 'area=', x.area(),
                'area computed=', np.pi * x.diam * cable.L / cable.nseg, 'ri=',
                x.ri(), 'computed ri=', 0.01 * cable.Ra *
                (cable.L / 2 / cable.nseg) / (np.pi * (x.diam / 2)**2))
            for mech in mechs:
                m = getattr(x, mech.name)
                print('  Has mechanism', m.name())
    sys.stdout.flush()
    return cable