Skip to content

Instantly share code, notes, and snippets.

Last active Dec 19, 2015
What would you like to do?
Geppetto integration sample scripts
import numpy
import pylab as pl
from matplotlib import pyplot as plt
import time
class muscle_simulation():
#sample script inspired from
def __init__(self,increment=1.0):
#create pre- and post- synaptic sections
self.increment = increment
self.pre = h.Section() = h.Section()
for sec in self.pre,
#inject current in the pre-synaptic section
self.stim = h.IClamp(0.5, sec=self.pre)
self.stim.amp = 70.0
self.stim.delay = 1500.0
self.stim.dur = 500.0
#create a synapse in the pre-synaptic section
self.syn = h.ExpSyn(0.5,
#connect the pre-synaptic section to the synapse object: = h.NetCon(self.pre(0.5)._ref_v, self.syn)[0] = 10.0
#let's do some manaical experimentation of the most evil kind:
self.calcium_level = 0
self.voltage_plot, = plt.plot([],[])
def addition_rate(self):
opening = abs(post_v+65)
opening = (opening**2/(opening**2+opening))
current = opening*(1-self.state.calcium_level)/100
return current
def removal_rate(self):
opening = abs(20-post_v)
opening = (opening**2/(opening**2+opening))
current = opening*(self.calcium_level)/100
return -current
def run(self,do_plot = True):
#run and return resting potential
t_now = h.t
self.calcium_level += self.addition_rate()+self.removal_rate()
self.muscle_contraction = self.calcium_level
<?xml version="1.0" encoding="UTF-8"?>
<tns:simulation xmlns:tns="" xmlns:xsi="" xsi:schemaLocation=" ../../src/main/resources/schema/simulationSchema.xsd ">
<tns:element state="hhpop[0].v" var="pre_v"></tns:element>
<tns:element state="hhpop[1].v" var="post_v"></tns:element>
<tns:element state="hhpop[1].i" var="sync_i"></tns:element>
<tns:element state="hhpop[0]" var="calcium_level"></tns:element>
<tns:element state="muscle[0].contraction" var="muscle_contraction"></tns:element>
1) timesteps need to have a minimum common denominator (e.g. 2ms, 4ms)
2) internal variables for the integration script
a) geppetto defines an interface for a method that gets exceuted every time there is an integration
3) the user needs to specify the exchange of information clock
timestep_simA = 2E-6 //from TimeConfiguration, unrelated to the script
timestep_simB = 1E-3 //from TimeConfiguration, unrelated to the script
"sampling" integer simA = 5 //from TimeConfiguration, unrelated to the script
"sampling" integer simB = 2 //from TimeConfiguration, unrelated to the script
timestep_script (by default the fastest clock) = 2s
- should not be faster than the fastest clock
- can be as slow as the user desires
- all clocks have a minimum common denominator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment