-
Notifications
You must be signed in to change notification settings - Fork 2
/
Fig_2_PSP.py
149 lines (115 loc) · 4.61 KB
/
Fig_2_PSP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import numpy as np
import make_timetables as mp
import subprocess
sim_name = 'MSsim'
text_sim_1 = '''include SimParams.g
include MScell/globals.g
include MScell/Ca_constants.g
include MScell/SynParamsCtx.g
include MScell/spineParams.g
include MScell/MScellSynSpines // access make_MS_cell
include InOut/add_output.g //functions for ascii file output
include InOut/IF.g //function to create pulse generator for current injection, also IF & IV curves
include InOut/HookUp.g
setclock 0 {simdt}
setclock 1 {outputclock}
str DA = "UI"
'''
#str Location = "tertdend1_1"
text_sim_11 = '''str jitter = "No"
int jitter_int = 0
int seedvalue = 5757538
'''
#here Protocol and Timing
text_sim_2 = """
str diskpath="SimData/"@{Protocol}@"_"@{DA}@"_"@{Timing}@"_"@{Location}@"_randseed_"@{seedvalue}@"_high_res"
if ({GABAtonic})
diskpath = {diskpath}@"_tonic_gaba"
end
int totspine={make_MS_cell_SynSpine {neuronname} {pfile} {spinesYesNo} {DA}}
reset
Vmhead={add_outputVm {comps} {Vmfile} {neuronname}}
if ({CaOut})
if ( {calciumdye} == 0)
Cafile = "Ca_plasticity"
elif ( {calciumdye} == 1)
Cafile = "Ca_Fura_2_plasticity"
elif ( {calciumdye} == 2)
Cafile = "Ca_Fluo_5f_plasticity"
elif ( {calciumdye} == 3)
Cafile = "Ca_Fluo_4_plasticity"
else
Cafile = "Ca_unnkown_dye_plasticity"
end
Cahead={add_outputCal {comps} {CaBufs} {Cafile} {neuronname}}
else
Cafile="X_plasticity"
Cahead=""
end
if ({GkOut})
Gkfile="Gk_plasticity"
Gkhead={add_outputGk {comps} {chans} {Gkfile} {neuronname}}
else
Gkfile="X_plasticity"
Gkhead=""
end
str stimcomp= {Location}
str spinefile="spine_plasticity"
ce /
"""
#here include paradigm
#and change ISI
text_sim_3 = '''
float newTrainFreq = {burstFreq}/{numbursts}
echo {newTrainFreq}
HookUp {prestim} {Protocol} {Timing} {stimcomp} {diskpath} {numAP} {inject} {AP_durtime} {APinterval} {ISI} {pulseFreq} {pulses} {burstFreq} {numbursts} {newTrainFreq} 1 {jitter_int}
reset
step 1.5 -time
fileFLUSH {Vmfile}
fileFLUSH {Cafile}
fileFLUSH {Gkfile}
fileFLUSH {spinefile}
fileFLUSH {somainjfile}
'''
locations = ['tertdend1_1','tertdend1_3','tertdend1_5','tertdend1_7','tertdend1_9','tertdend1_11','tertdend1_13']
if __name__ == '__main__':
params = mp.read_file('SimParams.g')
gabaYesNo = 0#mp.find_value(params,'GABAYesNo','Pre')
spines = mp.find_string(params,'whichSpines','Pre')
stim_start = mp.find_value(params,'initSim','Pre')
too_fast = mp.find_value(params,'TooFast','Pre')
print gabaYesNo, spines, stim_start, too_fast
protocols = ['InOut/1_PSP.g']
timings = ['Pre']
paradigm_names = ['1_PSP']
for location in locations:
for timing in timings:
for i, protocol in enumerate(protocols):
print protocol
text = mp.read_file(protocol)
#find pulseFreq
freq = mp.find_value(text, 'pulseFreq',timing)
npulses = mp.find_value(text, 'pulses',timing)
nbursts = mp.find_value(text, 'numbursts',timing)
burstfreq = mp.find_value(text, 'burstFreq',timing)
ntrains = mp.find_value(text, 'numtrains',timing)
trainfreq = mp.find_value(text, 'trainFreq',timing)
print freq, npulses, nbursts, burstfreq, ntrains, trainfreq
if npulses == None:
npulses = 1
fname_base = paradigm_names[i]+'_'+timing+'_stimulation__'
spine_list = ['spine_1']
mp.distribute(freq,npulses,burstfreq,nbursts,trainfreq,ntrains,stim_start,fname_base,spine_list)
sim_file = sim_name+'_'+paradigm_names[i]+'_'+timing+'_location_'+location+'_phasic.g'
fil = open(sim_file,'w')
fil.write(text_sim_1)
fil.write('str Location = "'+location+'"\n')
fil.write(text_sim_11)
fil.write('str Protocol = "'+paradigm_names[i]+'"\n')
fil.write('str Timing = "'+timing+'"\n')
fil.write(text_sim_2)
fil.write("include "+protocol+'\n')
fil.write(text_sim_3)
fil.close()
process = subprocess.Popen(['/home/asia/genesis-2.4/chemesis','-nox','-notty','-batch',sim_file])
ret = process.wait()