Introduction
The python calciumcompartment example is extracted from the most popular open source projects, you can refer to the following example for usage.
Programming language: Python
Namespace/package name: optofitneuroncompartment
Example#1File:
model.pyProject:
HIPS/optofit
def point_parameter_model(values):
model = Model()
population = Population('population', model)
neuron = Neuron('neuron', population)
body = CalciumCompartment('body', neuron)
channel_constructor_dict = {
'leak': LeakChannel,
'ca3kdr': Ca3KdrChannel,
'ca3ka': Ca3KaChannel,
'ca3na': Ca3NaChannel,
'ca3ca': Ca3CaChannel,
'ca3kahp': Ca3KahpChannel,
'ca3kc': Ca3KcChannel,
'chr2': ChR2Channel
}
for ch, d in values.iteritems():
if ch in channel_constructor_dict:
channel = channel_constructor_dict[ch](
ch, body,
Parameter('g_' + ch, d['g'] ,lb=0.0),
Parameter('E_' + ch, d['E'] ,lb=0.0)
)
body.add_channel(channel)
else:
print "Warning: ", ch, " not in dict"
neuron.add_compartment(body, None)
population.add_neuron(neuron)
model.add_population(population)
return model, body
Example#2File:
bayes_opt_target.pyProject:
HIPS/optofit
def params_to_model(params):
model = Model()
population = Population('population', model)
neuron = Neuron('neuron', population)
body = CalciumCompartment('body', neuron)
channel_constructor_dict = {
u'leak': LeakChannel,
u'ca3kdr': Ca3KdrChannel,
u'ca3ka': Ca3KaChannel,
u'ca3na': Ca3NaChannel,
u'ca3ca': Ca3CaChannel,
u'ca3kahp': Ca3KahpChannel,
u'ca3kc': Ca3KcChannel,
u'chr2': ChR2Channel
}
for ch, g in params.iteritems():
if ch in channel_constructor_dict:
channel = channel_constructor_dict[ch](
ch.encode('ascii', 'ignore'), body,
Parameter('g_' + ch.encode('ascii', 'ignore'), g.tolist()[0] ,lb=0.0),
)
body.add_channel(channel)
else:
print "Warning: ", ch, " not in dict"
neuron.add_compartment(body, None)
population.add_neuron(neuron)
model.add_population(population)
observation = IndependentObservations('observations', model)
lp_body_voltage = LowPassCompartmentVoltage('lp body voltage', model, body, filterbins=20)
#import pdb; pdb.set_trace()
lp_body_voltage.sigma.value = params[u'sigma']
observation.add_observation(lp_body_voltage)
model.add_observation(observation)
return model
Example#3File:
new_model_demo.pyProject:
HIPS/optofit
def make_model():
"""Make a model of a single compartment neuron with a handful of channels and a directly
observable voltage
"""
model = Model()
# The population object doesn't do anything yet, but eventually it could support
# synapses between neurons
population = Population('population', model)
# Explicitly build the neuron
neuron = Neuron('neuron', population)
# The single compartment corresponds to the cell body
body = CalciumCompartment('body', neuron)
# Add a few channels
leak = LeakChannel('leak', body)
ca3kdr = Ca3KdrChannel('ca3kdr', body)
ca3ka = Ca3KaChannel('ca3ka', body)
ca3na = Ca3NaChannel('ca3na', body)
ca3ca = Ca3CaChannel('ca3ca', body)
ca3kahp = Ca3KahpChannel('ca3kahp', body)
ca3kc = Ca3KcChannel('ca3kc', body)
chr2 = ChR2Channel('chr2', body)
# Now connect all the pieces of the neuron together
body.add_channel(leak)
# body.add_channel(na)
# body.add_channel(kdr)
body.add_channel(ca3kdr)
body.add_channel(ca3ka)
body.add_channel(ca3na)
body.add_channel(ca3ca)
body.add_channel(ca3kahp)
body.add_channel(ca3kc)
body.add_channel(chr2)
neuron.add_compartment(body, None)
population.add_neuron(neuron)
model.add_population(population)
# Create the observation model
observation = IndependentObservations('observations', model)
# Direct voltage measurement
# body_voltage = NewDirectCompartmentVoltage('body voltage', model, body)
# observation.add_observation(body_voltage)
# Low pass filtered voltage measurement
lp_body_voltage = LowPassCompartmentVoltage('lp body voltage', model, body, filterbins=2)
observation.add_observation(lp_body_voltage)
# Fluorescence (linearly scaled voltage) measurement
# body_fluorescence = LinearFluorescence('body fluorescence' , model, body)
# observation.add_observation(body_fluorescence)
model.add_observation(observation)
return model