bmtool 0.7.0.6.4__py3-none-any.whl → 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bmtool/SLURM.py +162 -109
- bmtool/__init__.py +1 -1
- bmtool/__main__.py +8 -7
- bmtool/analysis/entrainment.py +250 -143
- bmtool/analysis/lfp.py +279 -134
- bmtool/analysis/netcon_reports.py +41 -44
- bmtool/analysis/spikes.py +114 -73
- bmtool/bmplot/connections.py +658 -325
- bmtool/bmplot/entrainment.py +17 -18
- bmtool/bmplot/lfp.py +24 -17
- bmtool/bmplot/netcon_reports.py +0 -4
- bmtool/bmplot/spikes.py +97 -48
- bmtool/connectors.py +394 -251
- bmtool/debug/commands.py +13 -7
- bmtool/debug/debug.py +2 -2
- bmtool/graphs.py +26 -19
- bmtool/manage.py +6 -11
- bmtool/plot_commands.py +350 -151
- bmtool/singlecell.py +357 -195
- bmtool/synapses.py +564 -470
- bmtool/util/commands.py +1079 -627
- bmtool/util/neuron/celltuner.py +989 -609
- bmtool/util/util.py +992 -588
- {bmtool-0.7.0.6.4.dist-info → bmtool-0.7.1.dist-info}/METADATA +40 -2
- bmtool-0.7.1.dist-info/RECORD +34 -0
- {bmtool-0.7.0.6.4.dist-info → bmtool-0.7.1.dist-info}/WHEEL +1 -1
- bmtool-0.7.0.6.4.dist-info/RECORD +0 -34
- {bmtool-0.7.0.6.4.dist-info → bmtool-0.7.1.dist-info}/entry_points.txt +0 -0
- {bmtool-0.7.0.6.4.dist-info → bmtool-0.7.1.dist-info}/licenses/LICENSE +0 -0
- {bmtool-0.7.0.6.4.dist-info → bmtool-0.7.1.dist-info}/top_level.txt +0 -0
bmtool/util/commands.py
CHANGED
@@ -1,53 +1,122 @@
|
|
1
|
-
|
2
|
-
import click
|
3
|
-
import logging
|
4
|
-
import os
|
5
|
-
import questionary
|
1
|
+
import glob
|
6
2
|
import json
|
7
|
-
import
|
3
|
+
import os
|
8
4
|
import shutil
|
9
|
-
import
|
5
|
+
import tempfile
|
6
|
+
from os import name, system
|
10
7
|
|
11
|
-
|
8
|
+
import click
|
9
|
+
import questionary
|
10
|
+
from clint.textui import colored
|
12
11
|
|
13
12
|
from .util import load_config
|
14
13
|
|
15
|
-
|
16
|
-
@click.
|
14
|
+
|
15
|
+
@click.group("util")
|
16
|
+
@click.option(
|
17
|
+
"-c",
|
18
|
+
"--config",
|
19
|
+
type=click.Path(),
|
20
|
+
default="./simulation_config.json",
|
21
|
+
help='Configuration file to use, default: "simulation_config.json"',
|
22
|
+
)
|
17
23
|
@click.pass_context
|
18
24
|
def cli(ctx, config):
|
19
|
-
config_path = os.path.abspath(os.path.expanduser(config)).replace("\\","/")
|
25
|
+
config_path = os.path.abspath(os.path.expanduser(config)).replace("\\", "/")
|
20
26
|
|
21
27
|
ctx.obj["config"] = config_path
|
22
28
|
|
23
29
|
if not os.path.exists(config_path):
|
24
|
-
#click.echo(colored.red("Config file not found: " + config))
|
30
|
+
# click.echo(colored.red("Config file not found: " + config))
|
25
31
|
pass
|
26
32
|
|
33
|
+
|
27
34
|
def check_neuron_installed(confirm=True):
|
28
35
|
try:
|
29
|
-
import
|
36
|
+
import importlib.util
|
37
|
+
|
38
|
+
if importlib.util.find_spec("neuron") is None:
|
39
|
+
raise ModuleNotFoundError("neuron module not found")
|
30
40
|
except ModuleNotFoundError as e:
|
31
41
|
print("Error: Python NEURON was not found.")
|
32
42
|
if not confirm or not questionary.confirm("Do you want to continue anyway? ").ask():
|
33
43
|
return False
|
34
44
|
return True
|
35
45
|
|
36
|
-
|
37
|
-
@click.
|
38
|
-
@click.option(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@click.option(
|
45
|
-
|
46
|
+
|
47
|
+
@click.group("cell", help="Access various utilities for manipulating your cell")
|
48
|
+
@click.option(
|
49
|
+
"--hoc-folder",
|
50
|
+
type=click.STRING,
|
51
|
+
default=None,
|
52
|
+
help="override the default cell picker from the simulation config hoc location",
|
53
|
+
)
|
54
|
+
@click.option(
|
55
|
+
"--mod-folder",
|
56
|
+
type=click.STRING,
|
57
|
+
default=None,
|
58
|
+
help="override the default simulation config mod file location",
|
59
|
+
)
|
60
|
+
@click.option(
|
61
|
+
"--template",
|
62
|
+
type=click.STRING,
|
63
|
+
default=None,
|
64
|
+
help="supply template name and skip interactive mode question",
|
65
|
+
)
|
66
|
+
@click.option(
|
67
|
+
"--hoc",
|
68
|
+
type=click.STRING,
|
69
|
+
default=None,
|
70
|
+
help="loads a single hoc file, best for directories with multiple NON-Template hoc files, specify --hoc TEMPLATE_FILE.hoc",
|
71
|
+
)
|
72
|
+
@click.option(
|
73
|
+
"--prefab",
|
74
|
+
type=click.BOOL,
|
75
|
+
default=False,
|
76
|
+
is_flag=True,
|
77
|
+
help="Downloads a set of pre-defined cells to the current directory",
|
78
|
+
)
|
79
|
+
@click.option(
|
80
|
+
"--prefab-repo",
|
81
|
+
type=click.STRING,
|
82
|
+
default="https://github.com/tjbanks/bmtool-cell-prefab",
|
83
|
+
help="Override the github repository URL to download pre-defined cells from (default: https://github.com/tjbanks/bmtool-cell-prefab)",
|
84
|
+
)
|
85
|
+
@click.option(
|
86
|
+
"--prefab-branch",
|
87
|
+
type=click.STRING,
|
88
|
+
default="master",
|
89
|
+
help="Override the github repository branch (default: master)",
|
90
|
+
)
|
91
|
+
@click.option(
|
92
|
+
"--prefab-refresh",
|
93
|
+
type=click.BOOL,
|
94
|
+
default=False,
|
95
|
+
is_flag=True,
|
96
|
+
help="Delete cached cells directory and re-download from prefab repository (WARNING: deletes everything in the folder)",
|
97
|
+
)
|
98
|
+
@click.option(
|
99
|
+
"--prefab-no-compile",
|
100
|
+
type=click.BOOL,
|
101
|
+
default=False,
|
102
|
+
is_flag=True,
|
103
|
+
help="Don't attempt to (re-)compile prefab cell mod files",
|
104
|
+
)
|
46
105
|
@click.pass_context
|
47
|
-
def cell(
|
48
|
-
|
106
|
+
def cell(
|
107
|
+
ctx,
|
108
|
+
hoc_folder,
|
109
|
+
mod_folder,
|
110
|
+
template,
|
111
|
+
hoc,
|
112
|
+
prefab,
|
113
|
+
prefab_repo,
|
114
|
+
prefab_branch,
|
115
|
+
prefab_refresh,
|
116
|
+
prefab_no_compile,
|
117
|
+
):
|
49
118
|
if not check_neuron_installed():
|
50
|
-
return
|
119
|
+
return
|
51
120
|
|
52
121
|
hoc_template_file = None
|
53
122
|
prefab_dict = None
|
@@ -59,49 +128,58 @@ def cell(ctx,hoc_folder,mod_folder,template,hoc,prefab,prefab_repo,prefab_branch
|
|
59
128
|
prefab_location = ""
|
60
129
|
|
61
130
|
dl = False
|
62
|
-
if prefab:
|
63
|
-
if os.path.exists(
|
131
|
+
if prefab: # User has elected to use prefab cells
|
132
|
+
if os.path.exists(
|
133
|
+
"./" + prefab_dict_file
|
134
|
+
): # If the current directory contains the repository continue
|
64
135
|
prefab_location = "./"
|
65
136
|
|
66
|
-
#mod_folder = "./" + os.path.relpath("./").replace("\\","/")
|
67
|
-
#hoc_folder = "./" + os.path.relpath("./").replace("\\","/")
|
68
|
-
#hoc_template_file = prefab_template_file
|
137
|
+
# mod_folder = "./" + os.path.relpath("./").replace("\\","/")
|
138
|
+
# hoc_folder = "./" + os.path.relpath("./").replace("\\","/")
|
139
|
+
# hoc_template_file = prefab_template_file
|
69
140
|
if prefab_refresh:
|
70
|
-
click.echo(
|
71
|
-
|
72
|
-
|
141
|
+
click.echo(
|
142
|
+
colored.red(
|
143
|
+
"Refresh selected -- Change directory to parent directory (cd ..) and re-run to refresh"
|
144
|
+
)
|
145
|
+
)
|
73
146
|
|
147
|
+
else: # Check if current directory contains the repository
|
74
148
|
if os.path.exists("./" + prefab_directory + "/" + prefab_dict_file):
|
75
149
|
if prefab_refresh:
|
76
|
-
shutil.rmtree("./"+prefab_directory)
|
150
|
+
shutil.rmtree("./" + prefab_directory)
|
77
151
|
dl = True
|
78
|
-
else:
|
152
|
+
else: # The folder/file we're looking for doesn't exist
|
79
153
|
dl = True
|
80
154
|
|
81
|
-
if dl:
|
155
|
+
if dl: # Download the repo
|
82
156
|
click.echo(colored.green("Downloading premade cells from " + prefab_zip_url))
|
83
|
-
import
|
157
|
+
import io
|
158
|
+
import zipfile
|
159
|
+
|
160
|
+
import requests
|
161
|
+
|
84
162
|
r = requests.get(prefab_zip_url)
|
85
163
|
z = zipfile.ZipFile(io.BytesIO(r.content))
|
86
164
|
z.extractall()
|
87
|
-
|
88
|
-
prefab_location = "./" + os.path.relpath(prefab_directory).replace("\\","/")
|
89
|
-
|
90
|
-
|
91
|
-
with open(os.path.join(prefab_location,prefab_dict_file), 'r') as f:
|
165
|
+
|
166
|
+
prefab_location = "./" + os.path.relpath(prefab_directory).replace("\\", "/")
|
167
|
+
|
168
|
+
with open(os.path.join(prefab_location, prefab_dict_file), "r") as f:
|
92
169
|
prefab_dict = json.load(f)
|
93
170
|
|
94
|
-
|
95
171
|
prefab_cells = prefab_dict.get("cells") or []
|
96
|
-
|
172
|
+
|
97
173
|
if not template:
|
98
|
-
template = questionary.select(
|
99
|
-
"Select a cell:",
|
100
|
-
choices=prefab_cells).ask()
|
174
|
+
template = questionary.select("Select a cell:", choices=prefab_cells).ask()
|
101
175
|
|
102
|
-
mod_folder =
|
103
|
-
|
104
|
-
|
176
|
+
mod_folder = (
|
177
|
+
prefab_location + "/" + prefab_cells.get(template).get("mod_folder").replace("\\", "/")
|
178
|
+
)
|
179
|
+
hoc_folder = (
|
180
|
+
prefab_location + "/" + prefab_cells.get(template).get("hoc_folder").replace("\\", "/")
|
181
|
+
)
|
182
|
+
hoc_template_file = prefab_cells.get(template).get("hoc_template_file").replace("\\", "/")
|
105
183
|
|
106
184
|
if not prefab_no_compile:
|
107
185
|
click.echo(colored.green("Compiling mod files..."))
|
@@ -113,43 +191,53 @@ def cell(ctx,hoc_folder,mod_folder,template,hoc,prefab,prefab_repo,prefab_branch
|
|
113
191
|
if not ret:
|
114
192
|
click.echo(colored.green("COMPILATION COMPLETE"))
|
115
193
|
else:
|
116
|
-
click.echo(
|
194
|
+
click.echo(
|
195
|
+
colored.red(
|
196
|
+
"nrnivmodl may not have been run, execute nrnivmodl or mknrndll manually in the `"
|
197
|
+
)
|
198
|
+
+ colored.green(os.path.abspath(mod_folder))
|
199
|
+
+ colored.red(
|
200
|
+
"` folder then press enter... SKIP THIS IF YOU HAVE ALREADY COMPILED"
|
201
|
+
)
|
202
|
+
)
|
117
203
|
input()
|
118
|
-
|
204
|
+
|
119
205
|
else:
|
120
206
|
if hoc:
|
121
207
|
if not hoc_folder:
|
122
|
-
hoc_folder =
|
208
|
+
hoc_folder = "./"
|
123
209
|
if not mod_folder:
|
124
|
-
mod_folder =
|
210
|
+
mod_folder = "./"
|
125
211
|
hoc_template_file = hoc
|
126
212
|
elif not hoc_folder or not mod_folder:
|
127
213
|
try:
|
128
|
-
cfg = load_config(ctx.obj[
|
214
|
+
cfg = load_config(ctx.obj["config"])
|
129
215
|
if not hoc_folder:
|
130
|
-
hoc_folder = cfg[
|
216
|
+
hoc_folder = cfg["components"]["templates_dir"]
|
131
217
|
if not mod_folder:
|
132
|
-
mod_folder = cfg[
|
218
|
+
mod_folder = cfg["components"]["mechanisms_dir"]
|
133
219
|
except Exception as e:
|
134
|
-
#lazy way of passing cases where sim config is not found and template provided
|
220
|
+
# lazy way of passing cases where sim config is not found and template provided
|
135
221
|
if not hoc_folder:
|
136
222
|
print("Setting hoc folder to ./")
|
137
|
-
hoc_folder =
|
223
|
+
hoc_folder = "."
|
138
224
|
if not mod_folder:
|
139
225
|
print("Setting mod folder to ./")
|
140
|
-
mod_folder =
|
226
|
+
mod_folder = "."
|
141
227
|
|
142
228
|
ctx.obj["hoc_folder"] = hoc_folder
|
143
229
|
ctx.obj["mod_folder"] = mod_folder
|
144
230
|
ctx.obj["hoc_template_file"] = hoc_template_file
|
145
231
|
ctx.obj["cell_template"] = template
|
146
232
|
ctx.obj["prefab"] = prefab_dict
|
147
|
-
|
233
|
+
|
148
234
|
return
|
149
235
|
|
236
|
+
|
150
237
|
cli.add_command(cell)
|
151
238
|
|
152
|
-
|
239
|
+
|
240
|
+
class Builder:
|
153
241
|
def __init__(self):
|
154
242
|
self.title = ""
|
155
243
|
self._options = {}
|
@@ -157,14 +245,14 @@ class Builder():
|
|
157
245
|
return
|
158
246
|
|
159
247
|
def run(self):
|
160
|
-
def clear():
|
161
|
-
# for windows
|
162
|
-
if name ==
|
163
|
-
_ = system(
|
164
|
-
# for mac and linux(here, os.name is 'posix')
|
165
|
-
else:
|
166
|
-
_ = system(
|
167
|
-
|
248
|
+
def clear():
|
249
|
+
# for windows
|
250
|
+
if name == "nt":
|
251
|
+
_ = system("cls")
|
252
|
+
# for mac and linux(here, os.name is 'posix')
|
253
|
+
else:
|
254
|
+
_ = system("clear")
|
255
|
+
|
168
256
|
prompter = self
|
169
257
|
while prompter:
|
170
258
|
clear()
|
@@ -174,36 +262,35 @@ class Builder():
|
|
174
262
|
return
|
175
263
|
|
176
264
|
def prompt(self):
|
177
|
-
options = list(self._options.keys())
|
178
|
-
options_ind = [str(i+1)+") "+op for i,op in enumerate(options)]
|
265
|
+
options = list(self._options.keys())
|
266
|
+
options_ind = [str(i + 1) + ") " + op for i, op in enumerate(options)]
|
179
267
|
if bool(self._exit_option):
|
180
|
-
exit_option = list(self._exit_option.keys())
|
181
|
-
exit_option_ind = [
|
268
|
+
exit_option = list(self._exit_option.keys())
|
269
|
+
exit_option_ind = [
|
270
|
+
str(i) + ") " + op for i, op in enumerate(exit_option)
|
271
|
+
] # should only be one
|
182
272
|
options = options + exit_option
|
183
273
|
options_ind = options_ind + exit_option_ind
|
184
|
-
|
185
|
-
selected = questionary.select(
|
186
|
-
self.title,
|
187
|
-
choices=options_ind).ask()
|
274
|
+
|
275
|
+
selected = questionary.select(self.title, choices=options_ind).ask()
|
188
276
|
|
189
277
|
selected = options[options_ind.index(selected)]
|
190
|
-
|
278
|
+
|
191
279
|
if self._exit_option.get(selected):
|
192
280
|
_prompt = self._exit_option[selected][0]()
|
193
281
|
else:
|
194
282
|
_prompt = self._options[selected][0]()
|
195
283
|
return _prompt
|
196
284
|
|
197
|
-
def register(self, text, handler,args=None,is_exit=False):
|
285
|
+
def register(self, text, handler, args=None, is_exit=False):
|
198
286
|
if is_exit:
|
199
287
|
self._exit_option.clear()
|
200
|
-
self._exit_option[text] = (handler,args)
|
288
|
+
self._exit_option[text] = (handler, args)
|
201
289
|
else:
|
202
|
-
self._options[text] = (handler,args)
|
290
|
+
self._options[text] = (handler, args)
|
203
291
|
return
|
204
292
|
|
205
293
|
|
206
|
-
|
207
294
|
class BaseBuilder(Builder):
|
208
295
|
def __init__(self, ctg):
|
209
296
|
super(BaseBuilder, self).__init__()
|
@@ -213,31 +300,33 @@ class BaseBuilder(Builder):
|
|
213
300
|
return
|
214
301
|
|
215
302
|
def register_all(self):
|
216
|
-
|
217
303
|
def new_window():
|
218
|
-
return WindowBuilder(self,self.ctg)
|
219
|
-
|
304
|
+
return WindowBuilder(self, self.ctg)
|
305
|
+
|
220
306
|
def print_ctx():
|
221
307
|
print("Not currently implemented")
|
222
308
|
print("Press enter to continue...")
|
223
309
|
input()
|
224
310
|
return self
|
225
|
-
|
311
|
+
|
226
312
|
def write_to_hoc():
|
227
|
-
#print("Enter the name of the file you wish to write: (eg: cellgui.hoc)")
|
228
|
-
filename = questionary.text(
|
313
|
+
# print("Enter the name of the file you wish to write: (eg: cellgui.hoc)")
|
314
|
+
filename = questionary.text(
|
315
|
+
"Enter the name of the file you wish to write: (eg: cellgui.hoc)",
|
316
|
+
default="cellgui.hoc",
|
317
|
+
).ask()
|
229
318
|
self.ctg.write_hoc(filename)
|
230
319
|
print("Done. Press enter to continue...")
|
231
320
|
input()
|
232
321
|
return self
|
233
322
|
|
234
323
|
def set_tstop():
|
235
|
-
tstop = questionary.text("Set tstop (ms): )",default=str(self.ctg.tstop)).ask()
|
324
|
+
tstop = questionary.text("Set tstop (ms): )", default=str(self.ctg.tstop)).ask()
|
236
325
|
self.ctg.tstop = tstop
|
237
326
|
return self
|
238
327
|
|
239
328
|
def set_v_init():
|
240
|
-
v_init = questionary.text("Set v_init (mV): )",default=str(self.ctg.v_init)).ask()
|
329
|
+
v_init = questionary.text("Set v_init (mV): )", default=str(self.ctg.v_init)).ask()
|
241
330
|
self.ctg.v_init = v_init
|
242
331
|
return self
|
243
332
|
|
@@ -249,8 +338,9 @@ class BaseBuilder(Builder):
|
|
249
338
|
self.register("Set tstop", set_tstop)
|
250
339
|
self.register("Set v_init", set_v_init)
|
251
340
|
self.register("Write to HOC executable", write_to_hoc)
|
252
|
-
self.register("Finish and Display", finished
|
253
|
-
|
341
|
+
self.register("Finish and Display", finished, is_exit=True)
|
342
|
+
|
343
|
+
|
254
344
|
class WindowBuilder(Builder):
|
255
345
|
def __init__(self, parent, ctg):
|
256
346
|
super(WindowBuilder, self).__init__()
|
@@ -262,22 +352,22 @@ class WindowBuilder(Builder):
|
|
262
352
|
return
|
263
353
|
|
264
354
|
def register_all(self):
|
265
|
-
|
266
355
|
def set_title():
|
267
356
|
print("Type the new title for this window")
|
268
|
-
self.ctg.set_title(self.window_index,input())
|
357
|
+
self.ctg.set_title(self.window_index, input())
|
269
358
|
self.title = self.ctg.get_title(self.window_index)
|
270
359
|
return self
|
271
|
-
|
360
|
+
|
272
361
|
def new_column():
|
273
|
-
return ColumnBuilder(self,self.ctg)
|
274
|
-
|
362
|
+
return ColumnBuilder(self, self.ctg)
|
363
|
+
|
275
364
|
def finished():
|
276
365
|
return self.parent
|
277
366
|
|
278
367
|
self.register("Add Column", new_column)
|
279
368
|
self.register("Set Window Title", set_title)
|
280
|
-
self.register("Finish Window", finished
|
369
|
+
self.register("Finish Window", finished, is_exit=True)
|
370
|
+
|
281
371
|
|
282
372
|
class ColumnBuilder(Builder):
|
283
373
|
def __init__(self, parent, ctg):
|
@@ -285,69 +375,68 @@ class ColumnBuilder(Builder):
|
|
285
375
|
self.parent = parent
|
286
376
|
self.ctg = ctg
|
287
377
|
self.column_index = ctg.add_column(self.parent.window_index)
|
288
|
-
self.title =
|
378
|
+
self.title = (
|
379
|
+
"Window " + str(self.parent.window_index + 1) + " Column " + str(self.column_index + 1)
|
380
|
+
)
|
289
381
|
self.register_all()
|
290
382
|
return
|
291
383
|
|
292
384
|
def register_all(self):
|
293
|
-
|
294
385
|
def new_widget():
|
295
386
|
print("Not currently implemented")
|
296
387
|
print("Press enter to continue...")
|
297
388
|
input()
|
298
389
|
return self
|
299
|
-
|
390
|
+
|
300
391
|
def new_plot_widget():
|
301
|
-
return PlotWidgetBuilder(self,self.ctg)
|
302
|
-
|
392
|
+
return PlotWidgetBuilder(self, self.ctg)
|
393
|
+
|
303
394
|
def new_controlmenu_widget():
|
304
395
|
from .neuron.celltuner import ControlMenuWidget
|
396
|
+
|
305
397
|
widget = ControlMenuWidget()
|
306
|
-
self.ctg.add_widget(self.parent.window_index, self.column_index,widget)
|
398
|
+
self.ctg.add_widget(self.parent.window_index, self.column_index, widget)
|
307
399
|
print("Done. Press enter to continue...")
|
308
400
|
input()
|
309
401
|
return self
|
310
402
|
|
311
403
|
def new_pointmenu_widget():
|
312
|
-
return PointMenuWidgetBuilder(self,self.ctg)
|
404
|
+
return PointMenuWidgetBuilder(self, self.ctg)
|
313
405
|
|
314
406
|
def new_secmenu_widget():
|
315
|
-
return SecMenuWidgetBuilder(self,self.ctg)
|
407
|
+
return SecMenuWidgetBuilder(self, self.ctg)
|
316
408
|
|
317
409
|
def finished():
|
318
410
|
return self.parent
|
319
411
|
|
320
|
-
#self.register("Add Widget", new_widget)
|
412
|
+
# self.register("Add Widget", new_widget)
|
321
413
|
self.register("Add Plot Widget", new_plot_widget)
|
322
414
|
self.register("Add Control Menu Widget (Init & Run)", new_controlmenu_widget)
|
323
415
|
self.register("Add SecMenu Widget (Section Variables)", new_secmenu_widget)
|
324
416
|
self.register("Add Point Menu Widget (Current Clamp, Netstim)", new_pointmenu_widget)
|
325
|
-
self.register("Finish Column", finished
|
417
|
+
self.register("Finish Column", finished, is_exit=True)
|
418
|
+
|
326
419
|
|
327
420
|
class SecMenuWidgetBuilder(Builder):
|
328
421
|
def __init__(self, parent, ctg):
|
329
422
|
super(SecMenuWidgetBuilder, self).__init__()
|
330
423
|
|
331
|
-
from .neuron.celltuner import SecMenuWidget
|
332
|
-
|
333
424
|
self.parent = parent
|
334
425
|
self.ctg = ctg
|
335
|
-
self.title =
|
426
|
+
self.title = "(Section Menu Widget)"
|
336
427
|
self.register_all()
|
337
428
|
return
|
338
429
|
|
339
430
|
def register_all(self):
|
340
|
-
|
341
431
|
def select():
|
342
432
|
from .neuron.celltuner import SecMenuWidget
|
433
|
+
|
343
434
|
cell_options = []
|
344
435
|
cell_options_obj = []
|
345
436
|
cell_options.append(self.ctg.template.hname())
|
346
437
|
cell_options_obj.append(self.ctg.template)
|
347
|
-
|
348
|
-
cell_selected = questionary.select(
|
349
|
-
"Select the Cell",
|
350
|
-
choices=cell_options).ask()
|
438
|
+
|
439
|
+
cell_selected = questionary.select("Select the Cell", choices=cell_options).ask()
|
351
440
|
|
352
441
|
section_options = []
|
353
442
|
section_options_obj = []
|
@@ -356,45 +445,47 @@ class SecMenuWidgetBuilder(Builder):
|
|
356
445
|
section_options = [s.hname() for s in section_options_obj]
|
357
446
|
|
358
447
|
section_selected = questionary.select(
|
359
|
-
|
360
|
-
|
448
|
+
"Select the Section", choices=section_options
|
449
|
+
).ask()
|
361
450
|
|
362
451
|
section_selected_obj = section_options_obj[section_options.index(section_selected)]
|
363
|
-
section_location = questionary.text(
|
452
|
+
section_location = questionary.text(
|
453
|
+
"Enter recording location (default:0.5): ", default="0.5"
|
454
|
+
).ask()
|
455
|
+
|
456
|
+
self.widget = SecMenuWidget(section_selected_obj, x=float(section_location))
|
457
|
+
self.widget_index = self.ctg.add_widget(
|
458
|
+
self.parent.parent.window_index, self.parent.column_index, self.widget
|
459
|
+
)
|
364
460
|
|
365
|
-
self.widget = SecMenuWidget(section_selected_obj,x=float(section_location))
|
366
|
-
self.widget_index = self.ctg.add_widget(self.parent.parent.window_index, self.parent.column_index,self.widget)
|
367
|
-
|
368
461
|
return self.parent
|
369
462
|
|
370
463
|
def finish():
|
371
464
|
return self.parent
|
372
465
|
|
373
466
|
self.register("Select Section", select)
|
374
|
-
self.register("Return without adding widget", finish
|
467
|
+
self.register("Return without adding widget", finish, is_exit=True)
|
375
468
|
return
|
376
469
|
|
470
|
+
|
377
471
|
class PointMenuWidgetBuilder(Builder):
|
378
472
|
def __init__(self, parent, ctg):
|
379
473
|
super(PointMenuWidgetBuilder, self).__init__()
|
380
474
|
|
381
475
|
self.parent = parent
|
382
476
|
self.ctg = ctg
|
383
|
-
self.title =
|
477
|
+
self.title = "(Point Menu Widget)"
|
384
478
|
self.register_all()
|
385
479
|
return
|
386
480
|
|
387
481
|
def register_all(self):
|
388
|
-
|
389
482
|
def select_section_location():
|
390
483
|
cell_options = []
|
391
484
|
cell_options_obj = []
|
392
485
|
cell_options.append(self.ctg.template.hname())
|
393
486
|
cell_options_obj.append(self.ctg.template)
|
394
|
-
|
395
|
-
cell_selected = questionary.select(
|
396
|
-
"Select the Cell",
|
397
|
-
choices=cell_options).ask()
|
487
|
+
|
488
|
+
cell_selected = questionary.select("Select the Cell", choices=cell_options).ask()
|
398
489
|
|
399
490
|
section_options = []
|
400
491
|
section_options_obj = []
|
@@ -403,67 +494,113 @@ class PointMenuWidgetBuilder(Builder):
|
|
403
494
|
section_options = [s.hname() for s in section_options_obj]
|
404
495
|
|
405
496
|
section_selected = questionary.select(
|
406
|
-
|
407
|
-
|
497
|
+
"Select the Section", choices=section_options
|
498
|
+
).ask()
|
408
499
|
|
409
500
|
section_selected_obj = section_options_obj[section_options.index(section_selected)]
|
410
|
-
section_location = questionary.text(
|
501
|
+
section_location = questionary.text(
|
502
|
+
"Enter location (default:0.5): ", default="0.5"
|
503
|
+
).ask()
|
411
504
|
|
412
505
|
return section_selected_obj, section_location
|
413
506
|
|
414
507
|
def new_clamp():
|
415
508
|
from .neuron.celltuner import PointMenuWidget
|
416
|
-
|
509
|
+
|
417
510
|
section_selected_obj, section_location = select_section_location()
|
418
511
|
|
419
|
-
delay = float(
|
420
|
-
|
421
|
-
|
512
|
+
delay = float(
|
513
|
+
questionary.text("Enter default iclamp delay (default:0): ", default="0").ask()
|
514
|
+
)
|
515
|
+
dur = float(
|
516
|
+
questionary.text(
|
517
|
+
"Enter default iclamp duration (default:100): ", default="100"
|
518
|
+
).ask()
|
519
|
+
)
|
520
|
+
amp = float(
|
521
|
+
questionary.text("Enter default iclamp amp(mA) (default:1): ", default="1").ask()
|
522
|
+
)
|
422
523
|
|
423
524
|
self.widget = PointMenuWidget(None)
|
424
|
-
iclamp = self.widget.iclamp(
|
525
|
+
iclamp = self.widget.iclamp(
|
526
|
+
section_selected_obj(float(section_location)), dur, amp, delay
|
527
|
+
)
|
425
528
|
self.ctg.register_iclamp(iclamp)
|
426
|
-
self.widget_index = self.ctg.add_widget(
|
529
|
+
self.widget_index = self.ctg.add_widget(
|
530
|
+
self.parent.parent.window_index, self.parent.column_index, self.widget
|
531
|
+
)
|
427
532
|
|
428
533
|
return self.parent
|
429
534
|
|
430
535
|
def new_netstim():
|
431
536
|
from .neuron.celltuner import PointMenuWidget
|
537
|
+
|
432
538
|
section_selected_obj, section_location = select_section_location()
|
433
539
|
|
434
540
|
notlisted = "Synapse not listed"
|
435
541
|
|
436
542
|
synapse_options = self.ctg.mechanism_point_processes[:]
|
437
|
-
synapse_options = synapse_options + ["AlphaSynapse","Exp2Syn","ExpSyn"]
|
543
|
+
synapse_options = synapse_options + ["AlphaSynapse", "Exp2Syn", "ExpSyn"] # Builtins
|
438
544
|
synapse_options.append(notlisted)
|
439
545
|
|
440
546
|
synapse_selected = questionary.select(
|
441
|
-
|
442
|
-
|
547
|
+
"Select the Synapse type from the most likely options", choices=synapse_options
|
548
|
+
).ask()
|
443
549
|
|
444
550
|
if synapse_selected == notlisted:
|
445
551
|
synapse_options = [i for i in self.ctg.get_all_h_hocobjects()]
|
446
552
|
synapse_selected = questionary.select(
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
interval = int(
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
553
|
+
"Select the Synapse (ALL HOCOBJECTS)", choices=synapse_options
|
554
|
+
).ask()
|
555
|
+
|
556
|
+
interval = int(
|
557
|
+
questionary.text(
|
558
|
+
"Enter default netstim interval (ms (mean) time between spikes): ", default="50"
|
559
|
+
).ask()
|
560
|
+
)
|
561
|
+
number = int(
|
562
|
+
questionary.text(
|
563
|
+
"Enter default netstim number of events ((average) number of spikes): ",
|
564
|
+
default="10",
|
565
|
+
).ask()
|
566
|
+
)
|
567
|
+
start = int(
|
568
|
+
questionary.text(
|
569
|
+
"Enter default netstim start (ms (most likely) start time of first spike): ",
|
570
|
+
default="0",
|
571
|
+
).ask()
|
572
|
+
)
|
573
|
+
noise = float(
|
574
|
+
questionary.text(
|
575
|
+
"Enter default netstim noise (range 0 to 1. Fractional randomness.): ",
|
576
|
+
default="0",
|
577
|
+
).ask()
|
578
|
+
)
|
579
|
+
weight = float(
|
580
|
+
questionary.text(
|
581
|
+
"Enter default netcon weight (range 0 to 1. Default: 1): ", default="1"
|
582
|
+
).ask()
|
583
|
+
)
|
584
|
+
|
456
585
|
self.widget = PointMenuWidget(None)
|
457
586
|
self.widget_extra = PointMenuWidget(None)
|
458
|
-
synapse = self.widget_extra.synapse(
|
459
|
-
|
587
|
+
synapse = self.widget_extra.synapse(
|
588
|
+
section_selected_obj, section_location, synapse_selected
|
589
|
+
)
|
590
|
+
netstim, netcon = self.widget.netstim(
|
591
|
+
interval, number, start, noise, target=synapse, weight=weight
|
592
|
+
)
|
460
593
|
self.ctg.register_netstim(netstim)
|
461
594
|
self.ctg.register_netcon(netcon)
|
462
595
|
self.ctg.register_synapse(synapse)
|
463
596
|
|
464
|
-
self.widget_index_extra = self.ctg.add_widget(
|
465
|
-
|
466
|
-
|
597
|
+
self.widget_index_extra = self.ctg.add_widget(
|
598
|
+
self.parent.parent.window_index, self.parent.column_index, self.widget_extra
|
599
|
+
)
|
600
|
+
self.widget_index = self.ctg.add_widget(
|
601
|
+
self.parent.parent.window_index, self.parent.column_index, self.widget
|
602
|
+
)
|
603
|
+
|
467
604
|
return self.parent
|
468
605
|
|
469
606
|
def finish():
|
@@ -471,9 +608,10 @@ class PointMenuWidgetBuilder(Builder):
|
|
471
608
|
|
472
609
|
self.register("Add Netstim to Cell and Insert Widgets", new_netstim)
|
473
610
|
self.register("Add Current Clamp to Cell and Insert Widget", new_clamp)
|
474
|
-
self.register("Finished", finish
|
611
|
+
self.register("Finished", finish, is_exit=True)
|
475
612
|
return
|
476
613
|
|
614
|
+
|
477
615
|
class PlotWidgetBuilder(Builder):
|
478
616
|
def __init__(self, parent, ctg):
|
479
617
|
super(PlotWidgetBuilder, self).__init__()
|
@@ -483,331 +621,482 @@ class PlotWidgetBuilder(Builder):
|
|
483
621
|
self.parent = parent
|
484
622
|
self.ctg = ctg
|
485
623
|
self.widget = PlotWidget(tstop=self.ctg.tstop)
|
486
|
-
self.widget_index = ctg.add_widget(
|
487
|
-
|
488
|
-
|
624
|
+
self.widget_index = ctg.add_widget(
|
625
|
+
self.parent.parent.window_index, self.parent.column_index, self.widget
|
626
|
+
)
|
627
|
+
self.title = (
|
628
|
+
"Window "
|
629
|
+
+ str(self.parent.parent.window_index + 1)
|
630
|
+
+ " Column "
|
631
|
+
+ str(self.parent.column_index + 1)
|
632
|
+
+ " Widget "
|
633
|
+
+ str(self.widget_index)
|
634
|
+
+ " (Plot Widget)"
|
635
|
+
)
|
489
636
|
self.register_all()
|
490
637
|
return
|
491
638
|
|
492
639
|
def register_all(self):
|
493
|
-
|
494
640
|
def new_expression():
|
495
|
-
obj_options = ["Cell","Quick - Template Cell.soma Membrane Voltage (0.5)"]
|
641
|
+
obj_options = ["Cell", "Quick - Template Cell.soma Membrane Voltage (0.5)"]
|
496
642
|
obj_selected = questionary.select(
|
497
|
-
|
498
|
-
|
643
|
+
"Select the object type to plot", choices=obj_options
|
644
|
+
).ask()
|
499
645
|
if obj_selected == obj_options[0]:
|
500
|
-
|
501
646
|
cell_options = []
|
502
647
|
cell_options_obj = []
|
503
648
|
cell_options.append(self.ctg.template.hname())
|
504
649
|
cell_options_obj.append(self.ctg.template)
|
505
|
-
|
506
|
-
cell_selected = questionary.select(
|
507
|
-
"Select the Cell",
|
508
|
-
choices=cell_options).ask()
|
650
|
+
|
651
|
+
cell_selected = questionary.select("Select the Cell", choices=cell_options).ask()
|
509
652
|
|
510
653
|
section_options = []
|
511
654
|
section_options_obj = []
|
512
655
|
all_sections = self.ctg.all_sections()
|
513
|
-
section_options_obj = [
|
656
|
+
section_options_obj = [
|
657
|
+
s for s in all_sections if s.hname().startswith(cell_selected)
|
658
|
+
]
|
514
659
|
section_options = [s.hname() for s in section_options_obj]
|
515
660
|
|
516
661
|
section_selected = questionary.select(
|
517
|
-
|
518
|
-
|
662
|
+
"Select the Section", choices=section_options
|
663
|
+
).ask()
|
519
664
|
|
520
665
|
section_selected_obj = section_options_obj[section_options.index(section_selected)]
|
521
|
-
section_location = questionary.text(
|
522
|
-
|
523
|
-
|
666
|
+
section_location = questionary.text(
|
667
|
+
"Enter recording location (default:0.5): ", default="0.5"
|
668
|
+
).ask()
|
669
|
+
|
670
|
+
mechs = [
|
671
|
+
mech.name()
|
672
|
+
for mech in section_selected_obj(float(section_location))
|
673
|
+
if not mech.name().endswith("_ion")
|
674
|
+
]
|
524
675
|
|
525
676
|
variable_options = []
|
526
|
-
variable_options.append("v")
|
677
|
+
variable_options.append("v") # builtin voltage variable
|
527
678
|
for mech in mechs:
|
528
679
|
if self.ctg.mechanism_dict.get(mech):
|
529
680
|
ranges = self.ctg.mechanism_dict[mech]["NEURON"]["RANGE"]
|
530
681
|
variable_options = variable_options + [rng + "_" + mech for rng in ranges]
|
531
682
|
|
532
683
|
variables_selected = questionary.checkbox(
|
533
|
-
|
534
|
-
|
684
|
+
"Select the Variables", choices=variable_options
|
685
|
+
).ask()
|
686
|
+
|
687
|
+
# sec_text = self.ctg.root_sec.hname().split('.')[-1]+"(.5)"
|
688
|
+
# self.widget.add_expr(self.ctg.root_sec(0.5)._ref_v,sec_text,hoc_text="%s.soma.v(0.5)",hoc_text_obj=self.ctg.template)
|
535
689
|
|
536
|
-
#sec_text = self.ctg.root_sec.hname().split('.')[-1]+"(.5)"
|
537
|
-
#self.widget.add_expr(self.ctg.root_sec(0.5)._ref_v,sec_text,hoc_text="%s.soma.v(0.5)",hoc_text_obj=self.ctg.template)
|
538
|
-
|
539
690
|
for variable_selected in variables_selected:
|
540
|
-
#sec_var_ref = exec("section_selected_obj(float(section_location))."+variable_selected)
|
541
|
-
sec_var_ref = getattr(
|
542
|
-
|
543
|
-
|
544
|
-
|
691
|
+
# sec_var_ref = exec("section_selected_obj(float(section_location))."+variable_selected)
|
692
|
+
sec_var_ref = getattr(
|
693
|
+
section_selected_obj(float(section_location)), "_ref_" + variable_selected
|
694
|
+
)
|
695
|
+
sec_text = (
|
696
|
+
section_selected_obj.hname().split(".")[-1]
|
697
|
+
+ "("
|
698
|
+
+ section_location
|
699
|
+
+ ")."
|
700
|
+
+ variable_selected
|
701
|
+
)
|
702
|
+
sec_hoc_text = section_selected.split(".")[-1]
|
703
|
+
hoc_text = (
|
704
|
+
"%s."
|
705
|
+
+ sec_hoc_text
|
706
|
+
+ "."
|
707
|
+
+ variable_selected
|
708
|
+
+ "("
|
709
|
+
+ section_location
|
710
|
+
+ ")"
|
711
|
+
)
|
545
712
|
hoc_text_obj = cell_selected
|
546
|
-
|
547
|
-
self.widget.add_expr(sec_var_ref,sec_text,hoc_text=hoc_text,hoc_text_obj=hoc_text_obj)
|
548
713
|
|
549
|
-
|
714
|
+
self.widget.add_expr(
|
715
|
+
sec_var_ref, sec_text, hoc_text=hoc_text, hoc_text_obj=hoc_text_obj
|
716
|
+
)
|
717
|
+
|
718
|
+
# import pdb;pdb.set_trace()
|
550
719
|
|
551
720
|
elif obj_selected == obj_options[1]:
|
552
|
-
sec_text = self.ctg.root_sec.hname().split(
|
553
|
-
self.widget.add_expr(
|
721
|
+
sec_text = self.ctg.root_sec.hname().split(".")[-1] + "(.5)"
|
722
|
+
self.widget.add_expr(
|
723
|
+
self.ctg.root_sec(0.5)._ref_v,
|
724
|
+
sec_text,
|
725
|
+
hoc_text="%s.soma.v(0.5)",
|
726
|
+
hoc_text_obj=self.ctg.template,
|
727
|
+
)
|
554
728
|
print("Captured. Press enter to continue...")
|
555
729
|
input()
|
556
730
|
return self
|
557
|
-
|
731
|
+
|
558
732
|
def finished():
|
559
733
|
return self.parent
|
560
734
|
|
561
735
|
self.register("Add Expression", new_expression)
|
562
|
-
self.register("Finish Widget", finished
|
563
|
-
|
564
|
-
|
565
|
-
@
|
566
|
-
@click.option(
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
736
|
+
self.register("Finish Widget", finished, is_exit=True)
|
737
|
+
|
738
|
+
|
739
|
+
@cell.command("tune", help="Creates a NEURON GUI window with everything you need to tune a cell")
|
740
|
+
@click.option(
|
741
|
+
"--easy",
|
742
|
+
type=click.BOOL,
|
743
|
+
default=None,
|
744
|
+
is_flag=True,
|
745
|
+
help="Builds a simple GUI with no walkthrough",
|
746
|
+
)
|
747
|
+
@click.option(
|
748
|
+
"--builder",
|
749
|
+
type=click.BOOL,
|
750
|
+
default=None,
|
751
|
+
is_flag=True,
|
752
|
+
help="A commandline walkthrough for building your own GUI",
|
753
|
+
)
|
754
|
+
@click.option(
|
755
|
+
"--write-hoc",
|
756
|
+
type=click.STRING,
|
757
|
+
default=None,
|
758
|
+
help="write a standalone hoc file for your GUI, supply filename",
|
759
|
+
)
|
760
|
+
@click.option(
|
761
|
+
"--hide",
|
762
|
+
type=click.BOOL,
|
763
|
+
default=False,
|
764
|
+
is_flag=True,
|
765
|
+
help="hide the interface that shows automatically after building the GUI",
|
766
|
+
)
|
767
|
+
@click.option("--title", type=click.STRING, default=None)
|
768
|
+
@click.option("--tstop", type=click.INT, default=250)
|
769
|
+
@click.option(
|
770
|
+
"--debug", type=click.BOOL, default=False, is_flag=True, help="Print debug messages and errors"
|
771
|
+
)
|
572
772
|
@click.pass_context
|
573
|
-
def cell_tune(
|
773
|
+
def cell_tune(
|
774
|
+
ctx, easy, builder, write_hoc, hide, title, tstop, debug
|
775
|
+
): # , title, populations, group_by, save_file):
|
574
776
|
print("Loading...")
|
575
|
-
from .neuron.celltuner import CellTunerGUI,
|
777
|
+
from .neuron.celltuner import CellTunerGUI, ControlMenuWidget, PlotWidget, SecMenuWidget
|
576
778
|
|
577
779
|
hoc_folder = ctx.obj["hoc_folder"]
|
578
780
|
mod_folder = ctx.obj["mod_folder"]
|
579
781
|
hoc_template_file = ctx.obj["hoc_template_file"]
|
580
782
|
template = ctx.obj["cell_template"]
|
581
783
|
|
582
|
-
ctg = CellTunerGUI(hoc_folder,mod_folder,title=title,print_debug=debug)
|
784
|
+
ctg = CellTunerGUI(hoc_folder, mod_folder, title=title, print_debug=debug)
|
583
785
|
hoc_templates = ctg.get_templates(hoc_template_file=hoc_template_file)
|
584
|
-
|
786
|
+
|
585
787
|
# Cell selector
|
586
788
|
if not template:
|
587
|
-
template = questionary.select(
|
588
|
-
"Select a cell:",
|
589
|
-
choices=hoc_templates).ask()
|
789
|
+
template = questionary.select("Select a cell:", choices=hoc_templates).ask()
|
590
790
|
|
591
791
|
ctg.load_template(template)
|
592
792
|
if not title:
|
593
|
-
title =
|
793
|
+
title = (
|
794
|
+
template
|
795
|
+
+ " - Cell Configurator - Interface generated by BMTool (https://github.com/tjbanks/bmtool)"
|
796
|
+
)
|
594
797
|
|
595
798
|
# Mode selector
|
596
799
|
if easy is None and builder is None:
|
597
800
|
easy = questionary.confirm("Use pre-built interface? (no for advanced mode) ").ask()
|
598
|
-
|
801
|
+
|
599
802
|
if easy:
|
600
|
-
#Window 1
|
803
|
+
# Window 1
|
601
804
|
window_index = ctg.add_window(title=title)
|
602
|
-
#Column 1
|
805
|
+
# Column 1
|
603
806
|
column_index = ctg.add_column(window_index)
|
604
807
|
plot_widget = PlotWidget(tstop=tstop)
|
605
|
-
sec_text = ctg.root_sec.hname().split(
|
606
|
-
plot_widget.add_expr(ctg.root_sec(0.5)._ref_v,sec_text)
|
607
|
-
ctg.add_widget(window_index,column_index,plot_widget)
|
608
|
-
|
808
|
+
sec_text = ctg.root_sec.hname().split(".")[-1] + "(.5)"
|
809
|
+
plot_widget.add_expr(ctg.root_sec(0.5)._ref_v, sec_text)
|
810
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
811
|
+
|
609
812
|
if len(ctg.sections) > 1:
|
610
813
|
plot_widget = PlotWidget(tstop=tstop)
|
611
814
|
for sec in ctg.sections:
|
612
|
-
sec_text = sec.hname().split(
|
613
|
-
plot_widget.add_expr(sec(0.5)._ref_v,sec_text)
|
614
|
-
ctg.add_widget(window_index,column_index,plot_widget)
|
615
|
-
|
616
|
-
#Column 2
|
815
|
+
sec_text = sec.hname().split(".")[-1] + "(.5)"
|
816
|
+
plot_widget.add_expr(sec(0.5)._ref_v, sec_text)
|
817
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
818
|
+
|
819
|
+
# Column 2
|
617
820
|
column_index = ctg.add_column(window_index)
|
618
|
-
for i in range(len(ctg.sections))
|
619
|
-
#import pdb;pdb.set_trace()
|
821
|
+
for i in range(len(ctg.sections)): # regular iteration was acting funny
|
822
|
+
# import pdb;pdb.set_trace()
|
620
823
|
sec_menu_widget = SecMenuWidget(ctg.sections[i])
|
621
|
-
ctg.add_widget(window_index,column_index,sec_menu_widget)
|
824
|
+
ctg.add_widget(window_index, column_index, sec_menu_widget)
|
622
825
|
|
623
|
-
#Column 3
|
826
|
+
# Column 3
|
624
827
|
column_index = ctg.add_column(window_index)
|
625
828
|
control_widget = ControlMenuWidget()
|
626
|
-
ctg.add_widget(window_index,column_index,control_widget)
|
627
|
-
iclamp_widget, iclamp = ctg.new_IClamp_Widget(ctg.sections[0](0.5),200,0.1,25)
|
628
|
-
ctg.add_widget(window_index,column_index,iclamp_widget)
|
629
|
-
|
630
|
-
else:
|
829
|
+
ctg.add_widget(window_index, column_index, control_widget)
|
830
|
+
iclamp_widget, iclamp = ctg.new_IClamp_Widget(ctg.sections[0](0.5), 200, 0.1, 25)
|
831
|
+
ctg.add_widget(window_index, column_index, iclamp_widget)
|
832
|
+
|
833
|
+
else:
|
631
834
|
cmd_builder = BaseBuilder(ctg)
|
632
835
|
cmd_builder.run()
|
633
|
-
|
634
836
|
|
635
837
|
# Section selector
|
636
|
-
#section_names = ctg.get_section_names()
|
838
|
+
# section_names = ctg.get_section_names()
|
637
839
|
|
638
|
-
#sections_selected = questionary.checkbox(
|
840
|
+
# sections_selected = questionary.checkbox(
|
639
841
|
#'Select sections you want to configure (each will recieve a window):',
|
640
|
-
#choices=section_names).ask()
|
842
|
+
# choices=section_names).ask()
|
641
843
|
|
642
844
|
# Display selector
|
643
|
-
#displays_available = ['Voltages', 'Currents', 'Conductances', 'FIR']
|
644
|
-
#inputs_available = ['Current Clamp', 'Spike Input']
|
645
|
-
#configuration_available = ['Parameter']
|
845
|
+
# displays_available = ['Voltages', 'Currents', 'Conductances', 'FIR']
|
846
|
+
# inputs_available = ['Current Clamp', 'Spike Input']
|
847
|
+
# configuration_available = ['Parameter']
|
646
848
|
|
647
|
-
#Do you want to select which currents to plot?
|
648
|
-
#import pdb;pdb.set_trace()
|
849
|
+
# Do you want to select which currents to plot?
|
850
|
+
# import pdb;pdb.set_trace()
|
649
851
|
if write_hoc:
|
650
852
|
ctg.write_hoc(write_hoc)
|
651
853
|
|
652
854
|
if not hide:
|
653
855
|
ctg.show()
|
654
856
|
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
@click.option('--
|
660
|
-
@click.option(
|
661
|
-
@click.option(
|
662
|
-
@click.option(
|
663
|
-
@click.option(
|
664
|
-
|
665
|
-
|
666
|
-
|
857
|
+
|
858
|
+
@cell.command("fi", help="Creates a NEURON GUI window with FI curve and passive properties")
|
859
|
+
# @click.option('--easy', type=click.BOOL, default=None, is_flag=True, help="override the default simulation config mod file location")
|
860
|
+
# @click.option('--write-hoc', type=click.STRING, default=None, help="write a standalone hoc file for your GUI, supply filename")
|
861
|
+
# @click.option('--hide', type=click.BOOL, default=False, is_flag=True, help="hide the interface that shows automatically after building the GUI")
|
862
|
+
@click.option("--title", type=click.STRING, default=None)
|
863
|
+
@click.option("--min-pa", type=click.INT, default=0, help="Min pA for injection")
|
864
|
+
@click.option("--max-pa", type=click.INT, default=1000, help="Max pA for injection")
|
865
|
+
@click.option(
|
866
|
+
"--passive-delay",
|
867
|
+
type=click.INT,
|
868
|
+
default=650,
|
869
|
+
help="Wait n ms before determining steadystate value (default: 650)",
|
870
|
+
)
|
871
|
+
@click.option(
|
872
|
+
"--increment", type=click.FLOAT, default=100, help="Increment the injection by [i] pA"
|
873
|
+
)
|
874
|
+
@click.option("--tstart", type=click.INT, default=150, help="Injection start time")
|
875
|
+
@click.option("--tdur", type=click.INT, default=1000, help="Duration of injection default:1000ms")
|
876
|
+
@click.option(
|
877
|
+
"--advanced",
|
878
|
+
type=click.BOOL,
|
879
|
+
default=False,
|
880
|
+
is_flag=True,
|
881
|
+
help="Interactive dialog to select injection and recording points",
|
882
|
+
)
|
667
883
|
@click.pass_context
|
668
|
-
def cell_fir(
|
669
|
-
|
670
|
-
|
884
|
+
def cell_fir(
|
885
|
+
ctx, title, min_pa, max_pa, passive_delay, increment, tstart, tdur, advanced
|
886
|
+
): # , title, populations, group_by, save_file):
|
887
|
+
from .neuron.celltuner import (
|
888
|
+
CellTunerGUI,
|
889
|
+
FICurveWidget,
|
890
|
+
PlotWidget,
|
891
|
+
TextWidget,
|
892
|
+
)
|
671
893
|
|
672
894
|
hoc_folder = ctx.obj["hoc_folder"]
|
673
895
|
mod_folder = ctx.obj["mod_folder"]
|
674
896
|
hoc_template_file = ctx.obj["hoc_template_file"]
|
675
897
|
template = ctx.obj["cell_template"]
|
676
898
|
|
677
|
-
tstop = tstart+tdur
|
899
|
+
tstop = tstart + tdur
|
678
900
|
|
679
|
-
ctg = CellTunerGUI(hoc_folder,mod_folder,tstop=tstop,skip_load_mod=True)
|
901
|
+
ctg = CellTunerGUI(hoc_folder, mod_folder, tstop=tstop, skip_load_mod=True)
|
680
902
|
hoc_templates = ctg.get_templates(hoc_template_file=hoc_template_file)
|
681
|
-
|
903
|
+
|
682
904
|
# Cell selector
|
683
905
|
if not template:
|
684
|
-
template = questionary.select(
|
685
|
-
"Select a cell:",
|
686
|
-
choices=hoc_templates).ask()
|
906
|
+
template = questionary.select("Select a cell:", choices=hoc_templates).ask()
|
687
907
|
|
688
908
|
ctg.load_template(template)
|
689
909
|
if not title:
|
690
|
-
title =
|
691
|
-
|
692
|
-
|
910
|
+
title = (
|
911
|
+
template
|
912
|
+
+ " - Cell FI Curve - Interface generated by BMTool (https://github.com/tjbanks/bmtool)"
|
913
|
+
)
|
914
|
+
# ctg.set_title(title)
|
915
|
+
|
693
916
|
inj_sec = ctg.root_sec.hname()
|
694
917
|
rec_sec = ctg.root_sec.hname()
|
695
918
|
|
696
|
-
inj_loc = "0.5"
|
919
|
+
inj_loc = "0.5"
|
697
920
|
rec_loc = "0.5"
|
698
|
-
|
921
|
+
|
699
922
|
if advanced:
|
700
923
|
inj_sec = questionary.select(
|
701
|
-
"Select the current injection segment: ",
|
702
|
-
choices=ctg.get_section_names()
|
924
|
+
"Select the current injection segment: ", choices=ctg.get_section_names()
|
703
925
|
).ask()
|
704
926
|
inj_loc = questionary.text("Enter current injection segment location (eg:0.5): ").ask()
|
705
927
|
rec_sec = questionary.select(
|
706
|
-
"Select the recording segment: ",
|
707
|
-
choices=ctg.get_section_names()
|
928
|
+
"Select the recording segment: ", choices=ctg.get_section_names()
|
708
929
|
).ask()
|
709
930
|
rec_loc = questionary.text("Enter recording segment location (eg:0.5): ").ask()
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
931
|
+
|
932
|
+
rec_sec_split = rec_sec.split(".")[-1]
|
933
|
+
inj_sec_split = inj_sec.split(".")[-1]
|
934
|
+
|
935
|
+
click.echo(
|
936
|
+
"Using section " + colored.green(inj_sec_split + "(" + inj_loc + ")") + " for injection"
|
937
|
+
)
|
938
|
+
click.echo(
|
939
|
+
"Using section " + colored.green(rec_sec_split + "(" + rec_loc + ")") + " for recording"
|
940
|
+
)
|
941
|
+
|
942
|
+
# Window 1
|
943
|
+
window_index = ctg.add_window(title=title, width=800, height=650)
|
944
|
+
# Column 1
|
721
945
|
column_index = ctg.add_column(window_index)
|
722
|
-
fir_widget = FICurveWidget(
|
723
|
-
|
946
|
+
fir_widget = FICurveWidget(
|
947
|
+
template,
|
948
|
+
i_increment=increment,
|
949
|
+
i_start=min_pa,
|
950
|
+
i_stop=max_pa,
|
951
|
+
tstart=tstart,
|
952
|
+
tdur=tdur,
|
953
|
+
passive_delay=passive_delay,
|
954
|
+
record_sec=rec_sec_split,
|
955
|
+
record_loc=rec_loc,
|
956
|
+
inj_sec=inj_sec_split,
|
957
|
+
inj_loc=inj_loc,
|
958
|
+
)
|
724
959
|
|
725
|
-
|
726
960
|
plot_widget = PlotWidget(tstop=ctg.tstop)
|
727
|
-
plot_widget.add_expr(
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
961
|
+
plot_widget.add_expr(
|
962
|
+
eval("fir_widget.passive_cell." + rec_sec_split + "(" + rec_loc + ")._ref_v"),
|
963
|
+
str(round(float(fir_widget.passive_amp), 2)),
|
964
|
+
)
|
965
|
+
for cell, amp in zip(fir_widget.cells, fir_widget.amps):
|
966
|
+
plot_widget.add_expr(
|
967
|
+
eval("cell." + rec_sec_split + "(" + rec_loc + ")._ref_v"), str(round(float(amp), 2))
|
968
|
+
)
|
969
|
+
|
970
|
+
ctg.add_widget(window_index, column_index, fir_widget)
|
971
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
972
|
+
|
973
|
+
# Column 2
|
974
|
+
# column_index = ctg.add_column(window_index)
|
975
|
+
# control_widget = ControlMenuWidget()
|
976
|
+
# ctg.add_widget(window_index,column_index,control_widget)
|
977
|
+
|
739
978
|
text_widget = TextWidget()
|
740
979
|
text_widget.set_to_fir_passive(fir_widget)
|
741
980
|
ctg.add_widget(window_index, column_index, text_widget)
|
742
981
|
|
743
|
-
ctg.show(auto_run=True,on_complete=text_widget.update_fir_passive)
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
@
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
@click.option(
|
755
|
-
@click.option(
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
982
|
+
ctg.show(auto_run=True, on_complete=text_widget.update_fir_passive)
|
983
|
+
|
984
|
+
|
985
|
+
# https://www.youtube.com/watch?v=MkzeOmkOUHM
|
986
|
+
|
987
|
+
|
988
|
+
@cell.command(
|
989
|
+
"vhsegbuild",
|
990
|
+
help="Alturki et al. (2016) V1/2 Automated Segregation Interface, simplify tuning by separating channel activation AUTO BUILD EXPERIMENT",
|
991
|
+
)
|
992
|
+
@click.option("--title", type=click.STRING, default=None)
|
993
|
+
@click.option("--tstop", type=click.INT, default=1150)
|
994
|
+
@click.option(
|
995
|
+
"--outhoc",
|
996
|
+
type=click.STRING,
|
997
|
+
default="segmented_template.hoc",
|
998
|
+
help="Specify the file you want the modified cell template written to",
|
999
|
+
)
|
1000
|
+
@click.option(
|
1001
|
+
"--outfolder",
|
1002
|
+
type=click.STRING,
|
1003
|
+
default="./",
|
1004
|
+
help="Specify the directory you want the modified cell template and mod files written to (default: _seg)",
|
1005
|
+
)
|
1006
|
+
@click.option(
|
1007
|
+
"--outappend",
|
1008
|
+
type=click.BOOL,
|
1009
|
+
default=False,
|
1010
|
+
is_flag=True,
|
1011
|
+
help="Append out instead of overwriting (default: False)",
|
1012
|
+
)
|
1013
|
+
# @click.option('--skipmod',type=click.BOOL,default=False,is_flag=True,help="Skip new mod file generation")
|
1014
|
+
@click.option(
|
1015
|
+
"--debug", type=click.BOOL, default=False, is_flag=True, help="Print all debug statements"
|
1016
|
+
)
|
1017
|
+
@click.option(
|
1018
|
+
"--build",
|
1019
|
+
type=click.BOOL,
|
1020
|
+
default=False,
|
1021
|
+
is_flag=True,
|
1022
|
+
help="Build must be run before viewing GUI",
|
1023
|
+
)
|
1024
|
+
@click.option("--fminpa", type=click.INT, default=0, help="Starting FIR Curve amps (default: 0)")
|
1025
|
+
@click.option(
|
1026
|
+
"--fmaxpa", type=click.INT, default=1000, help="Ending FIR Curve amps (default: 1000)"
|
1027
|
+
)
|
1028
|
+
@click.option(
|
1029
|
+
"--fincrement",
|
1030
|
+
type=click.INT,
|
1031
|
+
default=100,
|
1032
|
+
help="Increment the FIR Curve amps by supplied pA (default: 100)",
|
1033
|
+
)
|
760
1034
|
@click.pass_context
|
761
|
-
def cell_vhsegbuild(
|
1035
|
+
def cell_vhsegbuild(
|
1036
|
+
ctx, title, tstop, outhoc, outfolder, outappend, debug, build, fminpa, fmaxpa, fincrement
|
1037
|
+
):
|
762
1038
|
click.echo(colored.red("EXPERIMENTAL - UNLIKELY TO WORK"))
|
763
1039
|
if not build:
|
764
1040
|
click.echo(colored.red("BE SURE TO RUN `vhseg --build` FOR YOUR CELL FIRST!"))
|
765
|
-
from .neuron.celltuner import
|
766
|
-
|
1041
|
+
from .neuron.celltuner import (
|
1042
|
+
AutoVInitWidget,
|
1043
|
+
CellTunerGUI,
|
1044
|
+
ControlMenuWidget,
|
1045
|
+
FICurveWidget,
|
1046
|
+
MultiSecMenuWidget,
|
1047
|
+
PlotWidget,
|
1048
|
+
PointMenuWidget,
|
1049
|
+
SegregationFIRFitWidget,
|
1050
|
+
SegregationPassiveWidget,
|
1051
|
+
SegregationSelectorWidget,
|
1052
|
+
TextWidget,
|
1053
|
+
VoltagePlotWidget,
|
1054
|
+
)
|
1055
|
+
|
767
1056
|
hoc_folder = ctx.obj["hoc_folder"]
|
768
1057
|
mod_folder = ctx.obj["mod_folder"]
|
769
1058
|
hoc_template_file = ctx.obj["hoc_template_file"]
|
770
1059
|
template = ctx.obj["cell_template"]
|
771
1060
|
|
772
1061
|
if build:
|
773
|
-
ctg = CellTunerGUI(hoc_folder,mod_folder,tstop=tstop,print_debug=debug)
|
1062
|
+
ctg = CellTunerGUI(hoc_folder, mod_folder, tstop=tstop, print_debug=debug)
|
774
1063
|
else:
|
775
|
-
#template = template + "Seg" #Likely not the best way to do it
|
776
|
-
#slm = True if os.path.abspath("./"+outfolder) == os.path.abspath(mod_folder) else False
|
777
|
-
ctg = CellTunerGUI(
|
1064
|
+
# template = template + "Seg" #Likely not the best way to do it
|
1065
|
+
# slm = True if os.path.abspath("./"+outfolder) == os.path.abspath(mod_folder) else False
|
1066
|
+
ctg = CellTunerGUI(
|
1067
|
+
"./" + outfolder, "./" + outfolder, tstop=tstop, print_debug=debug
|
1068
|
+
) # ,skip_load_mod=slm)
|
778
1069
|
pass
|
779
|
-
#ctg.load_template(template,hoc_template_file=outhoc)
|
1070
|
+
# ctg.load_template(template,hoc_template_file=outhoc)
|
780
1071
|
|
781
|
-
|
782
|
-
if build:
|
1072
|
+
if build:
|
783
1073
|
# Cell selector
|
784
1074
|
hoc_templates = ctg.get_templates(hoc_template_file=hoc_template_file)
|
785
1075
|
if not template:
|
786
|
-
template = questionary.select(
|
787
|
-
"Select a cell:",
|
788
|
-
choices=hoc_templates).ask()
|
1076
|
+
template = questionary.select("Select a cell:", choices=hoc_templates).ask()
|
789
1077
|
|
790
1078
|
ctg.load_template(template)
|
791
1079
|
else:
|
792
1080
|
# Cell selector
|
793
1081
|
hoc_templates = ctg.get_templates(hoc_template_file=outhoc)
|
794
1082
|
if not template:
|
795
|
-
template = questionary.select(
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
ctg.load_template(template,hoc_template_file=outhoc)
|
800
|
-
|
1083
|
+
template = questionary.select("Select a cell:", choices=hoc_templates).ask()
|
1084
|
+
|
1085
|
+
ctg.load_template(template, hoc_template_file=outhoc)
|
1086
|
+
|
801
1087
|
if not title:
|
802
|
-
title =
|
803
|
-
|
1088
|
+
title = (
|
1089
|
+
template
|
1090
|
+
+ " - V1/2 Segregation - Interface generated by BMTool (https://github.com/tjbanks/bmtool)"
|
1091
|
+
)
|
1092
|
+
# import pdb;pdb.set_trace()
|
804
1093
|
sec = ctg.root_sec.hname()
|
805
|
-
sec_split = sec.split(
|
1094
|
+
sec_split = sec.split(".")[-1]
|
806
1095
|
click.echo("Using section " + colored.green(sec_split))
|
807
|
-
|
1096
|
+
|
808
1097
|
if build:
|
809
1098
|
# Carry out the segregation method
|
810
|
-
fpath = os.path.abspath(
|
1099
|
+
fpath = os.path.abspath("./" + outfolder)
|
811
1100
|
if not os.path.exists(fpath):
|
812
1101
|
try:
|
813
1102
|
os.mkdir(fpath)
|
@@ -815,19 +1104,20 @@ def cell_vhsegbuild(ctx,title,tstop,outhoc,outfolder,outappend,debug,build,fminp
|
|
815
1104
|
print("Creation of the directory %s failed" % fpath)
|
816
1105
|
|
817
1106
|
mechs_processed = ctg.seg_mechs(folder=fpath)
|
818
|
-
template = ctg.seg_template(os.path.join(fpath,outhoc),mechs_processed)
|
1107
|
+
template = ctg.seg_template(os.path.join(fpath, outhoc), mechs_processed)
|
819
1108
|
click.echo(colored.green("COMPILING MOD FILES"))
|
820
1109
|
|
821
1110
|
cwd = os.getcwd()
|
822
1111
|
|
823
|
-
if os.path.abspath(mod_folder) != cwd:
|
824
|
-
import glob
|
1112
|
+
if os.path.abspath(mod_folder) != cwd: # The mod files will get loaded already
|
1113
|
+
import glob
|
1114
|
+
import shutil
|
825
1115
|
|
826
1116
|
files = glob.iglob(os.path.join(mod_folder, "*.mod"))
|
827
1117
|
for file in files:
|
828
1118
|
if os.path.isfile(file):
|
829
1119
|
shutil.copy2(file, fpath)
|
830
|
-
|
1120
|
+
|
831
1121
|
os.chdir(fpath)
|
832
1122
|
ret = os.system("nrnivmodl")
|
833
1123
|
os.chdir(cwd)
|
@@ -835,31 +1125,35 @@ def cell_vhsegbuild(ctx,title,tstop,outhoc,outfolder,outappend,debug,build,fminp
|
|
835
1125
|
if not ret:
|
836
1126
|
click.echo(colored.green("COMPILATION COMPLETE"))
|
837
1127
|
else:
|
838
|
-
click.echo(
|
1128
|
+
click.echo(
|
1129
|
+
colored.red(
|
1130
|
+
"nrnivmodl may not have been run, execute nrnivmodl or mknrndll manually in the `"
|
1131
|
+
)
|
1132
|
+
+ colored.green(fpath)
|
1133
|
+
+ colored.red("` folder then press enter...")
|
1134
|
+
)
|
839
1135
|
input()
|
840
1136
|
click.echo(colored.green("Done... remove the `--build` flag and re-run."))
|
841
1137
|
return
|
842
1138
|
else:
|
843
|
-
#template = template + "Seg" #Likely not the best way to do it
|
844
|
-
#slm = True if os.path.abspath("./"+outfolder) == os.path.abspath(mod_folder) else False
|
845
|
-
#ctg = CellTunerGUI("./"+outfolder,"./"+outfolder,tstop=tstop,print_debug=debug,skip_load_mod=slm)
|
1139
|
+
# template = template + "Seg" #Likely not the best way to do it
|
1140
|
+
# slm = True if os.path.abspath("./"+outfolder) == os.path.abspath(mod_folder) else False
|
1141
|
+
# ctg = CellTunerGUI("./"+outfolder,"./"+outfolder,tstop=tstop,print_debug=debug,skip_load_mod=slm)
|
846
1142
|
pass
|
847
|
-
#ctg.load_template(template,hoc_template_file=outhoc)
|
1143
|
+
# ctg.load_template(template,hoc_template_file=outhoc)
|
848
1144
|
|
849
1145
|
do_others = False
|
850
1146
|
if ctg.other_sec:
|
851
|
-
do_others = questionary.confirm("Show other sections? (default: No)",default=False).ask()
|
1147
|
+
do_others = questionary.confirm("Show other sections? (default: No)", default=False).ask()
|
852
1148
|
selected_segments = []
|
853
1149
|
if do_others:
|
854
|
-
choices = [s.name().split(
|
1150
|
+
choices = [s.name().split(".")[-1] for s in ctg.other_sec]
|
855
1151
|
selected_segments = questionary.checkbox(
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
1152
|
+
"Select other sections (space bar to select):", choices=choices
|
1153
|
+
).ask()
|
860
1154
|
|
861
1155
|
section_selected = "soma"
|
862
|
-
#FIR Properties
|
1156
|
+
# FIR Properties
|
863
1157
|
min_pa = fminpa
|
864
1158
|
max_pa = fmaxpa
|
865
1159
|
increment = fincrement
|
@@ -867,13 +1161,15 @@ def cell_vhsegbuild(ctx,title,tstop,outhoc,outfolder,outappend,debug,build,fminp
|
|
867
1161
|
tdur = 1000
|
868
1162
|
inj_sec = ctg.root_sec.hname()
|
869
1163
|
rec_sec = ctg.root_sec.hname()
|
870
|
-
inj_loc = "0.5"
|
1164
|
+
inj_loc = "0.5"
|
871
1165
|
rec_loc = "0.5"
|
872
|
-
rec_sec_split = rec_sec.split(
|
873
|
-
inj_sec_split = inj_sec.split(
|
1166
|
+
rec_sec_split = rec_sec.split(".")[-1]
|
1167
|
+
inj_sec_split = inj_sec.split(".")[-1]
|
874
1168
|
|
875
|
-
if tstop < tstart+tdur:
|
876
|
-
print(
|
1169
|
+
if tstop < tstart + tdur:
|
1170
|
+
print(
|
1171
|
+
"tstop must be greater than " + str(tstart + tdur) + " due to FIR injection properties"
|
1172
|
+
)
|
877
1173
|
print("Exiting")
|
878
1174
|
return
|
879
1175
|
# Current Clamp properties
|
@@ -881,8 +1177,18 @@ def cell_vhsegbuild(ctx,title,tstop,outhoc,outfolder,outappend,debug,build,fminp
|
|
881
1177
|
dur = 1000
|
882
1178
|
amp = 0.2
|
883
1179
|
|
884
|
-
fir_widget = FICurveWidget(
|
885
|
-
|
1180
|
+
fir_widget = FICurveWidget(
|
1181
|
+
template,
|
1182
|
+
i_increment=increment,
|
1183
|
+
i_start=min_pa,
|
1184
|
+
i_stop=max_pa,
|
1185
|
+
tstart=tstart,
|
1186
|
+
tdur=tdur,
|
1187
|
+
record_sec=rec_sec_split,
|
1188
|
+
record_loc=rec_loc,
|
1189
|
+
inj_sec=inj_sec_split,
|
1190
|
+
inj_loc=inj_loc,
|
1191
|
+
)
|
886
1192
|
other_cells = fir_widget.cells + [fir_widget.passive_cell]
|
887
1193
|
|
888
1194
|
for segment in selected_segments:
|
@@ -890,116 +1196,198 @@ def cell_vhsegbuild(ctx,title,tstop,outhoc,outfolder,outappend,debug,build,fminp
|
|
890
1196
|
# Column 1
|
891
1197
|
column_index = ctg.add_column(window_index)
|
892
1198
|
plot_widget = PlotWidget(tstop=tstop)
|
893
|
-
sec_text = segment+"(.5)"
|
894
|
-
cellsec = eval(
|
895
|
-
plot_widget.add_expr(cellsec(0.5)._ref_v,sec_text)
|
1199
|
+
sec_text = segment + "(.5)"
|
1200
|
+
cellsec = eval("ctg.template." + section_selected)
|
1201
|
+
plot_widget.add_expr(cellsec(0.5)._ref_v, sec_text)
|
896
1202
|
|
897
|
-
ctg.add_widget(window_index,column_index,plot_widget)
|
1203
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
898
1204
|
|
899
1205
|
widget = ControlMenuWidget()
|
900
|
-
ctg.add_widget(window_index,column_index,widget)
|
1206
|
+
ctg.add_widget(window_index, column_index, widget)
|
901
1207
|
|
902
1208
|
# Column 2
|
903
1209
|
column_index = ctg.add_column(window_index)
|
904
|
-
widget = MultiSecMenuWidget(ctg.root_sec.cell(), other_cells,segment,ctg.mechanism_dict)
|
905
|
-
ctg.add_widget(window_index,column_index,widget)
|
906
|
-
|
1210
|
+
widget = MultiSecMenuWidget(ctg.root_sec.cell(), other_cells, segment, ctg.mechanism_dict)
|
1211
|
+
ctg.add_widget(window_index, column_index, widget)
|
907
1212
|
|
908
|
-
#Window 1
|
1213
|
+
# Window 1
|
909
1214
|
window_index = ctg.add_window(title=title)
|
910
1215
|
|
911
|
-
#Column 1
|
1216
|
+
# Column 1
|
912
1217
|
column_index = ctg.add_column(window_index)
|
913
1218
|
|
914
1219
|
plot_widget = PlotWidget(tstop=tstop)
|
915
|
-
sec_text = ctg.root_sec.hname().split(
|
916
|
-
|
917
|
-
plot_widget.add_expr(ctg.root_sec(0.5)._ref_v,sec_text)
|
918
|
-
plot_widget.add_expr(eval("fir_widget.passive_cell." + rec_sec_split + "("+ rec_loc+")._ref_v"),"Passive @"+str(int(fir_widget.passive_amp*1e3))+"pA")
|
919
|
-
ctg.add_widget(window_index,column_index,plot_widget)
|
1220
|
+
sec_text = ctg.root_sec.hname().split(".")[-1] + "(.5)"
|
920
1221
|
|
921
|
-
ctg.
|
1222
|
+
plot_widget.add_expr(ctg.root_sec(0.5)._ref_v, sec_text)
|
1223
|
+
plot_widget.add_expr(
|
1224
|
+
eval("fir_widget.passive_cell." + rec_sec_split + "(" + rec_loc + ")._ref_v"),
|
1225
|
+
"Passive @" + str(int(fir_widget.passive_amp * 1e3)) + "pA",
|
1226
|
+
)
|
1227
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
922
1228
|
|
923
|
-
|
1229
|
+
ctg.add_widget(window_index, column_index, fir_widget)
|
924
1230
|
|
925
|
-
plot_widget = VoltagePlotWidget(ctg.root_sec.cell(),section="soma")
|
1231
|
+
plot_widget = VoltagePlotWidget(ctg.root_sec.cell(), section="soma")
|
926
1232
|
plot_widget.add_act_inf(ctg.mechanism_dict)
|
927
|
-
ctg.add_widget(window_index,column_index,plot_widget)
|
928
|
-
|
1233
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
929
1234
|
|
930
|
-
#Column 2
|
1235
|
+
# Column 2
|
931
1236
|
column_index = ctg.add_column(window_index)
|
932
|
-
|
933
|
-
#import pdb;pdb.set_trace()
|
934
|
-
widget = MultiSecMenuWidget(ctg.root_sec.cell(), other_cells,section_selected,ctg.mechanism_dict)
|
935
1237
|
|
936
|
-
#
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
#widget_index = ctg.add_widget(window_index, column_index,widget)
|
1238
|
+
# import pdb;pdb.set_trace()
|
1239
|
+
widget = MultiSecMenuWidget(
|
1240
|
+
ctg.root_sec.cell(), other_cells, section_selected, ctg.mechanism_dict
|
1241
|
+
)
|
941
1242
|
|
942
|
-
#
|
1243
|
+
# for cell,amp in zip(fir_widget.cells, fir_widget.amps):
|
1244
|
+
# plot_widget.add_expr(eval("cell." + rec_sec_split + "("+ rec_loc+")._ref_v"),str(round(float(amp),2)))
|
1245
|
+
widget_index = ctg.add_widget(window_index, column_index, widget)
|
1246
|
+
# widget = SecMenuWidget(ctg.root_sec,x=float(inj_loc))
|
1247
|
+
# widget_index = ctg.add_widget(window_index, column_index,widget)
|
1248
|
+
|
1249
|
+
# Column 3
|
943
1250
|
column_index = ctg.add_column(window_index)
|
944
1251
|
widget = ControlMenuWidget()
|
945
|
-
ctg.add_widget(window_index,column_index,widget)
|
946
|
-
|
1252
|
+
ctg.add_widget(window_index, column_index, widget)
|
947
1253
|
|
948
1254
|
widget = PointMenuWidget(None)
|
949
|
-
iclamp = widget.iclamp(ctg.root_sec(float(inj_loc)),dur,amp,delay)
|
1255
|
+
iclamp = widget.iclamp(ctg.root_sec(float(inj_loc)), dur, amp, delay)
|
950
1256
|
ctg.register_iclamp(iclamp)
|
951
|
-
widget_index = ctg.add_widget(window_index, column_index,widget)
|
1257
|
+
widget_index = ctg.add_widget(window_index, column_index, widget)
|
952
1258
|
|
953
1259
|
text_widget = TextWidget()
|
954
|
-
text_widget.set_to_fir_passive(fir_widget,print_calc=False,print_fi=False)
|
955
|
-
widget_index = ctg.add_widget(window_index, column_index,text_widget)
|
1260
|
+
text_widget.set_to_fir_passive(fir_widget, print_calc=False, print_fi=False)
|
1261
|
+
widget_index = ctg.add_widget(window_index, column_index, text_widget)
|
956
1262
|
|
957
1263
|
vinit_widget = AutoVInitWidget(fir_widget)
|
958
|
-
widget_index = ctg.add_widget(window_index, column_index,vinit_widget)
|
1264
|
+
widget_index = ctg.add_widget(window_index, column_index, vinit_widget)
|
959
1265
|
|
960
|
-
#Column 4
|
1266
|
+
# Column 4
|
961
1267
|
column_index = ctg.add_column(window_index)
|
962
|
-
|
963
|
-
widget = SegregationSelectorWidget(ctg.root_sec.cell(), other_cells,section_selected,ctg.mechanism_dict,all_sec=True)
|
964
|
-
ctg.add_widget(window_index,column_index,widget)
|
965
1268
|
|
966
|
-
widget =
|
967
|
-
|
1269
|
+
widget = SegregationSelectorWidget(
|
1270
|
+
ctg.root_sec.cell(), other_cells, section_selected, ctg.mechanism_dict, all_sec=True
|
1271
|
+
)
|
1272
|
+
ctg.add_widget(window_index, column_index, widget)
|
1273
|
+
|
1274
|
+
widget = SegregationPassiveWidget(
|
1275
|
+
fir_widget, ctg.root_sec.cell(), other_cells, section_selected, ctg.mechanism_dict
|
1276
|
+
)
|
1277
|
+
ctg.add_widget(window_index, column_index, widget)
|
968
1278
|
|
969
1279
|
widget = SegregationFIRFitWidget(fir_widget)
|
970
|
-
ctg.add_widget(window_index,column_index,widget)
|
1280
|
+
ctg.add_widget(window_index, column_index, widget)
|
971
1281
|
|
972
|
-
ctg.show(auto_run=True,on_complete_fih=text_widget.update_fir_passive,run_count=2)
|
1282
|
+
ctg.show(auto_run=True, on_complete_fih=text_widget.update_fir_passive, run_count=2)
|
973
1283
|
|
974
1284
|
return
|
975
1285
|
|
976
|
-
|
977
|
-
@
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
@click.option('--
|
984
|
-
@click.option('--
|
985
|
-
@click.option('--
|
986
|
-
@click.option('--
|
987
|
-
@click.option(
|
988
|
-
|
989
|
-
|
990
|
-
@click.option(
|
991
|
-
@click.option(
|
992
|
-
@click.option(
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
1286
|
+
|
1287
|
+
@cell.command(
|
1288
|
+
"vhseg",
|
1289
|
+
help="Alturki et al. (2016) V1/2 Automated Segregation Interface, simplify tuning by separating channel activation",
|
1290
|
+
)
|
1291
|
+
@click.option("--title", type=click.STRING, default=None)
|
1292
|
+
@click.option("--tstop", type=click.INT, default=1150)
|
1293
|
+
# @click.option('--outhoc',type=click.STRING,default="segmented_template.hoc",help="Specify the file you want the modified cell template written to")
|
1294
|
+
# @click.option('--outfolder',type=click.STRING,default="./",help="Specify the directory you want the modified cell template and mod files written to (default: _seg)")
|
1295
|
+
# @click.option('--outappend',type=click.BOOL,default=False,is_flag=True,help="Append out instead of overwriting (default: False)")
|
1296
|
+
# @click.option('--skipmod',type=click.BOOL,default=False,is_flag=True,help="Skip new mod file generation")
|
1297
|
+
@click.option(
|
1298
|
+
"--debug", type=click.BOOL, default=False, is_flag=True, help="Print all debug statements"
|
1299
|
+
)
|
1300
|
+
@click.option("--fminpa", type=click.INT, default=0, help="Starting FI Curve amps (default: 0)")
|
1301
|
+
@click.option("--fmaxpa", type=click.INT, default=1000, help="Ending FI Curve amps (default: 1000)")
|
1302
|
+
@click.option(
|
1303
|
+
"--passive-delay",
|
1304
|
+
type=click.INT,
|
1305
|
+
default=650,
|
1306
|
+
help="Wait n ms before determining steadystate value (default: 650)",
|
1307
|
+
)
|
1308
|
+
@click.option(
|
1309
|
+
"--fincrement",
|
1310
|
+
type=click.INT,
|
1311
|
+
default=100,
|
1312
|
+
help="Increment the FIR Curve amps by supplied pA (default: 100)",
|
1313
|
+
)
|
1314
|
+
@click.option(
|
1315
|
+
"--infvars",
|
1316
|
+
type=click.STRING,
|
1317
|
+
default=None,
|
1318
|
+
help="Specify the inf variables to plot, skips the wizard. (Comma separated, eg: inf_mech,minf_mech2,ninf_mech2)",
|
1319
|
+
)
|
1320
|
+
@click.option(
|
1321
|
+
"--segvars",
|
1322
|
+
type=click.STRING,
|
1323
|
+
default=None,
|
1324
|
+
help="Specify the segregation variables to globally set, skips the wizard. (Comma separated, eg: mseg_mech,nseg_mech2)",
|
1325
|
+
)
|
1326
|
+
@click.option("--eleak", type=click.STRING, default=None, help="Specify the eleak var manually")
|
1327
|
+
@click.option("--gleak", type=click.STRING, default=None, help="Specify the gleak var manually")
|
1328
|
+
@click.option(
|
1329
|
+
"--othersec",
|
1330
|
+
type=click.STRING,
|
1331
|
+
default=None,
|
1332
|
+
help="Specify other sections that a window should be generated for (Comma separated, eg: dend[0],dend[1])",
|
1333
|
+
)
|
1334
|
+
@click.option(
|
1335
|
+
"--clampsec",
|
1336
|
+
type=click.STRING,
|
1337
|
+
default=None,
|
1338
|
+
help="Specify sections that a current clamp should be attached. Root section will always have a clamp. (Comma separated, eg: dend[0],dend[1])",
|
1339
|
+
)
|
1340
|
+
@click.option(
|
1341
|
+
"--synsec",
|
1342
|
+
type=click.STRING,
|
1343
|
+
default=None,
|
1344
|
+
help="Specify sections that a synapse should be attached. Exp2Syn default, unless --syntype specified. (Comma separated, eg: dend[0],dend[1])",
|
1345
|
+
)
|
1346
|
+
@click.option(
|
1347
|
+
"--syntype",
|
1348
|
+
type=click.STRING,
|
1349
|
+
default="Exp2Syn",
|
1350
|
+
help="Specify the synapse mechanism that will be attached to the cell (Single type)",
|
1351
|
+
)
|
1352
|
+
@click.option(
|
1353
|
+
"--synloc", type=click.STRING, default="0.5", help="Specify the synapse location (Default: 0.5)"
|
1354
|
+
)
|
997
1355
|
@click.pass_context
|
998
|
-
def cell_vhseg(
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1356
|
+
def cell_vhseg(
|
1357
|
+
ctx,
|
1358
|
+
title,
|
1359
|
+
tstop,
|
1360
|
+
debug,
|
1361
|
+
fminpa,
|
1362
|
+
fmaxpa,
|
1363
|
+
passive_delay,
|
1364
|
+
fincrement,
|
1365
|
+
infvars,
|
1366
|
+
segvars,
|
1367
|
+
eleak,
|
1368
|
+
gleak,
|
1369
|
+
othersec,
|
1370
|
+
clampsec,
|
1371
|
+
synsec,
|
1372
|
+
syntype,
|
1373
|
+
synloc,
|
1374
|
+
):
|
1375
|
+
from .neuron.celltuner import (
|
1376
|
+
AutoVInitWidget,
|
1377
|
+
CellTunerGUI,
|
1378
|
+
ControlMenuWidget,
|
1379
|
+
FICurveWidget,
|
1380
|
+
MultiSecMenuWidget,
|
1381
|
+
PlotWidget,
|
1382
|
+
PointMenuWidget,
|
1383
|
+
SegregationFIRFitWidget,
|
1384
|
+
SegregationPassiveWidget,
|
1385
|
+
SegregationSelectorWidget,
|
1386
|
+
SingleButtonWidget,
|
1387
|
+
TextWidget,
|
1388
|
+
VoltagePlotWidget,
|
1389
|
+
)
|
1390
|
+
from .util import popupmsg, send_mail, tk_email_input
|
1003
1391
|
|
1004
1392
|
hoc_folder = ctx.obj["hoc_folder"]
|
1005
1393
|
mod_folder = ctx.obj["mod_folder"]
|
@@ -1007,31 +1395,35 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1007
1395
|
template = ctx.obj["cell_template"]
|
1008
1396
|
prefab_dict = ctx.obj["prefab"]
|
1009
1397
|
prefab_dictvh = None
|
1010
|
-
|
1011
|
-
ctg = CellTunerGUI(hoc_folder,mod_folder,tstop=tstop,print_debug=debug)
|
1012
|
-
|
1013
|
-
|
1398
|
+
|
1399
|
+
ctg = CellTunerGUI(hoc_folder, mod_folder, tstop=tstop, print_debug=debug)
|
1400
|
+
|
1014
1401
|
# Cell selector
|
1015
1402
|
hoc_templates = ctg.get_templates(hoc_template_file=hoc_template_file)
|
1016
1403
|
if not template:
|
1017
|
-
template = questionary.select(
|
1018
|
-
|
1019
|
-
choices=hoc_templates).ask()
|
1020
|
-
|
1404
|
+
template = questionary.select("Select a cell:", choices=hoc_templates).ask()
|
1405
|
+
|
1021
1406
|
ctg.load_template(template)
|
1022
1407
|
|
1023
1408
|
original_cell_values = ctg.get_current_cell_values()
|
1024
1409
|
|
1025
|
-
if
|
1410
|
+
if (
|
1411
|
+
prefab_dict
|
1412
|
+
and prefab_dict.get("cells")
|
1413
|
+
and prefab_dict["cells"].get(template)
|
1414
|
+
and prefab_dict["cells"][template].get("vhseg")
|
1415
|
+
):
|
1026
1416
|
prefab_dictvh = prefab_dict["cells"][template]["vhseg"]
|
1027
1417
|
|
1028
1418
|
if not title:
|
1029
|
-
title =
|
1030
|
-
|
1419
|
+
title = (
|
1420
|
+
template + " - V1/2 - Interface generated by BMTool (https://github.com/tjbanks/bmtool)"
|
1421
|
+
)
|
1422
|
+
# import pdb;pdb.set_trace()
|
1031
1423
|
sec = ctg.root_sec.hname()
|
1032
|
-
sec_split = sec.split(
|
1424
|
+
sec_split = sec.split(".")[-1]
|
1033
1425
|
click.echo("Using section " + colored.green(sec_split))
|
1034
|
-
|
1426
|
+
|
1035
1427
|
selected_segments = []
|
1036
1428
|
|
1037
1429
|
if prefab_dictvh and prefab_dictvh.get("othersec"):
|
@@ -1040,104 +1432,101 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1040
1432
|
else:
|
1041
1433
|
do_others = False
|
1042
1434
|
if ctg.other_sec:
|
1043
|
-
|
1044
1435
|
if othersec:
|
1045
1436
|
do_others = True
|
1046
1437
|
else:
|
1047
|
-
do_others = questionary.confirm(
|
1438
|
+
do_others = questionary.confirm(
|
1439
|
+
"Show other sections? (default: No)", default=False
|
1440
|
+
).ask()
|
1048
1441
|
|
1049
|
-
|
1050
1442
|
if do_others:
|
1051
1443
|
if othersec:
|
1052
1444
|
selected_segments = othersec.split(",")
|
1053
1445
|
else:
|
1054
|
-
choices = [s.name().split(
|
1446
|
+
choices = [s.name().split(".")[-1] for s in ctg.other_sec]
|
1055
1447
|
selected_segments = questionary.checkbox(
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1448
|
+
"Select other sections (space bar to select):", choices=choices
|
1449
|
+
).ask()
|
1450
|
+
|
1059
1451
|
section_selected = sec_split
|
1060
|
-
|
1061
|
-
#cellsec = getattr(ctg.template,section_selected)
|
1062
|
-
cellsec = eval(
|
1452
|
+
|
1453
|
+
# cellsec = getattr(ctg.template,section_selected)
|
1454
|
+
cellsec = eval("ctg.template." + section_selected)
|
1063
1455
|
|
1064
1456
|
mechs = [mech.name() for mech in cellsec(0.5) if not mech.name().endswith("_ion")]
|
1065
1457
|
ions = [mech.name() for mech in cellsec(0.5) if mech.name().endswith("_ion")]
|
1066
1458
|
cellmechvars = []
|
1067
|
-
|
1459
|
+
|
1068
1460
|
for mech in mechs:
|
1069
|
-
if hasattr(cellsec(0.5),mech):
|
1070
|
-
mechobj = getattr(cellsec(0.5),mech)
|
1461
|
+
if hasattr(cellsec(0.5), mech):
|
1462
|
+
mechobj = getattr(cellsec(0.5), mech)
|
1071
1463
|
else:
|
1072
1464
|
print(mech + " not found on " + cellsec.name())
|
1073
1465
|
continue
|
1074
|
-
|
1075
|
-
attribs = [at for at in dir(mechobj) if not at.startswith("__") and at !="name"]
|
1466
|
+
|
1467
|
+
attribs = [at for at in dir(mechobj) if not at.startswith("__") and at != "name"]
|
1076
1468
|
for attrib in attribs:
|
1077
|
-
ref = attrib+"_"+mech
|
1078
|
-
if hasattr(cellsec(0.5),ref):
|
1469
|
+
ref = attrib + "_" + mech
|
1470
|
+
if hasattr(cellsec(0.5), ref):
|
1079
1471
|
cellmechvars.append(ref)
|
1080
1472
|
|
1081
1473
|
for ion in ions:
|
1082
|
-
if hasattr(cellsec(0.5),ion):
|
1083
|
-
ionobj = getattr(cellsec(0.5),ion)
|
1474
|
+
if hasattr(cellsec(0.5), ion):
|
1475
|
+
ionobj = getattr(cellsec(0.5), ion)
|
1084
1476
|
else:
|
1085
1477
|
print(ion + " not found on " + cellsec.name())
|
1086
1478
|
continue
|
1087
|
-
attribs = [at for at in dir(ionobj) if not at.startswith("__") and at !="name"]
|
1479
|
+
attribs = [at for at in dir(ionobj) if not at.startswith("__") and at != "name"]
|
1088
1480
|
for attrib in attribs:
|
1089
1481
|
ref = attrib
|
1090
|
-
if hasattr(cellsec(0.5),ref):
|
1482
|
+
if hasattr(cellsec(0.5), ref):
|
1091
1483
|
cellmechvars.append(ref)
|
1092
1484
|
|
1093
|
-
#Puts the best matches at the top
|
1094
|
-
inf_choices = [s for s in cellmechvars if "inf" in s.lower()] + [
|
1095
|
-
|
1485
|
+
# Puts the best matches at the top
|
1486
|
+
inf_choices = [s for s in cellmechvars if "inf" in s.lower()] + [
|
1487
|
+
s for s in cellmechvars if "inf" not in s.lower()
|
1488
|
+
]
|
1489
|
+
seg_choices = [s for s in cellmechvars if "seg" in s.lower()] + [
|
1490
|
+
s for s in cellmechvars if "seg" not in s.lower()
|
1491
|
+
]
|
1096
1492
|
from neuron import h
|
1493
|
+
|
1097
1494
|
globalvars = dir(h)
|
1098
1495
|
list_global_text = "** More ** (Shows unselected global [MANY]) (current selection retained)"
|
1099
|
-
|
1496
|
+
|
1100
1497
|
if prefab_dictvh and prefab_dictvh.get("infvars"):
|
1101
1498
|
infvars = prefab_dictvh["infvars"]
|
1102
|
-
|
1499
|
+
|
1103
1500
|
else:
|
1104
1501
|
if infvars:
|
1105
1502
|
infvars = infvars.split(",")
|
1106
1503
|
else:
|
1107
|
-
question_text =
|
1504
|
+
question_text = "Select inf variables to plot (with respect to membrane potential) (space bar to select): "
|
1108
1505
|
inf_choices = inf_choices + [list_global_text]
|
1109
|
-
infvars = questionary.checkbox(
|
1110
|
-
question_text,
|
1111
|
-
choices=inf_choices).ask()
|
1506
|
+
infvars = questionary.checkbox(question_text, choices=inf_choices).ask()
|
1112
1507
|
if list_global_text in infvars:
|
1113
1508
|
infvars.remove(list_global_text)
|
1114
|
-
global_choices =
|
1115
|
-
globalinfvars = questionary.checkbox(
|
1116
|
-
question_text,
|
1117
|
-
choices=global_choices).ask()
|
1509
|
+
global_choices = [c for c in globalvars if c not in infvars]
|
1510
|
+
globalinfvars = questionary.checkbox(question_text, choices=global_choices).ask()
|
1118
1511
|
infvars = infvars + globalinfvars
|
1119
1512
|
|
1120
1513
|
if prefab_dictvh and prefab_dictvh.get("segvars"):
|
1121
1514
|
segvars = prefab_dictvh["segvars"]
|
1122
|
-
|
1515
|
+
|
1123
1516
|
else:
|
1124
1517
|
if segvars:
|
1125
1518
|
segvars = segvars.split(",")
|
1126
1519
|
else:
|
1127
|
-
question_text =
|
1520
|
+
question_text = "Select segregation variables [OR VARIABLES YOU WANT TO CHANGE ON ALL SEGMENTS at the same time] (space bar to select):"
|
1128
1521
|
seg_choices = seg_choices + [list_global_text]
|
1129
|
-
segvars = questionary.checkbox(
|
1130
|
-
question_text,
|
1131
|
-
choices=seg_choices).ask()
|
1522
|
+
segvars = questionary.checkbox(question_text, choices=seg_choices).ask()
|
1132
1523
|
if list_global_text in segvars:
|
1133
1524
|
segvars.remove(list_global_text)
|
1134
|
-
global_choices =
|
1135
|
-
globalsegvars = questionary.checkbox(
|
1136
|
-
question_text,
|
1137
|
-
choices=global_choices).ask()
|
1525
|
+
global_choices = [c for c in globalvars if c not in segvars]
|
1526
|
+
globalsegvars = questionary.checkbox(question_text, choices=global_choices).ask()
|
1138
1527
|
segvars = segvars + globalsegvars
|
1139
1528
|
|
1140
|
-
#clampsec,synsec,syntype
|
1529
|
+
# clampsec,synsec,syntype
|
1141
1530
|
clampme = []
|
1142
1531
|
synme = []
|
1143
1532
|
if selected_segments:
|
@@ -1145,12 +1534,18 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1145
1534
|
clampme = prefab_dictvh["clampsec"]
|
1146
1535
|
else:
|
1147
1536
|
if not clampsec:
|
1148
|
-
do_clamps = questionary.confirm(
|
1537
|
+
do_clamps = questionary.confirm(
|
1538
|
+
"Attach a current clamp to other section? (root section ["
|
1539
|
+
+ section_selected
|
1540
|
+
+ "] automatically attached) (default: No)",
|
1541
|
+
default=False,
|
1542
|
+
).ask()
|
1149
1543
|
|
1150
1544
|
if do_clamps:
|
1151
1545
|
clampme = questionary.checkbox(
|
1152
|
-
|
1153
|
-
|
1546
|
+
"Select other sections to attach a current clamp to (space bar to select):",
|
1547
|
+
choices=selected_segments,
|
1548
|
+
).ask()
|
1154
1549
|
else:
|
1155
1550
|
clampme = clampsec.split(",")
|
1156
1551
|
|
@@ -1158,15 +1553,21 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1158
1553
|
clampme = prefab_dictvh["synsec"]
|
1159
1554
|
else:
|
1160
1555
|
if not synsec:
|
1161
|
-
do_syns = questionary.confirm(
|
1556
|
+
do_syns = questionary.confirm(
|
1557
|
+
"Attach a synapse to other section? (root section ["
|
1558
|
+
+ section_selected
|
1559
|
+
+ "] automatically attached) (default: No)",
|
1560
|
+
default=False,
|
1561
|
+
).ask()
|
1162
1562
|
|
1163
1563
|
if do_syns:
|
1164
1564
|
synme = questionary.checkbox(
|
1165
|
-
|
1166
|
-
|
1565
|
+
"Select sections to attach an artifical synapse (space bar to select):",
|
1566
|
+
choices=selected_segments,
|
1567
|
+
).ask()
|
1167
1568
|
else:
|
1168
1569
|
synme = synsec.split(",")
|
1169
|
-
|
1570
|
+
|
1170
1571
|
if prefab_dictvh and prefab_dictvh.get("eleak"):
|
1171
1572
|
eleak = prefab_dictvh["eleak"]
|
1172
1573
|
|
@@ -1178,8 +1579,8 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1178
1579
|
|
1179
1580
|
if prefab_dictvh and prefab_dictvh.get("synloc"):
|
1180
1581
|
synloc = prefab_dictvh["synloc"]
|
1181
|
-
|
1182
|
-
#FIR Properties
|
1582
|
+
|
1583
|
+
# FIR Properties
|
1183
1584
|
min_pa = fminpa
|
1184
1585
|
max_pa = fmaxpa
|
1185
1586
|
increment = fincrement
|
@@ -1187,13 +1588,15 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1187
1588
|
tdur = 1000
|
1188
1589
|
inj_sec = ctg.root_sec.hname()
|
1189
1590
|
rec_sec = ctg.root_sec.hname()
|
1190
|
-
inj_loc = "0.5"
|
1591
|
+
inj_loc = "0.5"
|
1191
1592
|
rec_loc = "0.5"
|
1192
|
-
rec_sec_split = rec_sec.split(
|
1193
|
-
inj_sec_split = inj_sec.split(
|
1593
|
+
rec_sec_split = rec_sec.split(".")[-1]
|
1594
|
+
inj_sec_split = inj_sec.split(".")[-1]
|
1194
1595
|
|
1195
|
-
if tstop < tstart+tdur:
|
1196
|
-
print(
|
1596
|
+
if tstop < tstart + tdur:
|
1597
|
+
print(
|
1598
|
+
"tstop must be greater than " + str(tstart + tdur) + " due to FIR injection properties"
|
1599
|
+
)
|
1197
1600
|
print("Exiting")
|
1198
1601
|
return
|
1199
1602
|
# Current Clamp properties
|
@@ -1201,8 +1604,19 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1201
1604
|
dur = 1000
|
1202
1605
|
amp = 0.2
|
1203
1606
|
|
1204
|
-
fir_widget = FICurveWidget(
|
1205
|
-
|
1607
|
+
fir_widget = FICurveWidget(
|
1608
|
+
template,
|
1609
|
+
i_increment=increment,
|
1610
|
+
i_start=min_pa,
|
1611
|
+
i_stop=max_pa,
|
1612
|
+
tstart=tstart,
|
1613
|
+
tdur=tdur,
|
1614
|
+
passive_delay=passive_delay,
|
1615
|
+
record_sec=rec_sec_split,
|
1616
|
+
record_loc=rec_loc,
|
1617
|
+
inj_sec=inj_sec_split,
|
1618
|
+
inj_loc=inj_loc,
|
1619
|
+
)
|
1206
1620
|
other_cells = fir_widget.cells + [fir_widget.passive_cell]
|
1207
1621
|
|
1208
1622
|
for segment in selected_segments:
|
@@ -1213,90 +1627,104 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1213
1627
|
# Column 1
|
1214
1628
|
column_index = ctg.add_column(window_index)
|
1215
1629
|
plot_widget = PlotWidget(tstop=tstop)
|
1216
|
-
sec_text = segment+"(.5)"
|
1217
|
-
cellsec = eval(
|
1218
|
-
plot_widget.add_expr(
|
1630
|
+
sec_text = segment + "(.5)"
|
1631
|
+
cellsec = eval("ctg.template." + segment)
|
1632
|
+
plot_widget.add_expr(
|
1633
|
+
cellsec(0.5)._ref_v,
|
1634
|
+
sec_text,
|
1635
|
+
hoc_text="%s." + segment + ".v(0.5)",
|
1636
|
+
hoc_text_obj=ctg.template,
|
1637
|
+
)
|
1219
1638
|
|
1220
|
-
ctg.add_widget(window_index,column_index,plot_widget)
|
1639
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
1221
1640
|
|
1222
1641
|
if segment in clampme:
|
1223
1642
|
widget = PointMenuWidget(None)
|
1224
|
-
iclamp = widget.iclamp(cellsec(float(inj_loc)),0,0,0)
|
1643
|
+
iclamp = widget.iclamp(cellsec(float(inj_loc)), 0, 0, 0)
|
1225
1644
|
ctg.register_iclamp(iclamp)
|
1226
|
-
widget_index = ctg.add_widget(window_index, column_index,widget)
|
1227
|
-
|
1228
|
-
|
1645
|
+
widget_index = ctg.add_widget(window_index, column_index, widget)
|
1646
|
+
|
1229
1647
|
widget = ControlMenuWidget()
|
1230
|
-
ctg.add_widget(window_index,column_index,widget)
|
1648
|
+
ctg.add_widget(window_index, column_index, widget)
|
1231
1649
|
|
1232
1650
|
# Column 2
|
1233
1651
|
column_index = ctg.add_column(window_index)
|
1234
|
-
widget = MultiSecMenuWidget(ctg.root_sec.cell(), other_cells,segment,ctg.mechanism_dict)
|
1235
|
-
ctg.add_widget(window_index,column_index,widget)
|
1652
|
+
widget = MultiSecMenuWidget(ctg.root_sec.cell(), other_cells, segment, ctg.mechanism_dict)
|
1653
|
+
ctg.add_widget(window_index, column_index, widget)
|
1236
1654
|
|
1237
1655
|
if segment in synme:
|
1238
1656
|
column_index = ctg.add_column(window_index)
|
1239
1657
|
|
1240
|
-
interval = 50
|
1241
|
-
number = 0
|
1242
|
-
start = 0
|
1243
|
-
noise = 0
|
1244
|
-
weight = 1
|
1245
|
-
|
1658
|
+
interval = 50 # int(questionary.text("Enter default netstim interval (ms (mean) time between spikes): ",default="50").ask())
|
1659
|
+
number = 0 # int(questionary.text("Enter default netstim number of events ((average) number of spikes): ",default="10").ask())
|
1660
|
+
start = 0 # int(questionary.text("Enter default netstim start (ms (most likely) start time of first spike): ",default="0").ask())
|
1661
|
+
noise = 0 # float(questionary.text("Enter default netstim noise (range 0 to 1. Fractional randomness.): ",default="0").ask())
|
1662
|
+
weight = 1 # float(questionary.text("Enter default netcon weight (range 0 to 1. Default: 1): ",default="1").ask())
|
1663
|
+
|
1246
1664
|
widget = PointMenuWidget(None)
|
1247
1665
|
widget_extra = PointMenuWidget(None)
|
1248
|
-
synapse = widget_extra.synapse(eval("ctg.template."+segment),synloc,syntype)
|
1249
|
-
netstim,netcon = widget.netstim(
|
1666
|
+
synapse = widget_extra.synapse(eval("ctg.template." + segment), synloc, syntype)
|
1667
|
+
netstim, netcon = widget.netstim(
|
1668
|
+
interval, number, start, noise, target=synapse, weight=weight
|
1669
|
+
)
|
1250
1670
|
ctg.register_netstim(netstim)
|
1251
1671
|
ctg.register_netcon(netcon)
|
1252
1672
|
ctg.register_synapse(synapse)
|
1253
1673
|
|
1254
1674
|
widget_index_extra = ctg.add_widget(window_index, column_index, widget_extra)
|
1255
1675
|
widget_index = ctg.add_widget(window_index, column_index, widget)
|
1256
|
-
|
1257
1676
|
|
1258
|
-
#Window 1
|
1677
|
+
# Window 1
|
1259
1678
|
window_index = ctg.add_window(title=title)
|
1260
1679
|
|
1261
|
-
#Column 1
|
1680
|
+
# Column 1
|
1262
1681
|
column_index = ctg.add_column(window_index)
|
1263
1682
|
|
1264
1683
|
plot_widget = PlotWidget(tstop=tstop)
|
1265
|
-
sec_text = ctg.root_sec.hname().split(
|
1684
|
+
sec_text = ctg.root_sec.hname().split(".")[-1] + "(.5)"
|
1685
|
+
|
1686
|
+
plot_widget.add_expr(
|
1687
|
+
ctg.root_sec(0.5)._ref_v,
|
1688
|
+
sec_text,
|
1689
|
+
hoc_text="%s." + section_selected + ".v(0.5)",
|
1690
|
+
hoc_text_obj=ctg.template,
|
1691
|
+
)
|
1692
|
+
plot_widget.add_expr(
|
1693
|
+
eval("fir_widget.passive_cell." + rec_sec_split + "(" + rec_loc + ")._ref_v"),
|
1694
|
+
"Passive @" + str(int(fir_widget.passive_amp * 1e3)) + "pA",
|
1695
|
+
)
|
1696
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
1697
|
+
|
1698
|
+
ctg.add_widget(window_index, column_index, fir_widget)
|
1699
|
+
|
1700
|
+
plot_widget = VoltagePlotWidget(ctg.root_sec.cell(), section=section_selected)
|
1701
|
+
plot_widget.add_act_inf(variables=infvars) # ctg.mechanism_dict)
|
1702
|
+
ctg.add_widget(window_index, column_index, plot_widget)
|
1703
|
+
|
1704
|
+
# Column 2
|
1705
|
+
column_index = ctg.add_column(window_index)
|
1266
1706
|
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1707
|
+
# import pdb;pdb.set_trace()
|
1708
|
+
widget = MultiSecMenuWidget(
|
1709
|
+
ctg.root_sec.cell(), other_cells, section_selected, ctg.mechanism_dict
|
1710
|
+
)
|
1270
1711
|
|
1271
|
-
|
1712
|
+
# for cell,amp in zip(fir_widget.cells, fir_widget.amps):
|
1713
|
+
# plot_widget.add_expr(eval("cell." + rec_sec_split + "("+ rec_loc+")._ref_v"),str(round(float(amp),2)))
|
1714
|
+
widget_index = ctg.add_widget(window_index, column_index, widget)
|
1715
|
+
# widget = SecMenuWidget(ctg.root_sec,x=float(inj_loc))
|
1716
|
+
# widget_index = ctg.add_widget(window_index, column_index,widget)
|
1272
1717
|
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1718
|
+
interval = 50 # int(questionary.text("Enter default netstim interval (ms (mean) time between spikes): ",default="50").ask())
|
1719
|
+
number = 0 # int(questionary.text("Enter default netstim number of events ((average) number of spikes): ",default="10").ask())
|
1720
|
+
start = 0 # int(questionary.text("Enter default netstim start (ms (most likely) start time of first spike): ",default="0").ask())
|
1721
|
+
noise = 0 # float(questionary.text("Enter default netstim noise (range 0 to 1. Fractional randomness.): ",default="0").ask())
|
1722
|
+
weight = 1 # float(questionary.text("Enter default netcon weight (range 0 to 1. Default: 1): ",default="1").ask())
|
1277
1723
|
|
1278
|
-
#Column 2
|
1279
|
-
column_index = ctg.add_column(window_index)
|
1280
|
-
|
1281
|
-
#import pdb;pdb.set_trace()
|
1282
|
-
widget = MultiSecMenuWidget(ctg.root_sec.cell(), other_cells,section_selected,ctg.mechanism_dict)
|
1283
|
-
|
1284
|
-
#for cell,amp in zip(fir_widget.cells, fir_widget.amps):
|
1285
|
-
#plot_widget.add_expr(eval("cell." + rec_sec_split + "("+ rec_loc+")._ref_v"),str(round(float(amp),2)))
|
1286
|
-
widget_index = ctg.add_widget(window_index, column_index,widget)
|
1287
|
-
#widget = SecMenuWidget(ctg.root_sec,x=float(inj_loc))
|
1288
|
-
#widget_index = ctg.add_widget(window_index, column_index,widget)
|
1289
|
-
|
1290
|
-
interval = 50 #int(questionary.text("Enter default netstim interval (ms (mean) time between spikes): ",default="50").ask())
|
1291
|
-
number = 0 #int(questionary.text("Enter default netstim number of events ((average) number of spikes): ",default="10").ask())
|
1292
|
-
start = 0 #int(questionary.text("Enter default netstim start (ms (most likely) start time of first spike): ",default="0").ask())
|
1293
|
-
noise = 0 #float(questionary.text("Enter default netstim noise (range 0 to 1. Fractional randomness.): ",default="0").ask())
|
1294
|
-
weight = 1 #float(questionary.text("Enter default netcon weight (range 0 to 1. Default: 1): ",default="1").ask())
|
1295
|
-
|
1296
1724
|
widget = PointMenuWidget(None)
|
1297
1725
|
widget_extra = PointMenuWidget(None)
|
1298
|
-
synapse = widget_extra.synapse(eval("ctg.template."+section_selected),synloc,syntype)
|
1299
|
-
netstim,netcon = widget.netstim(interval,number,start,noise,target=synapse,weight=weight)
|
1726
|
+
synapse = widget_extra.synapse(eval("ctg.template." + section_selected), synloc, syntype)
|
1727
|
+
netstim, netcon = widget.netstim(interval, number, start, noise, target=synapse, weight=weight)
|
1300
1728
|
ctg.register_netstim(netstim)
|
1301
1729
|
ctg.register_netcon(netcon)
|
1302
1730
|
ctg.register_synapse(synapse)
|
@@ -1304,59 +1732,64 @@ def cell_vhseg(ctx,title,tstop,debug,fminpa,fmaxpa,passive_delay,fincrement,infv
|
|
1304
1732
|
widget_index_extra = ctg.add_widget(window_index, column_index, widget_extra)
|
1305
1733
|
widget_index = ctg.add_widget(window_index, column_index, widget)
|
1306
1734
|
|
1307
|
-
#Column 3
|
1735
|
+
# Column 3
|
1308
1736
|
column_index = ctg.add_column(window_index)
|
1309
1737
|
widget = ControlMenuWidget()
|
1310
|
-
ctg.add_widget(window_index,column_index,widget)
|
1311
|
-
|
1738
|
+
ctg.add_widget(window_index, column_index, widget)
|
1312
1739
|
|
1313
1740
|
widget = PointMenuWidget(None)
|
1314
|
-
iclamp = widget.iclamp(ctg.root_sec(float(inj_loc)),dur,amp,delay)
|
1741
|
+
iclamp = widget.iclamp(ctg.root_sec(float(inj_loc)), dur, amp, delay)
|
1315
1742
|
ctg.register_iclamp(iclamp)
|
1316
|
-
widget_index = ctg.add_widget(window_index, column_index,widget)
|
1743
|
+
widget_index = ctg.add_widget(window_index, column_index, widget)
|
1317
1744
|
|
1318
1745
|
text_widget = TextWidget()
|
1319
|
-
text_widget.set_to_fir_passive(fir_widget,print_calc=False,print_fi=False)
|
1320
|
-
widget_index = ctg.add_widget(window_index, column_index,text_widget)
|
1746
|
+
text_widget.set_to_fir_passive(fir_widget, print_calc=False, print_fi=False)
|
1747
|
+
widget_index = ctg.add_widget(window_index, column_index, text_widget)
|
1321
1748
|
|
1322
1749
|
vinit_widget = AutoVInitWidget(fir_widget)
|
1323
|
-
widget_index = ctg.add_widget(window_index, column_index,vinit_widget)
|
1324
|
-
|
1325
|
-
|
1750
|
+
widget_index = ctg.add_widget(window_index, column_index, vinit_widget)
|
1326
1751
|
|
1327
1752
|
def email_func():
|
1328
1753
|
addr = tk_email_input()
|
1329
1754
|
if addr is not None:
|
1330
|
-
usernotes = tk_email_input(
|
1755
|
+
usernotes = tk_email_input(
|
1756
|
+
title="Usernotes",
|
1757
|
+
prompt="Enter any notes you want to include with the email. Click cancel for no notes, and send.",
|
1758
|
+
)
|
1331
1759
|
experiment_hoc = "run_experiment.hoc"
|
1332
1760
|
changed_cell_values = ctg.get_current_cell_values(change_dict=original_cell_values)
|
1333
|
-
ctg.write_hoc(
|
1761
|
+
ctg.write_hoc(
|
1762
|
+
experiment_hoc,
|
1763
|
+
mechanism_dir="./",
|
1764
|
+
template_dir="./",
|
1765
|
+
val_set={ctg.template: changed_cell_values},
|
1766
|
+
)
|
1334
1767
|
report_file = write_report(exp_hoc=experiment_hoc)
|
1335
|
-
template_zip = template+".zip"
|
1768
|
+
template_zip = template + ".zip"
|
1336
1769
|
|
1337
1770
|
dirpath = tempfile.mkdtemp()
|
1338
1771
|
|
1339
|
-
for file in glob.glob(os.path.join(hoc_folder,"*.hoc")):
|
1340
|
-
shutil.copy2(file,dirpath)
|
1341
|
-
for file in glob.glob(os.path.join(mod_folder,"*.mod")):
|
1342
|
-
shutil.copy2(file,dirpath)
|
1343
|
-
|
1344
|
-
mod_mod_folder = os.path.join(mod_folder,"modfiles")
|
1772
|
+
for file in glob.glob(os.path.join(hoc_folder, "*.hoc")):
|
1773
|
+
shutil.copy2(file, dirpath)
|
1774
|
+
for file in glob.glob(os.path.join(mod_folder, "*.mod")):
|
1775
|
+
shutil.copy2(file, dirpath)
|
1776
|
+
|
1777
|
+
mod_mod_folder = os.path.join(mod_folder, "modfiles")
|
1345
1778
|
if os.path.exists(mod_mod_folder):
|
1346
|
-
for file in glob.glob(os.path.join(mod_mod_folder,"*.mod")):
|
1347
|
-
shutil.copy2(file,dirpath)
|
1348
|
-
|
1349
|
-
shutil.copy2(experiment_hoc,dirpath)
|
1350
|
-
shutil.copy2(report_file,dirpath)
|
1351
|
-
shutil.make_archive(template,"zip",dirpath)
|
1779
|
+
for file in glob.glob(os.path.join(mod_mod_folder, "*.mod")):
|
1780
|
+
shutil.copy2(file, dirpath)
|
1781
|
+
|
1782
|
+
shutil.copy2(experiment_hoc, dirpath)
|
1783
|
+
shutil.copy2(report_file, dirpath)
|
1784
|
+
shutil.make_archive(template, "zip", dirpath)
|
1352
1785
|
shutil.rmtree(dirpath)
|
1353
1786
|
|
1354
1787
|
if usernotes is not None:
|
1355
1788
|
usernotes = "User notes: " + usernotes
|
1356
1789
|
else:
|
1357
1790
|
usernotes = ""
|
1358
|
-
|
1359
|
-
message_subject =
|
1791
|
+
|
1792
|
+
message_subject = 'Your "' + template + '" Model from Cyneuro.org'
|
1360
1793
|
message_text = """
|
1361
1794
|
Dear BMTool User,
|
1362
1795
|
|
@@ -1364,7 +1797,7 @@ Thank you for using bmtool. Your "{}" model cell is enclosed in the attached zip
|
|
1364
1797
|
|
1365
1798
|
1. You'll need to have NEURON installed (https://neuron.yale.edu/)
|
1366
1799
|
2. Unzip the {} file.
|
1367
|
-
3. Compile the .mod files using `mknrndll` (Windows) or `nrnivmodl` (Mac/Linux), included with NEURON.
|
1800
|
+
3. Compile the .mod files using `mknrndll` (Windows) or `nrnivmodl` (Mac/Linux), included with NEURON.
|
1368
1801
|
4. Finally, double click the `{}` file to view the user interface.
|
1369
1802
|
|
1370
1803
|
{}
|
@@ -1376,63 +1809,84 @@ Cyneuro.org
|
|
1376
1809
|
BMTool
|
1377
1810
|
https://github.com/tjbanks/bmtool
|
1378
1811
|
|
1379
|
-
""".format(template,template_zip, experiment_hoc,usernotes)
|
1380
|
-
|
1381
|
-
send_mail(
|
1812
|
+
""".format(template, template_zip, experiment_hoc, usernotes)
|
1813
|
+
|
1814
|
+
send_mail(
|
1815
|
+
"BMTool@cyneuro.org",
|
1816
|
+
[addr],
|
1817
|
+
message_subject,
|
1818
|
+
message_text,
|
1819
|
+
files=[os.path.abspath(template_zip)],
|
1820
|
+
)
|
1382
1821
|
|
1383
1822
|
os.remove(experiment_hoc)
|
1384
1823
|
os.remove(report_file)
|
1385
1824
|
os.remove(template_zip)
|
1386
1825
|
|
1387
|
-
|
1388
1826
|
def save_func():
|
1389
1827
|
experiment_hoc = "run_experiment.hoc"
|
1390
1828
|
write_report(experiment_hoc)
|
1391
1829
|
changed_cell_values = ctg.get_current_cell_values(change_dict=original_cell_values)
|
1392
|
-
ctg.write_hoc(experiment_hoc,val_set={ctg.template:changed_cell_values})
|
1393
|
-
popupmsg("Saved to " + os.path.abspath("./"+experiment_hoc))
|
1830
|
+
ctg.write_hoc(experiment_hoc, val_set={ctg.template: changed_cell_values})
|
1831
|
+
popupmsg("Saved to " + os.path.abspath("./" + experiment_hoc))
|
1394
1832
|
|
1395
|
-
emailer_widget = SingleButtonWidget("Email this model",email_func)
|
1396
|
-
widget_index = ctg.add_widget(window_index, column_index,emailer_widget)
|
1833
|
+
emailer_widget = SingleButtonWidget("Email this model", email_func)
|
1834
|
+
widget_index = ctg.add_widget(window_index, column_index, emailer_widget)
|
1397
1835
|
|
1398
|
-
save_widget = SingleButtonWidget("Save Hoc GUI with parameters",save_func)
|
1399
|
-
widget_index = ctg.add_widget(window_index, column_index,save_widget)
|
1836
|
+
save_widget = SingleButtonWidget("Save Hoc GUI with parameters", save_func)
|
1837
|
+
widget_index = ctg.add_widget(window_index, column_index, save_widget)
|
1400
1838
|
|
1401
|
-
#Column 4
|
1839
|
+
# Column 4
|
1402
1840
|
column_index = ctg.add_column(window_index)
|
1403
|
-
|
1404
|
-
widget = SegregationSelectorWidget(ctg.root_sec.cell(), other_cells,section_selected,ctg.mechanism_dict,all_sec=True,variables=segvars)
|
1405
|
-
ctg.add_widget(window_index,column_index,widget)
|
1406
1841
|
|
1407
|
-
|
1408
|
-
|
1842
|
+
widget = SegregationSelectorWidget(
|
1843
|
+
ctg.root_sec.cell(),
|
1844
|
+
other_cells,
|
1845
|
+
section_selected,
|
1846
|
+
ctg.mechanism_dict,
|
1847
|
+
all_sec=True,
|
1848
|
+
variables=segvars,
|
1849
|
+
)
|
1850
|
+
ctg.add_widget(window_index, column_index, widget)
|
1851
|
+
|
1852
|
+
segpassivewidget = SegregationPassiveWidget(
|
1853
|
+
fir_widget,
|
1854
|
+
ctg.root_sec.cell(),
|
1855
|
+
other_cells,
|
1856
|
+
section_selected,
|
1857
|
+
ctg.mechanism_dict,
|
1858
|
+
gleak_var=gleak,
|
1859
|
+
eleak_var=eleak,
|
1860
|
+
)
|
1861
|
+
ctg.add_widget(window_index, column_index, segpassivewidget)
|
1409
1862
|
|
1410
1863
|
widget = SegregationFIRFitWidget(fir_widget)
|
1411
|
-
ctg.add_widget(window_index,column_index,widget)
|
1412
|
-
|
1864
|
+
ctg.add_widget(window_index, column_index, widget)
|
1413
1865
|
|
1414
1866
|
def write_report(exp_hoc=""):
|
1415
1867
|
report_file = "Report and Instructions.txt"
|
1416
1868
|
|
1417
|
-
uvrest = str(round(fir_widget.v_rest,2))
|
1869
|
+
uvrest = str(round(fir_widget.v_rest, 2))
|
1418
1870
|
if segpassivewidget.v_rest:
|
1419
|
-
uvrest = str(round(segpassivewidget.v_rest.val,2))
|
1420
|
-
|
1421
|
-
urin = str(round(fir_widget.r_in/1e6,2))
|
1871
|
+
uvrest = str(round(segpassivewidget.v_rest.val, 2))
|
1872
|
+
|
1873
|
+
urin = str(round(fir_widget.r_in / 1e6, 2))
|
1422
1874
|
if segpassivewidget.r_in:
|
1423
|
-
urin = str(round(segpassivewidget.r_in.val,2))
|
1875
|
+
urin = str(round(segpassivewidget.r_in.val, 2))
|
1424
1876
|
|
1425
|
-
utau = str(round(fir_widget.tau,2))
|
1877
|
+
utau = str(round(fir_widget.tau, 2))
|
1426
1878
|
if segpassivewidget.tau:
|
1427
|
-
utau = str(round(segpassivewidget.tau.val,2))
|
1879
|
+
utau = str(round(segpassivewidget.tau.val, 2))
|
1428
1880
|
|
1429
|
-
vrest = str(round(fir_widget.v_rest,2))
|
1430
|
-
rin = str(round(fir_widget.r_in/1e6,2))
|
1431
|
-
tau = str(round(fir_widget.tau,2))
|
1881
|
+
vrest = str(round(fir_widget.v_rest, 2))
|
1882
|
+
rin = str(round(fir_widget.r_in / 1e6, 2))
|
1883
|
+
tau = str(round(fir_widget.tau, 2))
|
1432
1884
|
|
1433
|
-
spikes = [str(round(i,0)) for i in fir_widget.plenvec]
|
1885
|
+
spikes = [str(round(i, 0)) for i in fir_widget.plenvec]
|
1434
1886
|
amps = fir_widget.amps
|
1435
|
-
ficurve = " | ".join(
|
1887
|
+
ficurve = " | ".join(
|
1888
|
+
"[" + str(round(a * 1e3, 0)) + " pA]:" + n for a, n in zip(amps, spikes)
|
1889
|
+
)
|
1436
1890
|
|
1437
1891
|
report_text = """
|
1438
1892
|
Report generated by BMTool (https://github.com/tjbanks/bmtool)
|
@@ -1440,7 +1894,7 @@ Report generated by BMTool (https://github.com/tjbanks/bmtool)
|
|
1440
1894
|
Thank you for using bmtool to model your "{}" cell. To view your cell:
|
1441
1895
|
|
1442
1896
|
1. You'll need to have NEURON installed (https://neuron.yale.edu/)
|
1443
|
-
2. Compile the .mod files using `mknrndll` (Windows) or `nrnivmodl` (Mac/Linux), included with NEURON.
|
1897
|
+
2. Compile the .mod files using `mknrndll` (Windows) or `nrnivmodl` (Mac/Linux), included with NEURON.
|
1444
1898
|
3. Finally, double click the `{}` file to view the user interface.
|
1445
1899
|
|
1446
1900
|
Cell template: {}
|
@@ -1459,29 +1913,27 @@ V_rest = {} (mV)
|
|
1459
1913
|
R_in = {} (MOhms)
|
1460
1914
|
tau = {} (ms)
|
1461
1915
|
|
1462
|
-
FI Curve:
|
1916
|
+
FI Curve:
|
1463
1917
|
{}
|
1464
1918
|
|
1465
1919
|
Cell values:
|
1466
1920
|
|
1467
|
-
""".format(template,exp_hoc,template,uvrest,urin,utau,vrest,rin,tau,ficurve)
|
1921
|
+
""".format(template, exp_hoc, template, uvrest, urin, utau, vrest, rin, tau, ficurve)
|
1468
1922
|
changed_cell_values = ctg.get_current_cell_values()
|
1469
1923
|
|
1470
|
-
with open(report_file,"w+") as f:
|
1924
|
+
with open(report_file, "w+") as f:
|
1471
1925
|
f.write(report_text)
|
1472
|
-
for sec,vals in changed_cell_values.items():
|
1473
|
-
f.write(sec+"\n")
|
1474
|
-
for key,val in vals.items():
|
1475
|
-
f.write("\t" + key + " = " + str(round(val,6)) + "\n")
|
1926
|
+
for sec, vals in changed_cell_values.items():
|
1927
|
+
f.write(sec + "\n")
|
1928
|
+
for key, val in vals.items():
|
1929
|
+
f.write("\t" + key + " = " + str(round(val, 6)) + "\n")
|
1476
1930
|
|
1477
1931
|
return report_file
|
1478
1932
|
|
1479
|
-
|
1480
|
-
ctg.show(auto_run=True,on_complete_fih=text_widget.update_fir_passive,run_count=2)
|
1481
|
-
|
1482
|
-
|
1933
|
+
ctg.show(auto_run=True, on_complete_fih=text_widget.update_fir_passive, run_count=2)
|
1483
1934
|
|
1484
1935
|
return
|
1485
1936
|
|
1937
|
+
|
1486
1938
|
if __name__ == "__main__":
|
1487
|
-
cli()
|
1939
|
+
cli()
|