Skip to content

Commit a839d42

Browse files
committed
Moved demos from moose to this location.
1 parent f6742e8 commit a839d42

File tree

484 files changed

+214189
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

484 files changed

+214189
-2
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
"""bidirectional_plastic_switch.py:
2+
3+
Apply sequences of random input to this switch and plot the correlation between output
4+
sequences.
5+
6+
"""
7+
8+
__author__ = "Dilawar Singh"
9+
__copyright__ = "Copyright 2015, Dilawar Singh and NCBS Bangalore"
10+
__credits__ = ["NCBS Bangalore"]
11+
__license__ = "GNU GPL"
12+
__version__ = "1.0.0"
13+
__maintainer__ = "Dilawar Singh"
14+
__email__ = "dilawars@ncbs.res.in"
15+
__status__ = "Development"
16+
17+
import moose
18+
import os
19+
import sys
20+
import pylab
21+
22+
23+
def applyInputPulseTrain(mooseElem, fieldName, pulseTrain):
24+
"""
25+
Apply a train of pulse: a list of (time, value) tuples, to fieldName of
26+
mooseElem.
27+
28+
time is incremental.
29+
"""
30+
for (t, v) in pulseTrain:
31+
moose.start(t)
32+
mooseElem.setField(fieldName, v)
33+
34+
def dumpPlots():
35+
fname = 'bidirectionalPlasticity.plot'
36+
if ( os.path.exists( fname ) ):
37+
os.remove( fname )
38+
for x in moose.wildcardFind( '/model/graphs/conc#/#,/model/moregraphs/conc#/#' ):
39+
moose.element( x[0] ).xplot( fname, x[0].name )
40+
41+
def getPlotData():
42+
totR = moose.element('/model/graphs/conc1/tot_PSD_R.Co')
43+
PP1 = moose.element('/model/moregraphs/conc4/PP1_dash_active.Co')
44+
Ca = moose.element('/model/graphs/conc1/Ca.Co')
45+
return totR.vector, PP1.vector, Ca.vector
46+
47+
def displayPlots():
48+
clock = moose.Clock( '/clock' ) # look up global clock
49+
totR = moose.element( '/model/graphs/conc1/tot_PSD_R.Co' )
50+
PP1 = moose.element( '/model/moregraphs/conc4/PP1_dash_active.Co' )
51+
Ca = moose.element( '/model/graphs/conc1/Ca.Co' )
52+
pylab.plot( pylab.linspace( 0, clock.currentTime, len( totR.vector )), totR.vector, label='membrane Receptor' )
53+
pylab.plot( pylab.linspace( 0, clock.currentTime, len( PP1.vector ) ), PP1.vector, label='active PP1' )
54+
pylab.plot( pylab.linspace( 0, clock.currentTime, len( Ca.vector ) ), Ca.vector, label='Ca' )
55+
pylab.legend()
56+
pylab.show()
57+
58+
def main():
59+
"""
60+
This is a toy model of synaptic bidirectional plasticity. The model has
61+
a small a bistable chemical switch, and a small set of reactions that
62+
decode calcium input. One can turn the switch on with short high
63+
calcium pulses (over 2 uM for about 10 sec). One can turn it back off
64+
again using a long, lower calcium pulse (0.2 uM, 2000 sec).
65+
"""
66+
method = 'old_gssa' # This is the Gillespie Stoichastic Systems Algorithm
67+
if ( len( sys.argv ) >= 2 ):
68+
method = sys.argv[1]
69+
if ( method == "gsl" ):
70+
method = "old_gsl"
71+
if ( method == "gssa" ):
72+
method = "old_gssa"
73+
# Load in the model and set up to use the specified method
74+
modelId = moose.loadModel( './stargazin_synapse.g', 'model', method )
75+
moose.start( 1000.0 ) # Run the model for 1000 seconds.
76+
Ca = moose.element( '/model/kinetics/BULK/Ca' )
77+
78+
applyInputPulseTrain(Ca, 'concInit'
79+
, [ (1000.0, 1.0e-3)
80+
, (10.0, 0.08e-3)
81+
, (50.0, 1.0e-3)
82+
, (10.0, 0.08e-3)
83+
, (1000.0, 0.2e-3)
84+
, (2000.0, 0.08e-3)
85+
]
86+
)
87+
moose.start(2000.0)
88+
displayPlots()
89+
quit()
90+
91+
# Run the 'main' if this script is executed standalone.
92+
if __name__ == '__main__':
93+
main()

0 commit comments

Comments
 (0)