-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_bionet.py
57 lines (45 loc) · 1.76 KB
/
run_bionet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os, sys, logging, faulthandler
from bmtk.simulator import bionet
from bmtk.simulator.bionet.default_setters.cell_models import loadHOC
from bmtk.simulator.bionet.modules.sim_module import SimulatorMod
from bmtk.utils.reports.spike_trains import SpikeTrains
from bmtk.utils.reports.spike_trains import PoissonSpikeGenerator
from bmtk.simulator.bionet.io_tools import io
import numpy as np
from neuron import h
import pandas as pd
# from bmtk.analyzer.cell_vars import plot_report
from feedback_loop import FeedbackLoop
from plotting import plot_figure, plotting_calculator
# Import the synaptic depression/facilitation model
import synapses
import plot_results
"""
Basic Logging features, disable faulthandler if you don't want stacktraces printed
logging determines the level and file to save logs to (might be worth moving location)
"""
faulthandler.enable()
logging.basicConfig(filename='error_logs/debug_run.log', level=logging.DEBUG)
synapses.load()
logging.info('Synapses Loaded')
press_thres = 17 # cm H20 #40
# Lingala, et al. 2016
change_thres = 10 # cm H20 #10
# Need biological value for this
bionet.pyfunction_cache.add_cell_model(loadHOC, directive='hoc', model_type='biophysical')
logging.info('Cell model added')
def run(config_file):
conf = bionet.Config.from_json(config_file, validate=True)
conf.build_env()
fbmod = FeedbackLoop()
graph = bionet.BioNetwork.from_config(conf)
sim = bionet.BioSimulator.from_config(conf, network=graph)
sim.add_mod(fbmod) # Attach the above module to the simulator.
sim.run()
fbmod.save_aff(conf.output_dir)
plot_results.run(sim=sim,conf=conf)
if __name__ == '__main__':
if __file__ != sys.argv[-1]:
run(sys.argv[-1])
else:
run('config.json')