コード例 #1
0
def convert_hhchannel(channel):
    """Convert a moose HHChannel object into a neuroml element.

    TODO: need to check useConcentration option for Ca2+ and V
    dependent gates. How to handle generic expressions???

    """
    nml_channel = neuroml.IonChannel(id=channel.id_.value
            , name=channel.name, type='ionChannelHH'
            , conductance=channel.Gbar
            )
    if channel.Xpower > 0:
        hh_rate_x = convert_hhgate(channel.gateX[0])
        hh_rate_x.instances = channel.Xpower
        nml_channel.gate.append(hh_rate_x)

    if channel.Ypower > 0:
        hh_rate_y = convert_hhgate(channel.gateY[0])
        hh_rate_y.instances = channel.Ypower
        nml_channel.gate.append(hh_rate_y)

    if channel.Zpower > 0:
        hh_rate_z = convert_hhgate(channel.gateZ[0])
        hh_rate_y.instances = channel.Zpower
        nml_channel.gate.append(hh_rate_z)
    return nml_channel
コード例 #2
0
ファイル: main.py プロジェクト: hlapid/C_Elegans_locomotion
    def __init__(self,
                 k_fast_specific_gbar=36.0,
                 k_slow_specific_gbar=0.0,
                 ca_channel_specific_gbar=120.0,
                 ca_h_A_F=20.0,
                 k_tau_factor=1.0,
                 ca_tau_factor=1.0,
                 nocompile=True):

        #	print 'tau factor is:'
        #	print tau_factor
        k_tau_factor = float(k_tau_factor)
        ca_tau_factor = float(ca_tau_factor)
        ca_h_A_F = float(ca_h_A_F)
        self.k_fast_specific_gbar = float(k_fast_specific_gbar)
        self.k_slow_specific_gbar = float(k_slow_specific_gbar)
        self.ca_channel_specific_gbar = float(ca_channel_specific_gbar)

        #First build a compartment, I infered these dimensions from the hyperpolarizing pulses
        p = neuroml.Point3DWithDiam(x=0.0, y=0.0, z=0.0, diameter=800.0)

        d = neuroml.Point3DWithDiam(x=800.0, y=800.0, z=800.0, diameter=800.0)

        compartment = neuroml.Segment(proximal=p, distal=d)

        #create a leak ion channel:
        leak = neuroml.IonChannel(id="passive",
                                  type="ionChannelPassive",
                                  conductance="10pS")

        #create membrane properties:
        membrane_properties = neuroml.MembraneProperties()

        leak_density = neuroml.ChannelDensity(id="leak",
                                              ion_channels="passive",
                                              cond_density="3.0 S_per_m2",
                                              erev="-54.3mV")

        membrane_properties.channel_densities.append(leak_density)

        #        self.passive = kinetics.PassiveProperties(init_vm=-30.0,
        #                                                  rm=1/0.3,
        #                                                  cm=10.0, #1.0
        #                                                  ra=0.03)

        #leave leak current out for now
        #Create a LeakCurrent object:
        #	self.leak = kinetics.LeakCurrent(em=-30.0)

        #get a Morphology object from the compartment: (no longer needed?)
        #self.morphology = self.compartment.morphology

        #insert the passive properties and leak current into the morphology:

        self.cell.leak_current = self.leak
        #	self.morphology.passive_properties = self.passive
        #	self.morphology.leak_current = self.leak

        #create two current clamp stimuli:
        self.stim = kinetics.IClamp(current=0.25, delay=100.0, duration=1000.0)

        #problem with Pyramidal here, inserting this overrides the previous?!
        #create a current clamp stimulus:
        #            self.stim2 = kinetics.IClamp(current=0.10,
        #                                   delay=600.0,
        #                                   duration=500.0)

        #insert the stimulus into the morphology
        self.morphology[0].insert(self.stim)

        if nocompile == False:
            #create Ca ion channel:
            ca_channel = kinetics.HHChannel(
                name='ca',
                specific_gbar=self.ca_channel_specific_gbar,
                ion='ca',
                e_rev=20.0,
                x_power=3.0,
                y_power=1.0)

            #create K fast ion channel:
            k_fast = kinetics.HHChannel(
                name='kfast',
                specific_gbar=self.k_fast_specific_gbar,
                ion='k',
                e_rev=-10.0,
                x_power=4.0,
                y_power=0.0)

            k_slow = kinetics.HHChannel(
                name='kslow',
                specific_gbar=self.k_slow_specific_gbar,
                ion='k',
                e_rev=-10.0,
                x_power=4.0,
                y_power=0.0)

            #create dicts containing gating parameters:
            ca_m_params = {
                'A_A': 0.1 * 25.0 * ca_tau_factor,
                'A_B': -0.1 * ca_tau_factor,
                'A_C': -1.0,
                'A_D': -25.0,
                'A_F': -10.0,
                'B_A': 4.0 * ca_tau_factor,
                'B_B': 0.0 * ca_tau_factor,
                'B_C': 0.0,
                'B_D': 0.0,
                'B_F': 18.0
            }

            ca_h_params = {
                'A_A': 0.07 * ca_tau_factor,
                'A_B': 0.0 * ca_tau_factor,
                'A_C': 0.0,
                'A_D': 0.0,
                'A_F': ca_h_A_F,  #20
                'B_A': 1.0 * ca_tau_factor,
                'B_B': 0.0 * ca_tau_factor,
                'B_C': 1.0,
                'B_D': -30.0,
                'B_F': -10.0
            }

            k_fast_n_params = {
                'A_A': 0.01 * (10.0) * k_tau_factor,
                'A_B': -0.01 * k_tau_factor,  #0.01
                'A_C': -1.0,
                'A_D': -10.0,
                'A_F': -10.0,
                'B_A': 0.125 * k_tau_factor,
                'B_B': 0.0 * k_tau_factor,
                'B_C': 0.0,
                'B_D': 0.0,
                'B_F': 80.0
            }

            k_fast_h_params = {
                'A_A': 6.6 * k_tau_factor,
                'A_B': 0.0 * k_tau_factor,
                'A_C': 1.0,
                'A_D': 15.6,
                'A_F': 10.0,
                'B_A': 6.6 * k_tau_factor,
                'B_B': 0.0 * k_tau_factor,
                'B_C': 1.0,
                'B_D': 15.6,
                'B_F': -10.0
            }

            k_slow_n_params = {
                'A_A': 0.01 * (10.0),
                'A_B': -0.01,
                'A_C': -2.0,
                'A_D': -10.0,
                'A_F': -10.0,
                'B_A': 0.125,
                'B_B': 0.0,
                'B_C': 0.0,
                'B_D': 0.0,
                'B_F': 80.0
            }

            #setup the channel gating parameters:
            ca_channel.setup_alpha(gate='X',
                                   params=ca_m_params,
                                   vdivs=150,
                                   vmin=-30,
                                   vmax=120)

            ca_channel.setup_alpha(gate='Y',
                                   params=ca_h_params,
                                   vdivs=150,
                                   vmin=-30,
                                   vmax=120)

            k_fast.setup_alpha(gate='X',
                               params=k_fast_n_params,
                               vdivs=150,
                               vmin=-30,
                               vmax=120)

            k_fast.setup_alpha(gate='Y',
                               params=k_fast_h_params,
                               vdivs=300,
                               vmin=-150,
                               vmax=150)

            k_slow.setup_alpha(gate='X',
                               params=k_slow_n_params,
                               vdivs=150,
                               vmin=-30,
                               vmax=120)
        else:

            ca_attributes = {
                'gbar': self.ca_channel_specific_gbar,
                'h_A_F': ca_h_A_F,
                'm_A_A': 0.1 * 25.0 * ca_tau_factor,
                'm_A_B': -0.1 * ca_tau_factor,
                'm_B_A': 4.0 * ca_tau_factor,
                'm_B_B': 0.0 * ca_tau_factor,
                'h_A_A': 0.07 * ca_tau_factor,
                'h_A_B': 0.0 * ca_tau_factor,
                'h_A_F': ca_h_A_F,  #20
                'h_B_A': 1.0 * ca_tau_factor,
                'h_B_B': 0.0 * ca_tau_factor
            }

            kfast_attributes = {
                'gbar': self.k_fast_specific_gbar,
                'm_A_A': 0.01 * (10.0) * k_tau_factor,
                'm_A_B': -0.01 * k_tau_factor,  #0.01
                'm_B_A': 0.125 * k_tau_factor,
                'm_B_B': 0.0 * k_tau_factor
            }
            #bug in pyramidal, if Y == 0 (no inactivation gates) it doesn't compile these values, but it should
            #				'h_A_A': 6.6*k_tau_factor,
            #				'h_A_B': 0.0*k_tau_factor,
            #				'h_B_A': 6.6*k_tau_factor,
            #				'h_B_B': 0.0*k_tau_factor}

            kslow_attributes = {'gbar': self.k_slow_specific_gbar}

            ca_channel = kinetics.Nmodl('ca', ca_attributes)
            k_fast = kinetics.Nmodl('kfast', kfast_attributes)
            k_slow = kinetics.Nmodl('kslow', kslow_attributes)

    #insert the channels:
        self.morphology[0].insert(ca_channel)
        self.morphology[0].insert(k_fast)
        self.morphology[0].insert(k_slow)

        #create the NEURON environment
        self.neuron_env = envs.NeuronEnv(sim_time=100, dt=1e-2)

        #import morphology into environment:
        self.neuron_env.import_cell(self.morphology)
コード例 #3
0
"""
Generating a Hodgkin-Huxley Ion Channel and writing it to NeuroML
"""

import neuroml
import neuroml.writers as writers
from lxml import etree
from urllib import urlopen

chan = neuroml.IonChannel(id='na',
                          type='ionChannelHH',
                          conductance='10pS',
                          species='na',
                          notes="This is an example voltage-gated Na channel")

m_gate = neuroml.GateHHRates(id='m', instances='3')
h_gate = neuroml.GateHHRates(id='h', instances='1')

m_gate.forward_rate = neuroml.HHRate(type="HHExpRate",
                                     rate="0.07per_ms",
                                     midpoint="-65mV",
                                     scale="-20mV")

m_gate.reverse_rate = neuroml.HHRate(type="HHSigmoidRate",
                                     rate="1per_ms",
                                     midpoint="-35mV",
                                     scale="10mV")

h_gate.forward_rate = neuroml.HHRate(type="HHExpLinearRate",
                                     rate="0.1per_ms",
                                     midpoint="-55mV",