bmtool 0.6.6.3__tar.gz → 0.6.7__tar.gz
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-0.6.6.3 → bmtool-0.6.7}/PKG-INFO +1 -1
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/SLURM.py +69 -41
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/synapses.py +5 -7
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool.egg-info/PKG-INFO +1 -1
- {bmtool-0.6.6.3 → bmtool-0.6.7}/setup.py +1 -1
- {bmtool-0.6.6.3 → bmtool-0.6.7}/LICENSE +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/README.md +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/__init__.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/__main__.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/bmplot.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/connectors.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/debug/__init__.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/debug/commands.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/debug/debug.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/graphs.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/manage.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/plot_commands.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/singlecell.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/util/__init__.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/util/commands.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/util/neuron/__init__.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/util/neuron/celltuner.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool/util/util.py +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool.egg-info/SOURCES.txt +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool.egg-info/dependency_links.txt +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool.egg-info/entry_points.txt +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool.egg-info/requires.txt +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/bmtool.egg-info/top_level.txt +0 -0
- {bmtool-0.6.6.3 → bmtool-0.6.7}/setup.cfg +0 -0
@@ -4,6 +4,8 @@ import subprocess
|
|
4
4
|
import json
|
5
5
|
import requests
|
6
6
|
import shutil
|
7
|
+
import time
|
8
|
+
import copy
|
7
9
|
|
8
10
|
|
9
11
|
def check_job_status(job_id):
|
@@ -117,7 +119,7 @@ class multiSeedSweep(seedSweep):
|
|
117
119
|
MultSeedSweeps are centered around some base JSON cell file. When that base JSON is updated, the other JSONs
|
118
120
|
change according to their ratio with the base JSON.
|
119
121
|
"""
|
120
|
-
def __init__(self, base_json_file_path, param_name,
|
122
|
+
def __init__(self, base_json_file_path, param_name, syn_dict, base_ratio=1):
|
121
123
|
"""
|
122
124
|
Initializes the multipleSeedSweep instance.
|
123
125
|
|
@@ -128,7 +130,7 @@ class multiSeedSweep(seedSweep):
|
|
128
130
|
base_ratio (float): The ratio between the other JSONs; usually the current value for the parameter.
|
129
131
|
"""
|
130
132
|
super().__init__(base_json_file_path, param_name)
|
131
|
-
self.
|
133
|
+
self.syn_dict_for_multi = syn_dict
|
132
134
|
self.base_ratio = base_ratio
|
133
135
|
|
134
136
|
def edit_all_jsons(self, new_value):
|
@@ -140,19 +142,19 @@ class multiSeedSweep(seedSweep):
|
|
140
142
|
"""
|
141
143
|
self.edit_json(new_value)
|
142
144
|
base_ratio = self.base_ratio
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
with open(json_file_path, 'r') as f:
|
148
|
-
data = json.load(f)
|
149
|
-
altered_value = new_ratio * new_value
|
150
|
-
data[self.param_name] = altered_value
|
151
|
-
|
152
|
-
with open(json_file_path, 'w') as f:
|
153
|
-
json.dump(data, f, indent=4)
|
145
|
+
|
146
|
+
json_file_path = self.syn_dict_for_multi['json_file_path']
|
147
|
+
new_ratio = self.syn_dict_for_multi['ratio'] / base_ratio
|
154
148
|
|
155
|
-
|
149
|
+
with open(json_file_path, 'r') as f:
|
150
|
+
data = json.load(f)
|
151
|
+
altered_value = new_ratio * new_value
|
152
|
+
data[self.param_name] = altered_value
|
153
|
+
|
154
|
+
with open(json_file_path, 'w') as f:
|
155
|
+
json.dump(data, f, indent=4)
|
156
|
+
|
157
|
+
print(f"JSON file '{json_file_path}' modified successfully with {self.param_name}={altered_value}.", flush=True)
|
156
158
|
|
157
159
|
|
158
160
|
class SimulationBlock:
|
@@ -273,6 +275,7 @@ export OUTPUT_DIR={case_output_dir}
|
|
273
275
|
"""
|
274
276
|
for job_id in self.job_ids:
|
275
277
|
status = check_job_status(job_id)
|
278
|
+
#print(f"status of job is {status}")
|
276
279
|
if status != 'COMPLETED': # can add PENDING here for debugging NOT FOR ACTUALLY USING IT
|
277
280
|
return False
|
278
281
|
return True
|
@@ -314,7 +317,7 @@ class BlockRunner:
|
|
314
317
|
"""
|
315
318
|
|
316
319
|
def __init__(self, blocks, json_editor=None,json_file_path=None, param_name=None,
|
317
|
-
param_values=None, check_interval=60,
|
320
|
+
param_values=None, check_interval=60,syn_dict = None,
|
318
321
|
webhook=None):
|
319
322
|
self.blocks = blocks
|
320
323
|
self.json_editor = json_editor
|
@@ -323,29 +326,46 @@ class BlockRunner:
|
|
323
326
|
self.webhook = webhook
|
324
327
|
self.param_name = param_name
|
325
328
|
self.json_file_path = json_file_path
|
326
|
-
self.
|
329
|
+
self.syn_dict = syn_dict
|
327
330
|
|
328
331
|
def submit_blocks_sequentially(self):
|
329
332
|
"""
|
330
333
|
Submits all blocks sequentially, ensuring each block starts only after the previous block has completed or is running.
|
331
334
|
Updates the JSON file with new parameters before each block run.
|
332
|
-
json file path should be the path WITH the components folder
|
333
335
|
"""
|
334
336
|
for i, block in enumerate(self.blocks):
|
335
337
|
# Update JSON file with new parameter value
|
336
|
-
if self.
|
338
|
+
if self.json_file_path == None and self.param_values == None:
|
339
|
+
source_dir = block.component_path
|
340
|
+
destination_dir = f"{source_dir}{i+1}"
|
341
|
+
block.component_path = destination_dir
|
342
|
+
shutil.copytree(source_dir, destination_dir) # create new components folder
|
337
343
|
print(f"skipping json editing for block {block.block_name}",flush=True)
|
338
344
|
else:
|
339
345
|
if len(self.blocks) != len(self.param_values):
|
340
346
|
raise Exception("Number of blocks needs to each number of params given")
|
341
347
|
new_value = self.param_values[i]
|
348
|
+
# hope this path is correct
|
349
|
+
source_dir = block.component_path
|
350
|
+
destination_dir = f"{source_dir}{i+1}"
|
351
|
+
block.component_path = destination_dir
|
352
|
+
|
353
|
+
shutil.copytree(source_dir, destination_dir) # create new components folder
|
354
|
+
json_file_path = os.path.join(destination_dir,self.json_file_path)
|
355
|
+
|
356
|
+
# need to keep the orignal around
|
357
|
+
syn_dict_temp = copy.deepcopy(self.syn_dict)
|
358
|
+
print(self.syn_dict['json_file_path'])
|
359
|
+
json_to_be_ratioed = syn_dict_temp['json_file_path']
|
360
|
+
corrected_ratio_path = os.path.join(destination_dir,json_to_be_ratioed)
|
361
|
+
syn_dict_temp['json_file_path'] = corrected_ratio_path
|
342
362
|
|
343
|
-
if self.
|
344
|
-
json_editor = seedSweep(
|
363
|
+
if self.syn_dict == None:
|
364
|
+
json_editor = seedSweep(json_file_path , self.param_name)
|
345
365
|
json_editor.edit_json(new_value)
|
346
366
|
else:
|
347
|
-
json_editor = multiSeedSweep(
|
348
|
-
|
367
|
+
json_editor = multiSeedSweep(json_file_path ,self.param_name,
|
368
|
+
syn_dict=syn_dict_temp,base_ratio=1)
|
349
369
|
json_editor.edit_all_jsons(new_value)
|
350
370
|
|
351
371
|
# Submit the block
|
@@ -357,7 +377,7 @@ class BlockRunner:
|
|
357
377
|
|
358
378
|
# Wait for the block to complete
|
359
379
|
if i == len(self.blocks) - 1:
|
360
|
-
while not block.
|
380
|
+
while not block.check_block_status():
|
361
381
|
print(f"Waiting for the last block {i} to complete...")
|
362
382
|
time.sleep(self.check_interval)
|
363
383
|
else: # Not the last block so if job is running lets start a new one (checks status list)
|
@@ -376,13 +396,14 @@ class BlockRunner:
|
|
376
396
|
submits all the blocks at once onto the queue. To do this the components dir will be cloned and each block will have its own.
|
377
397
|
Also the json_file_path should be the path after the components dir
|
378
398
|
"""
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
399
|
+
for i, block in enumerate(self.blocks):
|
400
|
+
if self.param_values == None:
|
401
|
+
source_dir = block.component_path
|
402
|
+
destination_dir = f"{source_dir}{i+1}"
|
403
|
+
block.component_path = destination_dir
|
404
|
+
shutil.copytree(source_dir, destination_dir) # create new components folder
|
405
|
+
print(f"skipping json editing for block {block.block_name}",flush=True)
|
406
|
+
else:
|
386
407
|
if block.component_path == None:
|
387
408
|
raise Exception("Unable to use parallel submitter without defining the component path")
|
388
409
|
new_value = self.param_values[i]
|
@@ -393,22 +414,29 @@ class BlockRunner:
|
|
393
414
|
|
394
415
|
shutil.copytree(source_dir, destination_dir) # create new components folder
|
395
416
|
json_file_path = os.path.join(destination_dir,self.json_file_path)
|
396
|
-
|
397
|
-
|
417
|
+
|
418
|
+
# need to keep the orignal around
|
419
|
+
syn_dict_temp = copy.deepcopy(self.syn_dict)
|
420
|
+
print(self.syn_dict['json_file_path'])
|
421
|
+
json_to_be_ratioed = syn_dict_temp['json_file_path']
|
422
|
+
corrected_ratio_path = os.path.join(destination_dir,json_to_be_ratioed)
|
423
|
+
syn_dict_temp['json_file_path'] = corrected_ratio_path
|
424
|
+
|
425
|
+
if self.syn_dict == None:
|
426
|
+
json_editor = seedSweep(json_file_path , self.param_name)
|
398
427
|
json_editor.edit_json(new_value)
|
399
428
|
else:
|
400
|
-
json_editor = multiSeedSweep(json_file_path,self.param_name,
|
401
|
-
|
402
|
-
json_editor.edit_all_jsons(new_value)
|
403
|
-
|
404
|
-
# submit block with new component path
|
429
|
+
json_editor = multiSeedSweep(json_file_path ,self.param_name,
|
430
|
+
syn_dict_temp,base_ratio=1)
|
431
|
+
json_editor.edit_all_jsons(new_value)
|
432
|
+
# submit block with new component path
|
405
433
|
print(f"Submitting block: {block.block_name}", flush=True)
|
406
434
|
block.submit_block()
|
407
435
|
if i == len(self.blocks) - 1:
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
436
|
+
print("\nEverything has been submitted. You can close out of this or keep this script running to get a message when everything is finished\n")
|
437
|
+
while not block.check_block_status():
|
438
|
+
print(f"Waiting for the last block {i} to complete...")
|
439
|
+
time.sleep(self.check_interval)
|
412
440
|
|
413
441
|
if self.webhook:
|
414
442
|
message = "SIMULATION UPDATE: Simulations are Done!"
|
@@ -197,7 +197,7 @@ class SynapseTuner:
|
|
197
197
|
syn_props = {var: slider.value for var, slider in self.dynamic_sliders.items()}
|
198
198
|
self._set_syn_prop(**syn_props)
|
199
199
|
|
200
|
-
# sets values based off optimizer
|
200
|
+
# sets values based off optimizer
|
201
201
|
if hasattr(self,'using_optimizer'):
|
202
202
|
for name, value in zip(self.param_names, self.params):
|
203
203
|
setattr(self.syn, name, value)
|
@@ -222,7 +222,7 @@ class SynapseTuner:
|
|
222
222
|
h.run()
|
223
223
|
|
224
224
|
current = np.array(self.rec_vectors[self.current_name])
|
225
|
-
syn_props = self._get_syn_prop(rise_interval=self.general_settings['rise_interval'])
|
225
|
+
syn_props = self._get_syn_prop(rise_interval=self.general_settings['rise_interval'],dt=h.dt)
|
226
226
|
current = (current - syn_props['baseline']) * 1000 # Convert to pA
|
227
227
|
current_integral = np.trapz(current, dx=h.dt) # pA·ms
|
228
228
|
|
@@ -277,7 +277,7 @@ class SynapseTuner:
|
|
277
277
|
if self.vclamp:
|
278
278
|
isyn = self.ivcl
|
279
279
|
else:
|
280
|
-
isyn = self.rec_vectors[
|
280
|
+
isyn = self.rec_vectors[self.current_name]
|
281
281
|
isyn = np.asarray(isyn)
|
282
282
|
tspk = np.asarray(self.tspk)
|
283
283
|
if tspk.size:
|
@@ -350,7 +350,7 @@ class SynapseTuner:
|
|
350
350
|
|
351
351
|
# Plot synaptic current (always included)
|
352
352
|
current = self.rec_vectors[self.current_name]
|
353
|
-
syn_prop = self._get_syn_prop(short=True)
|
353
|
+
syn_prop = self._get_syn_prop(short=True,dt=h.dt)
|
354
354
|
current = (current - syn_prop['baseline'])
|
355
355
|
current = current * 1000
|
356
356
|
|
@@ -447,13 +447,12 @@ class SynapseTuner:
|
|
447
447
|
"""
|
448
448
|
isyn = np.array(self.rec_vectors[self.current_name].to_python())
|
449
449
|
tspk = np.append(np.asarray(self.tspk), h.tstop)
|
450
|
-
syn_prop = self._get_syn_prop(short=True)
|
450
|
+
syn_prop = self._get_syn_prop(short=True,dt=h.dt)
|
451
451
|
# print("syn_prp[sign] = " + str(syn_prop['sign']))
|
452
452
|
isyn = (isyn - syn_prop['baseline'])
|
453
453
|
isyn *= syn_prop['sign']
|
454
454
|
ispk = np.floor((tspk + self.general_settings['delay']) / h.dt).astype(int)
|
455
455
|
|
456
|
-
|
457
456
|
try:
|
458
457
|
amp = [isyn[ispk[i]:ispk[i + 1]].max() for i in range(ispk.size - 1)]
|
459
458
|
# indexs of where the max of the synaptic current is at. This is then plotted
|
@@ -1159,7 +1158,6 @@ class SynapseOptimizer:
|
|
1159
1158
|
self.tuner.SingleEvent(plot_and_print=True)
|
1160
1159
|
|
1161
1160
|
|
1162
|
-
|
1163
1161
|
# dataclass means just init the typehints as self.typehint. looks a bit cleaner
|
1164
1162
|
@dataclass
|
1165
1163
|
class GapOptimizationResult:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|